Solved

DB start-up/shutdown script

Posted on 2004-09-10
4
2,840 Views
Last Modified: 2010-07-27
Hello,

I wrote 2 scrits to automatically start-up and/or shutdown a DB at boot-up time.
However , when rebooting the server, the scripts don,t work.

Any ideas ?

PT
0
Comment
Question by:ptreves
4 Comments
 
LVL 23

Expert Comment

by:seazodiac
ID: 12026244
Tell use the procedures how you did it.?


did it work when you manually invoke the scripts? did it shutdown and restart ?

if the above checkpoint is done,
did you put into /etc/init.d folder and create a SXX and KXX link in the default run level of your system?
0
 
LVL 35

Expert Comment

by:Mark Geerlings
ID: 12026270
Can you tell us which version of Oracle you have and which O/S you have?
0
 
LVL 48

Accepted Solution

by:
schwertner earned 125 total points
ID: 12027139
Complex task!

1. Update 'oratab' (under /etc or /var/opt/oracle) as:
 
   <SID>:<ORACLE_HOME>:Y
 
where Y states that the database can be started up and shutdown using  
dbstart/dbshut.
 
2. Create the service script:
 
     /etc/init.d/dbora
 
Note: In Red Hat Advanced Server 2.1, the /etc/init.d is is a symbolic link to  
      /etc/rc.d/init.d  
 
Content of the script is as follows:
 
  #!/bin/bash
  #
  # chkconfig: 35 99 10    
  # description: Starts and stops Oracle processes
  #
  # Set ORA_HOME to be equivalent to the $ORACLE_HOME
  # from which you wish to execute dbstart and dbshut;
  #
  # Set ORA_OWNER to the user id of the owner of the
  # Oracle database in ORA_HOME.
  #
  ORA_HOME=<Type your ORACLE_HOME in full path here>
  ORA_OWNER=<Type your Oracle account name here>
 
  case "$1" in
    'start')
       # Start the Oracle databases:
       # The following command assumes that the oracle login
       # will not prompt the user for any values
       su - $ORA_OWNER -c $ORA_HOME/bin/dbstart
       # Start the TNS Listener
       su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"
       # Start the Intelligent Agent
       if [ -f $ORA_HOME/bin/agentctl ]; then
          su - $ORA_OWNER -c "$ORA_HOME/bin/agentctl start"
       else
          su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl dbsnmp_start"
       fi
       # Start Management Server
       if [ -f $ORA_HOME/bin/oemctl ]; then
          su - $ORA_OWNER -c "$ORA_HOME/bin/oemctl start oms"
       fi
       # Start HTTP Server
       if [ -f $ORA_HOME/Apache/Apache/bin/apachectl ]; then
          su - $ORA_OWNER -c "$ORA_HOME/Apache/Apache/bin/apachectl start"
       fi
       touch /var/lock/subsys/dbora
       ;;
    'stop')
       # Stop HTTP Server
       if [ -f $ORA_HOME/Apache/Apache/bin/apachectl ]; then
          su - $ORA_OWNER -c "$ORA_HOME/Apache/Apache/bin/apachectl stop"
       fi
       # Stop Management Server
       if [ -f $ORA_HOME/bin/oemctl ]; then
          su - $ORA_OWNER -c "$ORA_HOME/bin/oemctl stop oms sysman/<password>"
       fi
       # Stop the Intelligent Agent
       if [ -f $ORA_HOME/bin/agentctl ]; then
          su - $ORA_OWNER -c "$ORA_HOME/bin/agentctl stop"
       else
          su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl dbsnmp_stop"
       fi
       # Stop the TNS Listener
       su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"
       # Stop the Oracle databases:
       # The following command assumes that the oracle login
       # will not prompt the user for any values
       su - $ORA_OWNER -c $ORA_HOME/bin/dbshut
       rm -f /var/lock/subsys/dbora
       ;;
  esac
  # End of script dbora
 
NOTE 1:
The lines:
 
  # chkconfig: 35 99 10    
  # description: Starts and stops Oracle database
 
