MacLochlainns Weblog

Michael McLaughlin's Technical Blog

Site Admin

Oracle Segment Fails

with 2 comments

The instance that I’ve built for my students in a Fedora VM is quite stable except for one feature. The feature is the hibernation process of the base operating system. Sometimes when the base operating system hibernates, it causes the Oracle shared memory segment to fail. When that happens you get the following error:

ERROR:
ORA-01034: ORACLE NOT available
ORA-27101: shared memory realm does NOT exist
Linux-x86_64 Error: 2: No such FILE OR DIRECTORY
Process ID: 0
SESSION ID: 0 Serial NUMBER: 0

I created the master sudoer account as the student user. The oracle user is configured so that you can’t log in to the Linux OS with it. To restart the instance you can do the following in a default Oracle 11g XE installation:

su - root

or, you can do this:

sudo sh

Then as the root user, you can sign on to the oracle user’s account by using the su command without a password, like:

su - oracle

As the user who installed the Oracle instance, you can connect to the database without a password after you source the environment file. The standard Oracle 11g XE environment file can be sources like this:

. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh

Alternatively, for my students there is a .bashrc file that they can manually source. It contains the following:

# Source global definitions
if [ -f /etc/bashrc ]; then
  . /etc/bashrc
fi
 
# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=
 
# User specific aliases and functions
. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh
 
# Wrap sqlplus with rlwrap to edit prior lines with the
# up, down, left and right keys.
sqlplus () 
{
    # Discover the fully qualified program name. 
    path=`which rlwrap 2>/dev/null`
    file=''
 
    # Parse the program name from the path.
    if [ -n ${path} ]; then
        file=${path##/*/}
    fi;
 
    # Wrap when there is a file and it is rewrap.
    if [ -n ${file} ] && [[ ${file} = "rlwrap" ]]; then
        rlwrap sqlplus "${@}"
    else
        echo "Command-line history unavailable: Install the rlwrap package."
        $ORACLE_HOME/bin/sqlplus "${@}"
    fi
}
 
# Set vi as a command line editor.
set -o vi

You can source the oracle user’s .bashrc account, like this:

. .bashrc

After you’ve sourced the environment, you can connect as the internal user with the following syntax:

sqlplus / AS sysdba

Connected as the internal user, run these two commands in sequence:

shutdown IMMEDIATE
startup

Then, you should be able to connect as the student user or another ordinary user with the following syntax:

CONNECT student/student

Hope this helps my students and those who want to know how to restart the Oracle instance.

Written by maclochlainn

October 16th, 2016 at 10:29 pm