= Oracle Start And Stop
**Summary**: How to start and stop Oracle. \\
**Date**: Around 2013 \\
**Refactor**: 8 March 2025: Checked links and formatting. \\
{{tag>oracle bash}}
= Oracle Database =
== Start The Oracle Database ==
As the oracle user issue these commands:
UNIX> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Wed Oct 20 10:07:24 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1.7180E+10 bytes
Fixed Size 2114208 bytes
Variable Size 2164264288 bytes
Database Buffers 1.4999E+10 bytes
Redo Buffers 14659584 bytes
Database mounted.
Database opened.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
== Stop The Oracle Database ==
UNIX> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Wed Oct 20 11:29:41 2010
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
= Oracle Listener =
== Start The Oracle Listener ==
As the oracle user issue these commands:
UNIX> lsnrctl start SID_LISTENER
LSNRCTL for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Production on 20-OCT-2010 11:11:23
Copyright (c) 1991, 2007, Oracle. All rights reserved.
Starting /opt/oracle/product/10.2/bin/tnslsnr: please wait...
TNSLSNR for IBM/AIX RISC System/6000: Version 10.2.0.4.0 - Production
System parameter file is /opt/oracle/product/10.2/network/admin/listener.ora
Log messages written to /opt/oracle/product/10.2/network/log/sid_listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbserver)(PORT=2824)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
== Request The Oracle Listener Status ==
UNIX> lsnrctl status SID_LISTENER
== Stop The Oracle Listener ==
lsnrctl stop SID_LISTENER
== Tnsnames.ora ==
This is where the LISTENER configuration is set:
UNIX>/opt/oracle/product/10.2/network/admin>cat tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/oracle/product/10.2/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
SID_LISTENER =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 2824))
)
(CONNECT_DATA =
(SERVICE_NAME = sid)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
= Oracle Enterprise Manager Console =
emctl start dbconsole
emctl status dbconsole
emctl stop dbconsole
= Oracle Start Script =
#!/bin/ksh
# Oracle environment
ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/product/10.2
CLASSPATH=${ORACLE_BASE}/product/jre:${ORACLE_BASE}/jlib:${ORACLE_BASE}/rdbms/jlib:#{ORACLE_BASE}/network/jlib
LD_LIBRARY_PATH=${ORACLE_HOME}/lib:${ORACLE_HOME}/ctx/lib
ORACLE_OWNER=
ORACLE_SID=
ORA_NLS33=${ORACLE_HOME}/ocommon/nls/admin/data
TNS_ADMIN=${ORACLE_HOME}/network/admin
ORACLE_PROCESSES="ora_pmon_${ORACLE_SID} ora_smon_${ORACLE_SID} ora_dbw0_${ORACLE_SID} ora_lgwr_${ORACLE_SID} ora_ckpt_${ORACLE_SID}"
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/opt/oracle/product/10.2/bin:.
export PATH CLASSPATH LD_LIBRARY_PATH ORACLE_BASE ORACLE_HOME ORACLE_OWNER ORACLE_SID ORA_NLS33 TNS_ADMIN
case "$1" in
start )
echo "Starting the Oracle Server"
su $ORACLE_OWNER -c "${ORACLE_HOME}/bin/dbstart"
echo "Starting Oracle listener"
su $ORACLE_OWNER -c "${ORACLE_HOME}/bin/lsnrctl start ${ORACLE_SID}_LISTENER"
echo "Starting Oracle Enterprise Manager Console in the background"
su $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl start dbconsole &"
;;
stop )
echo "Stopping Oracle Enterprise Manager Console"
su $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
echo "Stopping Oracle listener"
su $ORACLE_OWNER -c "${ORACLE_HOME}/bin/lsnrctl stop ${ORACLE_SID}_LISTENER"
echo "Stopping the Oracle Server"
su $ORACLE_OWNER -c "${ORACLE_HOME}/bin/dbshut"
;;
status )
for i in $ORACLE_PROCESSES; do
unset pid
pid=`ps -ef|grep $i|grep -v grep|awk '{ print $2 }'`
if [[ "$pid" = "" ]] then
echo "Oracle subprocess $i is stopped..."
exit 0
else
echo "Oracle subprocess $i is running using processed $pid"
fi
done
unset pid
pid=`ps -ef|grep "${ORACLE_HOME}/bin/tnslsnr" |grep -v grep|awk '{ print $2 }'`
if [[ "$pid" = "" ]] then
echo "Oracle listener is stopped..."
exit 0
else
echo "Oracle listener is running using processed $pid"
fi
exit 1
;;
info )
# Oracle instance information, version, etc...
;;
env )
$0 status
if [[ "$?" = "1" ]] then
for i in $ORACLE_PROCESSES; do
echo "********* $i *********"
pid=`ps -ef|grep $i|grep -v grep|awk '{ print $2 }'`
ps ewww $pid | tr ' ' '\012' | grep = | sort
echo
echo
done
else
echo "Oracle server not available, exiting.."
exit 1
fi
;;
* )
echo "Usage: $0 COMMAND"
echo "---------------------------"
echo "start - Starts the Oracle server and listener daemons"
echo "stop - Stops the listener and Oracle server daemons"
echo "status - Server stopped/started state"
echo "env - Shows environment variables set for Oracle Server"
echo
exit 1
esac