Skip to main content

AUTOMATING STARTING AND STOPPING THE DATABASE AND LISTENER ON LINUX




It is sometime desirable by most DBAs to have the oracle database and listener automatically shutdown and startup when the server reboots. The following steps shows you how to automate your database and listener shutdown and startup.

Please note that this demonstration is linux centric (I am working on OEL 6.8), so if you are working with a different Unix platform, refer to the Oracle Database Admin’s Guide.

1. Edit the /etc/oratab file, and place a Y at the end of the entry for the database you want to restart automatically when the system reboots. You will need root priv to edit the file:

2. Paste within the file a line similar to the one below, for your environment:

db11g:/u01/app/oracle/product/11.2.0/dbhome_1:Y
Note:
The entries are of the form:
#   $ORACLE_SID:$ORACLE_HOME:N|Y:

3. As root, navigate to the /etc/init.d directory, and create a file named dbora:



Paste the following lines in the dbora file. Make sure you change the values of the variables OR_HOME and OR_OWNER to match your environment.

#!/bin/bash
# chkconfig: 35 99 10
# description: Starts and stops Oracle processes
OR_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
OR_OWNER=oracle
case "$1" in
'start')
su - $OR_OWNER -c "$OR_HOME/bin/lsnrctl start"
su - $OR_OWNER -c $OR_HOME/bin/dbstart
;;
'stop')
su - $OR_OWNER -c "$OR_HOME/bin/lsnrctl stop"
su - $OR_OWNER -c $OR_HOME/bin/dbshut
;;
esac

4. Change the group of the dbora file to match the group assigned to the OS owner of the Oracle software (usually oinstall or dba), change the permissions on the dbora file to 750:


5. Run the following chkconfig command:

# /sbin/chkconfig --add dbora

Use the --list option to display whether a service is on or off for each runlevel:


To test wether the dbora script is working, as root, run the following command to stop you database and listener:

# /etc/init.d/dbora stop

To test the startup of your database and listener, as root, issue the following command:

# /etc/init.d/dbora start

Note!!  You may need to make a slight modification to the Oracle-supplied ORACLE_HOME/bin/dbstart and ORACLE_HOME/bin/dbshut scripts. I ran the script without the modifacation and had the message below, so if u see the same message pls make this modifications in the script:


Inspect these scripts with an OS editor (such as vi), you’ll notice the following line:

ORACLE_HOME_LISTNER=$1

I would recommend that you change it to this:

ORACLE_HOME_LISTNER=${1:-$ORACLE_HOME}

This line instructs the scripts to accept a parameter if one is passed in. If a parameter is not passed in, then set ORACLE_HOME_LISTNER to the value contained in the variable $ORACLE_HOME. This preserves the functionality of dbstart and dbshut and also makes these scripts work when called from dbora

If you can reboot your system, then I recommend that you do so to ensure that the database stops and restarts correctly. The dbstart and dbshut utilities create log files in the ORACLE_HOME directory, named startup.log and shutdown.log. You can inspect the contents of these to verify that the shutdown and startup are working as expected.




Comments

Popular posts from this blog

Oracle Database 19c Step by Step Installation On Oracle Linux 7.6

This post describes the installation of Oracle Database 19c 64-bit on Oracle Linux 7.6  x86-64 bit. The Linux server needs a minimum of 3G swap and secure Linux set to permissive. An example of this type of Linux installation can be seen here . Download Software Download the Oracle software from oracle edelivery . Oracle Installation Prerequisites Automatic Setup Use the "oracle-database-preinstall-19c" package to perform all your prerequisite setup. # yum install -y oracle-database-preinstall-19c If you are using RHEL7 or CentOS7, you can pick up the PRM from the OL7 repository and install it. It will pull the dependencies from your normal repositories. # yum install -y https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm Hosts File Set a fully qualified name for the server in the "/etc/hosts" file. < IP-address > < fully-qualified-machine-name > < machin...

How to Delete Old Trace & Dump files with ADRCI

The ADRCI command interpreter has multiple features:- Create a package with incident or problem information for Oracle Support Analyze diagnostic data within the Automatic Diagnostic Repository (ADR) Run health checks In this post, we'll be concentrating on deleting the old diagnostic files with ADRCI. Set your environment and run the ADRCI utility: $ adrci Use the following command to list the ADR homes: adrci> show home ADR Homes: diag/rdbms/db11g/DB11G diag/tnslsnr/sol10/listener Choose the ADR home from the list above: adrci> set home diag/rdbms/db11g/DB11G Check the current retention policy: adrci> show control Check the following columns in the output: LONGP_POLICY:- It is set to 365 days by default. It is responsible for Incidents and Health Monitor warnings. SHORTP_POLICY:- It is set to 30 days by default. It manages the trace and core dump files. Use the following commands to change the retention policy: Specify the time in hours: 10 Days = 240 ...

Oracle Database 12C Error Codes, Solutions and Suggestions from ORA-19700 to ORA-20000

Oracle 12C Error Codes, Solutions and Suggestions from ORA 19700 to ORA 20000 ORA-19700: device type exceeds maximum length of string Cause:  The device type indicated is invalid. Action:  Supply a correct device type and retry the allocation. ORA-19701: device name exceeds maximum length of  string Cause:  The device name indicated is invalid. Action:  Supply a correct device name and retry the allocation. ORA-19702: device parameter exceeds maximum length of  string ORA-19703: device command string exceeds maximum length of  string Cause:  The device command string exceeds maximum length. Action:  Correct the command and retry the operation. ORA-19704: file name exceeds maximum length of  string Cause:  The specified file name, which was a parameter to a copy, backup, or restore operation, exceeds the maximum file name length for this operating system. Action:  Retry the operation with a s...