restore ederken otomatik set newname tanımlama

Yazının devamında exadata üzerinde ibm tivoliye aldığımız backupların, başka bir exadata üzerinde farklı disk grup isimleri olan bir makinaya restore etmek için oluşturduğumuz scriptler var.

Bu scriptlerde bir sh içerisinde önce mevcut datafie bilgilerini select ederek bunlara uygun şekilde set newname scripti oluşturuyor.

daha sonra da rman ayarlamalarını yapıp, ilgili scripti execute ederek restore ve recover işlemlerini gerçekleştiriyor.

 

[oracle@exadata1 cronscripts]$ cat testdb_automatic_restore_subat.sh
LOG_DIR=/home/oracle/cronlogs
SCRIPT_DIR=/home/oracle/cronscripts
currentdate=`date ‘+%Y%m%d%H%M%S’`

export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=testdb1
export ORACLE_UNQNAME=testdb

echo “RESTORE DATABASE BASLIYOR …”
rman log=$LOG_DIR/rman_`date ‘+%Y%m%d%H%M%S’`_testdb_restore_controlfile.log <<EOF
connect target /
run
{
allocate channel ch1 type ‘sbt_tape’ parms ‘ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_testdb_offsite.opt)’;
allocate channel ch2 type ‘sbt_tape’ parms ‘ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_testdb_offsite.opt)’;
allocate channel ch3 type ‘sbt_tape’ parms ‘ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_testdb_offsite.opt)’;
allocate channel ch4 type ‘sbt_tape’ parms ‘ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_testdb_offsite.opt)’;
restore controlfile from ‘ijtplksm_1_1’;
sql ‘alter database mount’;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}
exit;
EOF
### Set new name icin script cikariyor ###
rm -f $SCRIPT_DIR/restore_auto_testdb_setnewname.rman
sqlplus -s “/ as sysdba” <<EOF
set lines 150
set pages 0
set feedback off
spool $SCRIPT_DIR/restore_auto_testdb_setnewname.rman
select ‘set newname for datafile ‘||file#||’ to ”+DATA_D2”;’ from v\$datafile order by file#;
select ‘set newname for tempfile ‘||file#||’ to ”+RECO_D2”;’ from v\$tempfile order by file#;
spool off
exit;
EOF
chmod 755 $SCRIPT_DIR/restore_auto_testdb_setnewname.rman
### Ustteki adimda olusan scripti calistirip restore’u baslat.yor ###
rman log=$LOG_DIR/rman_`date ‘+%Y%m%d%H%M%S’`_testdb_restore_database.log <<EOF
connect target /
run
{
allocate channel ch1 type ‘sbt_tape’ parms ‘ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_testdb_offsite.opt)’;
allocate channel ch2 type ‘sbt_tape’ parms ‘ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_testdb_offsite.opt)’;
allocate channel ch3 type ‘sbt_tape’ parms ‘ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_testdb_offsite.opt)’;
allocate channel ch4 type ‘sbt_tape’ parms ‘ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_testdb_offsite.opt)’;
@$SCRIPT_DIR/restore_auto_testdb_setnewname.rman
#sql ‘alter system set wallet open identified by “XXXXXX”‘;
set until sequence 199616 thread 3;
restore database;
switch datafile all;
sql ‘alter database disable block change tracking’;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}
exit;
EOF

 



 

[oracle@exadata1 cronscripts]$ cat testdb_automatic_recover.sh
LOG_DIR=/home/oracle/cronlogs
SCRIPT_DIR=/home/oracle/cronscripts
currentdate=`date ‘+%Y%m%d%H%M%S’`

export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=testdb1
export ORACLE_UNQNAME=testdb

echo “RECOVER DATABASE BASLIYOR …”
rman log=$LOG_DIR/rman_`date ‘+%Y%m%d%H%M%S’`_testdb_recover.log <<EOF
connect target /
#connect catalog rmanuser/XXXXXX@RMANCATALOG
run
{
allocate channel ch1 type ‘sbt_tape’ parms ‘ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_testdb_offsite.opt)’;
allocate channel ch2 type ‘sbt_tape’ parms ‘ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_testdb_offsite.opt)’;
allocate channel ch3 type ‘sbt_tape’ parms ‘ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_testdb_offsite.opt)’;
allocate channel ch4 type ‘sbt_tape’ parms ‘ENV=(TDPO_OPTFILE=/opt/tivoli/tsm/client/oracle/bin64/tdpo_testdb_offsite.opt)’;
#sql ‘alter database mount’;

#sql ‘alter system set wallet open identified by “XXXXXX”‘;

set until sequence 199616 thread 3;
recover database;

release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}

exit;
EOF

 

Leave a Reply

Your email address will not be published. Required fields are marked *