are mandatory since they describe the characteristics of the service where:
 
  35 means that the service will be started in init levels 3 and 5 and will be stopped in other levels.
  99 means that the service will be started at the near end of the init level processing
  10 means that the service will be stopped at the near end of the init level processing
 
NOTE 2:  
The Management Server is not shut down during service stop since it requires interaction and there is no harm in system killing the processes since the database is shut down already.
 
 
3. Set script permissions:
 
    chmod 755 /etc/init.d/dbora
 
 
3. Register the Service
 
    /sbin/chkconfig --add dbora
 
This action registers the service to the Linux service mechanism. On SuSE SLES7 and Red Hat Advanced Server 2.1 it will arrange symbolic links under  
rc<runlevel>.d directories to /etc/init.d/dbora script.
 
NOTE 3:
The chkconfig utility calls 'insserv' to register and add services. The 'insserv'
version shipped with SUSE SLES8 is using the following header to define run level  
and start/shutdown order.
 
    ### BEGIN INIT INFO
    # Provides:       dbora      
    # Required-Start: $local_fs $remote_fs $netdaemons
    # Required-Stop:
    # Default-Start:  3 5
    # Default-Stop:   0 1 2 3 4 5 6
    # Description:    Oracle Startup
    ### END INIT INFO
 
On SuSE SLES7 the following symbolic links are created:
 
/etc/init.d/rc0.d/K10dbora
/etc/init.d/rc1.d/K10dbora
/etc/init.d/rc2.d/K10dbora
/etc/init.d/rc3.d/S99dbora
/etc/init.d/rc4.d/K10dbora
/etc/init.d/rc5.d/S99dbora
/etc/init.d/rc6.d/K10dbora
 
 
On Red Hat Advanced Server 2.1 the following symbolic links are created:
 
/etc/rc.d/rc0.d/K10dbora
/etc/rc.d/rc1.d/K10dbora
/etc/rc.d/rc2.d/K10dbora
/etc/rc.d/rc3.d/S99dbora
/etc/rc.d/rc4.d/K10dbora
/etc/rc.d/rc5.d/S99dbora
/etc/rc.d/rc6.d/K10dbora
 
 
The symbolic links are not created in United Linux 1.0 (SuSE SLES8 Edition)  
with the 'chkconfig -add' command.  
To have the symbolic links created run the following in addition:
 
   /sbin/chkconfig --set dbora 35
 
After this action, the following symbolic links will be created pointing  
to /etc/init.d/dbora script:
 
/etc/init.d/rc3.d/S01dbora
/etc/init.d/rc3.d/K22dbora
/etc/init.d/rc5.d/S01dbora
/etc/init.d/rc5.d/K22dbora
 
 
In all cases, the 'dbora' service will be running in runlevels 3,5 and it will  
be stopped in other runlevels (i.e. 0,1,2,4,6).
0
 

Author Comment

by:ptreves
ID: 12027883
Hello,

I have an Oracle 9i DB running on a Red Hat Linux Enterprise 3 (ES) server.
For the moment I just have the started DB, and trying to import an existing dump file.

Here is the script that I have:
-----
[root@Linux2005 init.d]# more dbora
#!/bin/sh
# chkconfig: - 20 80
# description: Oracle auto start-stop script
#
# Set ORA_HOME to be equivalent to the $ORACLE_HOME
# form which you wish to execute dbstart and dbshut;
#
# Set ORA_OWNER to the user id to the owner of the
# Oracle database in ORA_HOME.
ORA_HOME=/u01/app/oracle/product/9.2.0.1.0
ORA_OWNER=oracle
if [! -f $ORA_HOME/bin/dbstart]
then
  echo "Oracle startup: cannot start"
  exit
fi
case "$1" in
  'start'
     # Start the Oracle databases:
     # The following command assumes that the oracle lo
     # will not prompt the user for any values
  su - $ORACLE_OWNER -c $ORA_HOME/bin/dbstart &
  ;;
  'stop')
    # Stop the Oracle databases:
    # The following command assumes that the oracle lo
    # will not prompt the user for any values
  su - $ORA_OWNER -c $ORA_HOME/bin/dbshut &
  ;;
esac
-----

Hope this helps ........

PT
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question