背景:生产环境是RAC (11.2.0.1) ,要搭建一个单实例的测试环境
实现方法:对生产环境做一个rman备份,然后在测试环境进行不完整恢复
一、rman 备份,备份脚本如下:
[oracle@easrac01 ~]$ more /home/oracle/scripts/zszjk_full.sh
#!/bin/sh
source /home/oracle/.bash_profilezjk
CUSER=`id |cut -d"(" -f2 | cut -d ")" -f1`
DT=`date +"%Y%m%d_%H%M%S"`
RMAN_LOG_FILE=/home/oracle/bak_dir/zszjk_full.out
echo >> $RMAN_LOG_FILE
chmod 666 $RMAN_LOG_FILE
echo Script $0 >> $RMAN_LOG_FILE
echo ==== started on `date` ==== >> $RMAN_LOG_FILE
echo >> $RMAN_LOG_FILE
rman target / nocatalog msglog $RMAN_LOG_FILE append << EOF
RUN {
#sql 'alter system archive log current';
allocate channel ch00 TYPE disk;
allocate channel ch01 TYPE disk;
allocate channel ch02 TYPE disk;
allocate channel ch03 TYPE disk;
allocate channel ch04 TYPE disk;
allocate channel ch05 TYPE disk;
#send 'NB_ORA_POLICY=Ora_DB_ecdb02_Full';
backup INCREMENTAL LEVEL 0 filesperset = 5 as compressed backupset database format '/home/oracle/bak_dir/full_
%d_%T_%U.rman';
#sql 'alter system archive log current';
backup filesperset = 15 as compressed backupset archivelog all format '/home/oracle/bak_dir/arch_%d_%T_%U.rman
' delete input force;
DELETE noprompt OBSOLETE;
crosscheck backup;
delete noprompt expired backup;
release channel ch00;
release channel ch01;
release channel ch02;
release channel ch03;
release channel ch04;
release channel ch05;
#sql 'alter system archive log current';
ALLOCATE CHANNEL ch00 TYPE disk;
copy current controlfile to '/home/oracle/bak_dir/control.full_%d_%T.rman';
backup spfile format '/home/oracle/bak_dir/spfile_%d_%T';
release channel ch00;
}
EOF
二、在备库进行恢复
1、恢复参数文件、控制文件(使用备份的控制文件进行恢复)