Home » Server Options » Data Guard » to start and stop a standby database on server startup (Oracle 9i R2, Linux)
to start and stop a standby database on server startup [message #336136] Fri, 25 July 2008 00:10 Go to next message
sajut
Messages: 69
Registered: January 2007
Member
Dear All

I have a test standby database setup, which I have to shutdown every evening and start again in the morning. I use the following method for this
to startup
   sqlplus '/as sysdba'
     startup nomount
     alter database mount standby database
     alter database recover managed standby database disconnect from session;


and to shutdown
    sqlplus '/as sysdba'
    alter database recover managed standby database cancel;
    shutdown;


Is there any way I can automate these two processes

Thanks in advance

Saju
Re: to start and stop a standby database on server startup [message #336149 is a reply to message #336136] Fri, 25 July 2008 00:48 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Write a script and put it in the crontab?

Regards
Michel
Re: to start and stop a standby database on server startup [message #336183 is a reply to message #336149] Fri, 25 July 2008 02:20 Go to previous messageGo to next message
sajut
Messages: 69
Registered: January 2007
Member
Thanks for the hint. I could do this using the following script
for startup
#!/bin/bash
ORA_HOME="/opt/oracle/920"
ORA_OWNER="oracle"
SQLCMD="sqlplus '/as sysdba'"
LOGFILE="strt.log"
cat startup.sql | su - $ORA_OWNER  -c "$SQLCMD" > $LOGFILE

startup.sql
startup nomount;
alter database mount standby database;
alter database recover managed standby database disconnect from session;


and for shutdown

#!/bin/bash
ORA_HOME="/opt/oracle/920"
ORA_OWNER="oracle"
SQLCMD="sqlplus '/as sysdba'"
LOGFILE="sht.log"
cat shutdown.sql | su - $ORA_OWNER  -c "$SQLCMD" > $LOGFILE

shutdown.sql
alter database recover managed standby database cancel;
shutdown;
exit
Re: to start and stop a standby database on server startup [message #336189 is a reply to message #336183] Fri, 25 July 2008 02:29 Go to previous messageGo to next message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You have to explicitly set ORACLE_HOME and ORACLE_SID.
Don't "su" in your script, put the script in oracle crontab not root one then you just have to call "sqlplus '/ as sysdba' @startup"

Regards
Michel
Re: to start and stop a standby database on server startup [message #336547 is a reply to message #336189] Mon, 28 July 2008 02:02 Go to previous messageGo to next message
sajut
Messages: 69
Registered: January 2007
Member
Thanks Michel for your advice. But, if I put these scripts as cron entries for user oracle, how will it execute at system boot and shutdown?. If I am right, cron executes at preset timings and not at system startup and system shutdown. That is why I put these scripts in /etc/init.d/rc.n (n stands for runlevel).

Saju
Re: to start and stop a standby database on server startup [message #336555 is a reply to message #336547] Mon, 28 July 2008 02:20 Go to previous message
Michel Cadot
Messages: 64151
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
, how will it execute at system boot and shutdown?

This was not your original qyestion.
Different question, different answer.

Regards
Michel
Previous Topic: Physical Standby Database problems
Next Topic: About Data Guard
Goto Forum:
  


Current Time: Sat Dec 10 01:05:06 CST 2016

Total time taken to generate the page: 0.22697 seconds