Starting databases automatically – Linux/Unix

The standard scripts that Oracle provides to start databases at boot time will not start the standby databases in the correct mode when the server is started or rebooted.It is therefore recommended to edit the Oracle supplied scripts (if used) and to comment out the starting of the databases, and to use Dbvisit Standby to start the databases at boot time. Dbvisit Standby will start the standby databases and primary databases in the correct mode.The Oracle supplied scripts will still be used to start Listener, agent or networking processes. Dbvisit Standby does NOT start and stop listener, agent or networking services and processes. Dbvserver Scheduler can also be used to start the databases automatically. Please see Dbvserver Scheduler Autostart for more information. The Dbvserver process will need to be started at boot time with init.d scripts for this to be automated.

Setting up init.d scripts to start and stop the database automatically:

1. Go to the location of the init scripts. This may be different depending on the flavour of Linux or Unix. In this example it is /etc/init.d.

2. Create a new script (this may need to be done as the root user) on boththe primary and standby server.

 

[/etc/init.d]# vi OraStartStop

3. Add the following to lines to the script.

 

#!/bin/sh
#
# description: w120n database is started and stopped using dbvisit
#
prog=dbv_oraStartStop
start () {
        echo -n $"Starting $prog: "
        su - oracle -c "/usr/local/dbvisit/standby/$prog start w120n"
}
stop () {
        echo -n $"Stopping $prog: "
        su - oracle -c "/usr/local/dbvisit/standby/$prog stop w120n"
}
restart () {
        echo -n $"Restarting $prog: "
        su - oracle -c "/usr/local/dbvisit/standby/$prog restart w120n"
}
status () {
        echo -n $"Status $prog: "
        su - oracle -c "/usr/local/dbvisit/standby/$prog status w120n"
}
case $1 in
        start)
                start
        ;;
        stop)
                stop
        ;;
        restart)
                restart
        ;;
        status)
                status
        ;;
        *)
                echo $"Usage: $prog {start|stop|restart|status}"
        exit 3
esac
Where w120n is the name of the database and oracle is the owner of the Oracle software.

4. Set the correct permissions on the script.

 

chmod 750 OraStartStop

5. Create a link to the correct starting directory to stop and start the databases. This is usually /etc/rc3.d.The link must start with a capital S for starting and K for stopping. The number after the S and K determines the order of the start-up or stop command. On Linux the chkconfigcommand may be used for this.

 

 cd /etc/rc3.d 
[/etc/rc3.d]# ln -s ../init.d/OraStartStop S30OraStartStop
[/etc/rc3.d]# ln -s ../init.d/OraStartStop K30OraStartStop

6. When the server is rebooted, Dbvisit Standby will start the database in the correct mode. If the database has been activated from a standby database to a primary database (or vice versa), Dbvisit Standby will continue to start the database in the correct mode.

7. To add more databases to the start-up or shutdown script, add another line to in the correct place. Example:

 

su - oracle -c "/usr/local/dbvisit/standby/dbv_oraStartStop start w120n" 
su - oracle -c "/usr/local/dbvisit/standby/dbv_oraStartStop start w902"
Where w120n and w920 are the names of databases on the same server.