Oracle® Database Administrator's Reference
10g Release 1 (10.1) for UNIX Systems: AIX-Based Systems, Apple Mac OS X, hp HP-UX, hp Tru64 UNIX, Linux, and Solaris Operating System Part No. B10812-06 |
|
![]() Previous |
![]() Next |
This chapter describes how to identify Oracle Database processes running on UNIX systems, and provides basic information about how to stop and restart them. For more information about administering the products, see the appropriate product-specific documentation. This chapter contains information about the following:
This section describes how to stop and start the processes for the following Oracle products:
Note: Make sure that you follow the instructions in this section every time you start an Oracle database or ASM instance or an Oracle Net listener process. |
To ensure that certain shell limits are set to the values required to run Oracle processes, you must use the ssh
, rlogin
, or telnet
command to connect to the system where you want to start the process, even if that system is the local system. For example:
$ ssh localhost
This section describes how to stop and start database or Automatic Storage Management (ASM) instances.
Stopping Database or ASM Instances
To stop an Oracle database or ASM instance, follow these steps:
If necessary, to identify the SID and Oracle home directory for the instance that you want to shut down, enter the following command:
Solaris:
$ cat /var/opt/oracle/oratab
Other operating systems:
$ cat /etc/oratab
The oratab
file contains lines similar to the following, which identify the SID and corresponding Oracle home directory for each database or ASM instance on the system:
sid:oracle_home_directory:[Y|N]
Note: Oracle recommends that you use the plus sign (+) as the first character in the SID of ASM instances. |
Caution: Do not stop an ASM instance until you have stopped all Oracle database instances that use that ASM instance to manage their storage. |
Depending on your default shell, run the oraenv
or coraenv
script to set the environment variables for the instance that you want to shut down:
Bourne, Bash, or Korn shell:
$ . /usr/local/bin/oraenv
C shell:
% source /usr/local/bin/coraenv
When prompted, specify the SID for the instance.
Enter the following commands to shut down the instance:
$ sqlplus /nolog
SQL> CONNECT SYS/sys_password as SYSDBA
SQL> SHUTDOWN NORMAL
After the instance shuts down, you can exit from SQL*Plus.
Restarting Database or ASM Instances
To restart an Oracle database or Automatic Storage Management instance, follow these steps:
If necessary, repeat steps 1 and 2 in the previous subsection to set the ORACLE_SID and ORACLE_HOME environment variables to identify the SID and Oracle home directory for the instance that you want to start.
Caution: If the database instance uses ASM for storage management, you must start the ASM instance before you start the database instance. |
Enter the following commands to start the instance:
$ sqlplus /nolog
SQL> CONNECT SYS/sys_password as SYSDBA
SQL> STARTUP
After the instance starts, you can exit from SQL*Plus.
This section describes how to stop and start Oracle Net listener.
To stop an Oracle Net listener, follow these steps:
Enter the following command to determine the listener name and Oracle home directory for the Oracle Net listener that you want to stop:
Mac OS X:
$ ps -auxwww | grep tnslsnr
Other operating systems:
$ ps -ef | grep tnslsnr
This command displays a list of the Oracle Net listeners running on the system, similar to the following, where listenername1
and listenername2
are the names of the listeners:
94248 ?? I 0:00.18 oracle_home1/bin/tnslsnr listenername1 -inherit 94248 ?? I 0:00.18 oracle_home2/bin/tnslsnr listenername2 -inherit
Set the ORACLE_HOME environment variable to specify the appropriate Oracle home directory for the listener that you want to stop:
Bourne, Bash, or Korn shell:
$ ORACLE_HOME=oracle_home1
$ export ORACLE_HOME
C shell:
% setenv ORACLE_HOME oracle_home1
Enter the following command to stop the Oracle Net listener:
$ $ORACLE_HOME/bin/lsnrctl stop listenername
Note: If the name of the listener is the default name LISTENER, you do not have to specify the name in this command. |
Restarting Oracle Net Listener
To start an Oracle Net listener, follow these steps:
If necessary, set the ORACLE_HOME environment variable to specify the appropriate Oracle home directory for the listener that you want to start:
Bourne, Bash, or Korn shell:
$ ORACLE_HOME=oracle_home1
$ export ORACLE_HOME
C shell:
% setenv ORACLE_HOME oracle_home1
Enter the following command to restart the Oracle Net listener:
$ $ORACLE_HOME/bin/lsnrctl start [listenername]
You must specify the listener name only if it is different from the default listener name LISTENER. To determine the listener name, enter the following command to view the listener.ora
file:
$ more $ORACLE_HOME/network/admin/listener.ora
This section describes how to stop and start iSQL*Plus.
To stop iSQL*Plus, follow these steps:
Set the ORACLE_HOME environment variable to specify the appropriate Oracle home directory for iSQL*Plus:
Bourne, Bash, or Korn shell:
$ ORACLE_HOME=oracle_home
$ export ORACLE_HOME
C shell:
% setenv ORACLE_HOME oracle_home
Enter the following command to stop iSQL*Plus:
$ $ORACLE_HOME/bin/isqlplusctl stop
To start iSQL*Plus, follow these steps:
If necessary, set the ORACLE_HOME environment variable to specify the appropriate Oracle home directory for the iSQL*Plus instance that you want to start:
Bourne, Bash, or Korn shell:
$ ORACLE_HOME=oracle_home
$ export ORACLE_HOME
C shell:
% setenv ORACLE_HOME oracle_home
Enter the following command to start iSQL*Plus:
$ $ORACLE_HOME/bin/isqlplusctl start
This section describes how to stop and start Oracle Ultra Search.
To stop Oracle Ultra Search, follow these steps:
If necessary, set the ORACLE_HOME environment variable to specify the appropriate Oracle home directory for Oracle Ultra Search:
Bourne, Bash, or Korn shell:
$ ORACLE_HOME=oracle_home
$ export ORACLE_HOME
C shell:
% setenv ORACLE_HOME oracle_home
Enter the following command to stop Oracle Ultra Search:
$ $ORACLE_HOME/bin/searchctl stop
To start Oracle Ultra Search, follow these steps:
If necessary, set the ORACLE_HOME environment variable to specify the appropriate Oracle home directory for Oracle Ultra Search:
Bourne, Bash, or Korn shell:
$ ORACLE_HOME=oracle_home
$ export ORACLE_HOME
C shell:
% setenv ORACLE_HOME oracle_home
Enter the following command to start Oracle Ultra Search:
$ $ORACLE_HOME/bin/searchctl start
This section describes how to stop and start Oracle Enterprise Manager Database Control (Database Control).
To stop Database Control, follow these steps:
Depending on your default shell, run the oraenv
or coraenv
script to set the environment for the database managed by the Database Control that you want to stop:
coraenv
script:
% source /usr/local/bin/coraenv
oraenv
script:
$ . /usr/local/bin/oraenv
Enter the following command to stop the Database Control:
$ $ORACLE_HOME/bin/emctl stop dbconsole
To start Database Control, follow these steps:
If necessary, set the ORACLE_SID and ORACLE_HOME environment variables to identify the SID and Oracle home directory for the database control that you want to start:
Bourne, Bash, or Korn shell:
$ ORACLE_HOME=oracle_home $ ORACLE_SID=sid $ export ORACLE_HOME ORACLE_SID
C shell:
% setenv ORACLE_HOME oracle_home % setenv ORACLE_SID sid
Enter the following command to start the Database Control:
$ $ORACLE_HOME/bin/emctl start dbconsole
If you are using Oracle Enterprise Manager Grid Control to manage multiple Oracle products from a central location, you must have an Oracle Management Agent installed on each host system. Typically, the Oracle Management Agent is installed in its own Oracle home directory.
This section describes how to stop and start Oracle Management Agent.
Stopping Oracle Management Agent
To stop Oracle Management Agent, follow these steps:
If necessary, enter the following command to determine the Oracle home directory for Oracle Management Agent:
Mac OS X:
$ ps -auxwww | grep emagent
Other operating systems:
$ ps -ef | grep emagent
This command displays information about the Oracle Management Agent processes, similar to the following:
94248 ?? I 0:00.18 oracle_home/agent/bin/emagent ...
Set the ORACLE_HOME environment variable to specify the appropriate Oracle home directory for the Oracle Management Agent:
Bourne, Bash, or Korn shell:
$ ORACLE_HOME=oracle_home
$ export ORACLE_HOME
C shell:
% setenv ORACLE_HOME oracle_home
Enter the following command to stop Oracle Management Agent:
$ $ORACLE_HOME/agent/bin/emctl stop agent
Starting Oracle Management Agent
To start Oracle Management Agent, follow these steps:
If necessary, set the ORACLE_HOME environment variable to specify the appropriate Oracle home directory for Oracle Management Agent:
Bourne, Bash, or Korn shell:
$ ORACLE_HOME=oracle_home
$ export ORACLE_HOME
C shell:
% setenv ORACLE_HOME oracle_home
Enter the following command to start Oracle Management Agent:
$ $ORACLE_HOME/agent/bin/emctl start agent
Note: The procedure described in this section applies to single-instance databases only. |
Oracle recommends that you configure your system to automatically start Oracle databases when the system starts up, and to automatically shut them down when the system shuts down. Automating database startup and shutdown guards against incorrect database shutdown.
To automate database startup and shutdown, use the dbstart
and dbshut
scripts, located in the $ORACLE_HOME/bin
directory. The scripts refer to the same entries in the oratab
file, and so must apply to the same set of databases. You cannot, for example, have the dbstart
script automatically start sid1
, sid2
, and sid3
, and have the dbshut
script shut down only sid1
. However, you can specify that the dbshut
script shuts down a set of databases while the dbstart
script is not used at all. To do this, include a dbshut
entry in the system shutdown file, but omit the dbstart
entry from the system startup files.
The following section describes how to automate startup and shutdown of Oracle Database:
To automate database startup and shutdown using the dbstart
and dbshut
scripts on Mac OS X, follow these steps:
Log in as the root
user.
Open the oratab
file in any text editor:
# vi /etc/oratab
Database entries in the oratab
file appear in the following format:
SID:ORACLE_HOME:{Y|N}
In this example, Y or N specifies whether you want the scripts to start up or shut down the database. For each database that you want to start up and shut down, find the instance identifier (SID) for that database, identified by the SID
in the first field, and change the last field for each to Y.
Note: If you add new database instances to the system, remember to edit the entries for those instances in theoratab file if you want them to start automatically.
|
Create the /Library/StartupItems/Oracle
directory and change directory to it:
# mkdir /Library/StartupItems/Oracle # cd /Library/StartupItems/Oracle
Using any text editor, create a startup script called Oracle
in this directory, similar to the following:
#!/bin/bash # source the common startup script . /etc/rc.common # Change the value of ORACLE_HOME to specify the correct Oracle home # directory for you installation ORACLE_HOME=/Volumes/u01/app/oracle/product/10.1.0/db_1 # # change the value of ORACLE to the login name of the # oracle owner at your site ORACLE=oracle PATH=${PATH}:$ORACLE_HOME/bin export ORACLE_HOME PATH # Set shell limits for Oracle Database ulimit -c unlimited ulimit -d unlimited ulimit -s 65536 StartService() { if [ -f $ORACLE_HOME/bin/tnslsnr ] ; then ConsoleMessage "Starting Oracle Net" su $ORACLE -c "$ORACLE_HOME/bin/lsnrctl start" fi ConsoleMessage "Starting Oracle Databases" su $ORACLE -c "$ORACLE_HOME/bin/dbstart" } StopService() { ConsoleMessage "Stopping Oracle Databases" su $ORACLE -c "$ORACLE_HOME/bin/dbshut" if [ -f $ORACLE_HOME/bin/tnslsnr ] ; then ConsoleMessage "Stopping Oracle Net" su $ORACLE -c "$ORACLE_HOME/bin/lsnrctl stop" fi } RestartService() { StopService StartService } RunService "$1"
Note: This script works only if a password has not been set for the Oracle Net listener. If a password has been set for the listener, this script cannot stop the listener. Also, if the listener name is not the default name LISTENER, you must specify the listener name in the stop and start commands:$ORACLE_HOME/bin/lsnrctl {start|stop} listener_name
|
Using any text editor, create a startup item parameter list file called StartupParameters.plist
in this directory, similar to the following:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Description</key> <string>Oracle Database Startup</string> <key>Provides</key> <array> <string>Oracle Database</string> </array> <key>Requires</key> <array> <string>Disks</string> </array> <key>Uses</key> <array> <string>Disks</string> <string>Network</string> </array> <key>OrderPreference</key> <string>Late</string> </dict> </plist>
Change the owner, group, and permissions of the files that you created, as follows:
# chown root:wheel * # chmod 700 *
See Also: For more information about system startup and shutdown procedures, see theinit command in your UNIX system documentation.
|
To automate database startup and shutdown using the dbstart
and dbshut
scripts on AIX, HP-UX, Linux, Solaris, or Tru64 UNIX, follow these steps:
Log in as the root
user.
Open the oratab
file in any text editor:
Solaris:
# vi /var/opt/oracle/oratab
Other operating systems:
# vi /etc/oratab
Database entries in the oratab
file appear in the following format:
SID:ORACLE_HOME:{Y|N}
In this example, Y or N specifies whether you want the scripts to start up or shut down the database. For each database that you want to start up and shut down, find the instance identifier (SID) for that database, identified by the SID
in the first field, and change the last field for each to Y.
Note: If you add new database instances to the system, remember to edit the entries for those instances in theoratab file if you want them to start automatically.
|
Change directory to one of the following directories, depending on your platform:
Platform | Initialization File Directory |
---|---|
AIX | /etc
|
Linux and Solaris | /etc/init.d
|
HP-UX and Tru64 UNIX | /sbin/init.d
|
Create a file called dbora
with the following contents. Change the value specified for the ORACLE_HOME environment variable to an Oracle home directory for your installation, and change the value of the ORACLE environment variable to the user name of the owner of the database installed in the Oracle home directory (typically oracle
):
#! /bin/sh -x # # Change the value of ORACLE_HOME to specify the correct Oracle home # directory for you installation ORACLE_HOME=/u01/app/oracle/product/10.1.0/db_1 # # change the value of ORACLE to the login name of the # oracle owner at your site # ORACLE=oracle PATH=${PATH}:$ORACLE_HOME/bin HOST=`hostname` PLATFORM=`uname` export ORACLE_HOME PATH # if [ ! "$2" = "ORA_DB" ] ; then if [ "$PLATFORM" = "HP-UX" ] ; then remsh $HOST -l $ORACLE -n "$0 $1 ORA_DB" exit else rsh $HOST -l $ORACLE $0 $1 ORA_DB exit fi fi # LOG=$ORACLE_HOME/startup.log touch $LOG chmod a+r $LOG # case $1 in 'start') echo "$0: starting up" >> $LOG date >> $LOG # Start Oracle Net if [ -f $ORACLE_HOME/bin/tnslsnr ] ; then echo "starting Oracle Net Listener" $ORACLE_HOME/bin/lsnrctl start >> $LOG 2>&1 & fi echo "Starting Oracle databases" $ORACLE_HOME/bin/dbstart >> $LOG 2>&1 & ;; 'stop') echo "$0: shutting down" >> $LOG date >> $LOG # Stop Oracle Net if [ -f $ORACLE_HOME/bin/tnslsnr ] ; then echo "stopping Oracle Net Listener" $ORACLE_HOME/bin/lsnrctl stop >> $LOG 2>&1 & fi echo "stopping Oracle databases" $ORACLE_HOME/bin/dbshut >> $LOG 2>&1 & ;; *) echo "usage: $0 {start|stop}" exit ;; esac # exit
Note: This script works only if a password has not been set for the Oracle Net listener. If a password has been set for the listener, this script cannot stop the listener. Also, if the listener name is not the default name LISTENER, you must specify the listener name in the stop and start commands:$ORACLE_HOME/bin/lsnrctl {start|stop} listener_name
|
Change the group of the dbora
file to the OSDBA group (typically dba
) and set the permissions to 750:
# chgrp dba dbora # chmod 750 dbora
Create symbolic links to the dbora
script in the appropriate run-level script directories, as follows:
Platform | Symbolic Links Commands |
---|---|
AIX |
# ln -s /etc/dbora /etc/rc.d/rc2.d/S99dbora # ln -s /etc/dbora /etc/rc.d/rc2.d/K01dbora |
HP-UX |
# ln -s /sbin/init.d/dbora /sbin/rc3.d/S990dbora # ln -s /sbin/init.d/dbora /sbin/rc3.d/K001dbora |
Linux |
# ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/K01dbora # ln -s /etc/init.d/dbora /etc/rc.d/rc3.d/S99dbora # ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/K01dbora # ln -s /etc/init.d/dbora /etc/rc.d/rc5.d/S99dbora |
Solaris |
# ln -s /etc/init.d/dbora /etc/rc3.d/K01dbora # ln -s /etc/init.d/dbora /etc/rc3.d/S99dbora |
Tru64 UNIX |
# ln -s /sbin/init.d/dbora /sbin/rc3.d/S99dbora # ln -s /sbin/init.d/dbora /sbin/rc3.d/K01dbora |