Solved

Automatic startup of a dataguard database on Redhat Linux

Posted on 2006-10-26
13
1,483 Views
Last Modified: 2013-12-11
I inherited support of an Oracle 9i dataguard backup system on Redhat Linux AS2 . However the standby database does not start up automatically on reboot. If the standby DB is down longer than the oldedst date of my saved arachives, I'm in big trouble. Can someone tell me how to setup the standby database to startup automatically? Setting oratab to Y does not work. Apparently I need to use the rc scripts to do this, but I don't know very much about them. I have found the file S99oracle ../init.d/oracle /etc/rc.d/rc3.d.  I looked at it, and it's pretty detailed. If this is the correct file to modify could you point me in the right direction of what I need to do. I also read about a file called rc.local. Is this the file I need to start dataguard. Thank you very much in advance.
0
Comment
Question by:rmthoma
  • 6
  • 5
  • 2
13 Comments
 
LVL 13

Expert Comment

by:anand_2000v
Comment Utility
you can create a script like,

     startup nomount pfile=pfile path
     Alter database mount standby database


make this script to be called whenever the machine starts,so you will never have the problem even if the machine reboots.
   
 
0
 
LVL 13

Expert Comment

by:anand_2000v
Comment Utility
make the above scripts and make it call in rc2.d,rc3.d,rc4.d
0
 
LVL 47

Expert Comment

by:schwertner
Comment Utility
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 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.
 
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:rmthoma
Comment Utility
The comments above are great--thanks.  But there are 2 other instances on the server that are being started by dbstart, so I don't feel safe touching that file.  What I'm looking for is something simple. I would like to run something like the following shell file on startup at the end of the startup process:

. /etc/profile.d/oracle.sh
. /etc/profile.d/bocs.sh
ORACLE_SID=bocscs
export ORACLE_SID
/oracle/bin/sqlplus /nolog
conn / as sysdba
startup nomount pfile=$ORACLE_HOME/dbs/initbocscs.ora;
alter database mount standby database;
alter database recover managed standby database disconnect;
exit

Could you tweak this for me and tell from where I should call it? thanks again!
0
 
LVL 47

Expert Comment

by:schwertner
Comment Utility
In Oracle 9i you need to make minor changes in DBSTART file.
But first try it. Because in latest patches (after 9.2.0.4) Oracle has fixed that issues.

Before touching DBSTART make a spare copy of the original file.
You can add IF statement in the shell script to bounce the instances in different ways


IF $local_SID = dataguard_SID
THEN
     startup nomount pfile=$ORACLE_HOME/dbs/initbocscs.ora;
    alter database mount standby database;
    alter database recover managed standby database disconnect;
ELSE
   startup
ENDIF
0
 

Author Comment

by:rmthoma
Comment Utility
I changed dbstart from the following code:

                            ;;
                        *)  $SQLDBA <<EOF
connect / as sysdba
startup
EOF
                            ;;
                    esac

                    if test $? -eq 0 ; then

To the code below, based on my best guess at how to use your advice above. However I missed something because now none of the DBs startup when the server is rebooted. Any suggestions? (Thanks again)

                            ;;
                        *)
if [ "$ORACLE_SID" = 'bocscs' ] ; then
        $SQLDBA <<EOF
        connect / as sysdba
        startup nomount pfile=$ORACLE_HOME/dbs/initbocscs.ora;
        alter database mount standby database;
        alter database recover managed standby database disconnect;
        EOF
else
        $SQLDBA <<EOF
        connect / as sysdba
        startup
        EOF
fi
                            ;;
                    esac

                    if test $? -eq 0 ; then
0
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.

 
LVL 47

Expert Comment

by:schwertner
Comment Utility
I think it will do the job.
backup the old file.
0
 

Author Comment

by:rmthoma
Comment Utility
Unfortunately I already tried it and now none of the databases start automatically, although they are set to Y in oratab.  So something must be wrong with the code above that makes it crash. Do you see any mistakes? Do you have any ideas how to catch the crash? thanks
0
 
LVL 47

Expert Comment

by:schwertner
Comment Utility
Please see if you have set these

/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

What is the message you got?

I have set in dbora some messages like:

echo "ORACLE STARTS     ..........specify what instance"
SU - $ORA_OWNER -c $ORA_HOME/bin/dbstart
WAIT

To watch what happens!
0
 

Author Comment

by:rmthoma
Comment Utility
Sorry--I never wrote a dbora file (and one does not exist).  The script above is from dbstart.  Are you saying that I should use dbora to debug dbstart when it starts up?  My problem is that Unix Services supports the server, and I need to have them re-boot it.  I would not see any message that is echoed on the screen.  Is there a way to debug dbstart without re-booting the server? thanks a ton!
0
 
LVL 47

Expert Comment

by:schwertner
Comment Utility
dbora.sh is the script that invokes dbstart and dbshut script (automatically!!!
by start and halt of Linux OS!!!!).

Please read carefully the instruction I have posted!!!!
It looks like:

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 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
 
0
 

Author Comment

by:rmthoma
Comment Utility
I found the file on the server that is working like dbora.  It's in /etc/rc.d/rc3.d and it's called S99oracle -> ../init.d/oracle. It is very similar to the dbora file you have above, and it calls dbstart.  It appears to be working just fine.  The problem seems to be that my script inside of dbstart is crashing.  You suggest putting the following code in dbora.sh to debug the problem.  

echo "ORACLE STARTS     ..........specify what instance"
SU - $ORA_OWNER -c $ORA_HOME/bin/dbstart
WAIT

Where should I put it?  How does the echo command above work on re-boot?  Or, in other words, how can I send the results of the echo command to a log file to read since I will not be physically at the server when it is re-booted? (I very much appreciate your time!!)
0
 
LVL 47

Accepted Solution

by:
schwertner earned 500 total points
Comment Utility
ECHO shows messages on the screen by reboot.
So you can check the progress of the script and to
figure out (putting ECHO in the key points of the script)
where your script crashes.
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.

Join & Write a Comment

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

771 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now