Tuesday, April 15, 2008

Cron backup on Solaris

#!/bin/sh

ORACLE_BASE=/opt/app/oracle
export ORACLE_BASE

ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_HOME

ORACLE_SID=sunrise
export ORACLE_SID

LD_LIBRARY_PATH_64=$ORACLE_HOME/lib:$LD_LIBRARY_PATH_64
export LD_LIBRARY_PATH_64

LD_LIBRARY_PATH=$ORACLE_HOME/lib32:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH

PATH=$ORACLE_HOME/bin:$PATH
export PATH

NLS_LANG=American_America.AL32UTF8
export NLS_LANG

NLS_DATE_FORMAT='DD-Mon-YYYY HH24:MI:SS'
export NLS_DATE_FORMAT

rman target sys/pwd @/home/oracle/crons/backupinc0.rmn log /home/oracle/crons/backupinc0.log

Thursday, April 10, 2008

Move and Rename DB

1. Backup the control file of DB to trace.
alter database backup controlfile to trace

This will produce the following sql in user_dump_dest

STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "OLDDB" NORESETLOGS

2. Shutdown the DB and move the datafiles to the new location. DataFiles can be renamed but control file trace must be edited to reflect the changes.
3. Change
CREATE CONTROLFILE REUSE DATABASE "OLDDB" NORESETLOGS
to
CREATE CONTROLFILE SET DATABASE "NEWDB" NORESETLOGS

4. Remove recover database and open database statments from the control file trace.
5. If any of the *dump directories are missing create them.
6. create a pfile to start the new DB
7. Start the new DB with
startup nomount;
@control_file_trace.sql


Tuesday, April 8, 2008

Auto Start Oracle DB on Solaris

create a similar script in /etc/init.d


#!/bin/sh

user=oracle
SU=/bin/su
ORACLE_HOME=/opt/app/oracle/product/10.2.0/db_1
export ORACLE_HOME

case "$1" in
start)
$SU $user $ORACLE_HOME/bin/dbstart
;;
restart)
$SU $user $ORACLE_HOME/bin/dbshut
$SU $user $ORACLE_HOME/bin/dbstart
;;
stop)
$SU $user $ORACLE_HOME/bin/dbshut
;;
*)
echo "Usage : oracle start restart stop"
;;
esac

Edit $ORACLE_HOME/bin/dbshut and dbstart, pay attention to where oratab is. In solaris this is in /var/opt/oracle/oratab

Create softlink on rc0 rc2 and rc3 (on solaris 10)

ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle

ln -s /etc/init.d/oracle /etc/rc2.d/K01oracle
ln -s /etc/init.d/oracle /etc/rc2.d/S99oracle

ln -s /etc/init.d/oracle /etc/rc3.d/K01oracle
ln -s /etc/init.d/oracle /etc/rc3.d/S99oracle