====== Oracle database status, start, stop ======
===== Manual operation =====
[oracle@aixdb01]/home/oracle> sqlplus / as sysdba
SQL*Plus: Release 11.2.0.2.0 Production on Fri Sep 4 13:18:29 2015
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
SQL> select status from v$instance;
STATUS
------------
STARTED
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 8551575552 bytes
Fixed Size 2236744 bytes
Variable Size 4429188792 bytes
Database Buffers 4093640704 bytes
Redo Buffers 26509312 bytes
===== Script to start and stop =====
# cat /etc/rc.d/init.d/oracledb
#!/bin/ksh
# Start and Stop oracle and the listener
USER=oracle
PATH1=${PATH}
SQLDBA="sqlplus /nolog"
ORATAB=/etc/oratab
ulimit -c unlimited
ulimit -d unlimited
ulimit -s unlimited
if [ ! -f $ORATAB ]
then
echo "ERROR file $ORATAB doesn't exists"
exit 1
fi
StartService()
{
echo "Starting Oracle databases"
su $USER -c "$SQLDBA $args < /dev/null;echo $?) -ne 0 ]
then
echo "Starting Oracle LISTENER"
su - $USER -c "$ORACLE_HOME/bin/lsnrctl start"
fi
}
StopService()
{
if [ $(ps -ef | grep "$ORACLE_HOME/bin/tnslsnr | grep -v grep > /dev/null;echo $?) -eq 0 ]
then
echo "Stopping Oracle LISTENER"
su - $USER -c "$ORACLE_HOME/bin/lsnrctl stop"
fi
echo "Stopping Oracle databases"
su $USER -c "$SQLDBA $args < /dev/null;echo $?) -eq 0 ]
then
echo "Listener is started OK"
else
echo "no Listener for this DB
fi
done
;;
* ) echo "Usage: $0 (start | stop | status)"
exit 1
esac