备份脚本内容如下:
export RMAN_LOG_FILE=/logbackup/ycyth_ramn/fullrman20160817.log
export ORACLE_BASE=/u01/app/oracle
export RMAN=$ORACLE_HOME/bin/rman
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export ORACLE_SID=ycythdb2
rman target / nocatalog msglog $RMAN_LOG_FILE append << EOF
run{
allocate channel t1 type disk;
allocate channel t2 type disk;
allocate channel t3 type disk;
allocate channel t4 type disk;
allocate channel t5 type disk;
allocate channel t6 type disk;
allocate channel t7 type disk;
allocate channel t8 type disk;
backup as compressed backupset full tag 'dbfull' format '/logbackup/ycyth_ramn/dbfull_%t_%s_%p' diskratio=0 database ;
sql 'alter system archive log current';
backup as compressed backupset format '/logbackup/ycyth_ramn/arch_%t_%s_%p' diskratio=0 archivelog all;
backup format '/logbackup/ycyth_ramn/ctl_%t_%s_%p' current controlfile ;
release channel t1;
release channel t2;
release channel t3;
release channel t4;
release channel t5;
release channel t6;
release channel t7;
release channel t8;
}
EOF
备份完了,要修改权限 chown oracle:oinstall -R *
1)恢复参数文件:
源端生成pfile
sql> create pfile='/mnt/rmannfs/ycythrman/pfile.20160810' from spfile;
修改pfile
*.db_create_file_dest='+DATA'
改成
*.db_create_file_dest='+DATAC1/YCYTHDB/CONTROLFILE'
*.remote_listener='HB95598-scan:1521'
改成
*.remote_listener='mmsdb-scan:1521'
*.control_files='+DATA/ycythdb/controlfile/current.292.906236575'
改成
*.control_files='+DATAC1'
*.compatible='11.2.0.0.0'
改成
*.compatible='11.2.0.4.0'
*.cluster_database=true
改成
*.cluster_database=false
ycythdb1.log_archive_dest_1='location=/arch01'
ycythdb2.log_archive_dest_1='location=/arch02'
改成
ycythdb1.log_archive_dest_1='location=+DATAC1'
ycythdb2.log_archive_dest_1='location=+DATAC1'
#set archivelog destination to '/xtts_stage/arch';
2)通过修改后的参数文件将目标端库启动到nomout状态
sql> startup nomount pfile='/xtts_stage/ycythrman/pfile.20160810';
3)恢复控制文件:
export ORACLE_SID=ycythdb1
rman target /
rman>restore controlfile from '/xtts_stage/ycythrman/ctl_920076103_305_1';
4)修改数据文件的DG路径 (98个数据文件,6个redo,2个tmp文件)
SQL> col name format a60 ;
select file#,name from v$datafile ;
select count(*) from v$datafile ;
select count(*) from v$logfile ;
select count(*) from v$tempfile ;
a.数据文件:
select 'set newname for datafile '|| file# ||' to ''+DATAC1'' ;' from v$datafile order by file#;
b.redo文件:
select 'alter database rename file ''||group#||'' to ''+DATAC1'';' from v$logfile;
c.temp文件:
select 'set newname for tempfile '|| file# ||' to ''+DATAC1'' ;' from v$tempfile ;
5)注册备份集:
rman target /
catalog start with '/xtts_stage/ycythrman/' ;
catalog start with '/xtts_stage/ycythrman/last_arch/'
6)开始恢复数据
export ORACLE_SID=ycythdb1
rman target / msglog /home/oracle/restorzxk20160817.log append
run{
set newname for datafile 1 to '+DATAC1' ;
set newname for datafile 2 to '+DATAC1' ;
set newname for datafile 3 to '+DATAC1' ;
set newname for datafile 4 to '+DATAC1' ;
set newname for datafile 5 to '+DATAC1' ;
set newname for datafile 6 to '+DATAC1' ;
set newname for datafile 7 to '+DATAC1' ;
set newname for datafile 8 to '+DATAC1' ;
set newname for datafile 9 to '+DATAC1' ;
set newname for datafile 10 to '+DATAC1' ;
set newname for datafile 11 to '+DATAC1' ;
set newname for datafile 12 to '+DATAC1' ;
set newname for datafile 13 to '+DATAC1' ;
set newname for datafile 14 to '+DATAC1' ;
set newname for datafile 15 to '+DATAC1' ;
set newname for datafile 16 to '+DATAC1' ;
set newname for datafile 17 to '+DATAC1' ;
set newname for datafile 18 to '+DATAC1' ;
set newname for datafile 19 to '+DATAC1' ;
set newname for datafile 20 to '+DATAC1' ;
set newname for datafile 21 to '+DATAC1' ;
set newname for datafile 22 to '+DATAC1' ;
set newname for datafile 23 to '+DATAC1' ;
set newname for datafile 24 to '+DATAC1' ;
set newname for datafile 25 to '+DATAC1' ;
set newname for datafile 26 to '+DATAC1' ;
set newname for datafile 27 to '+DATAC1' ;
set newname for datafile 28 to '+DATAC1' ;
set newname for datafile 29 to '+DATAC1' ;
set newname for datafile 30 to '+DATAC1' ;
set newname for datafile 31 to '+DATAC1' ;
set newname for datafile 32 to '+DATAC1' ;
set newname for datafile 33 to '+DATAC1' ;
set newname for datafile 34 to '+DATAC1' ;
set newname for datafile 35 to '+DATAC1' ;
set newname for datafile 36 to '+DATAC1' ;
set newname for datafile 37 to '+DATAC1' ;
set newname for datafile 38 to '+DATAC1' ;
set newname for datafile 39 to '+DATAC1' ;
set newname for datafile 40 to '+DATAC1' ;
set newname for datafile 41 to '+DATAC1' ;
set newname for datafile 42 to '+DATAC1' ;
set newname for datafile 43 to '+DATAC1' ;
set newname for datafile 44 to '+DATAC1' ;
set newname for datafile 45 to '+DATAC1' ;
set newname for datafile 46 to '+DATAC1' ;
set newname for datafile 47 to '+DATAC1' ;
set newname for datafile 48 to '+DATAC1' ;
set newname for datafile 49 to '+DATAC1' ;
set newname for datafile 50 to '+DATAC1' ;
set newname for datafile 51 to '+DATAC1' ;
set newname for datafile 52 to '+DATAC1' ;
set newname for datafile 53 to '+DATAC1' ;
set newname for datafile 54 to '+DATAC1' ;
set newname for datafile 55 to '+DATAC1' ;
set newname for datafile 56 to '+DATAC1' ;
set newname for datafile 57 to '+DATAC1' ;
set newname for datafile 58 to '+DATAC1' ;
set newname for datafile 59 to '+DATAC1' ;
set newname for datafile 60 to '+DATAC1' ;
set newname for datafile 61 to '+DATAC1' ;
set newname for datafile 62 to '+DATAC1' ;
set newname for datafile 63 to '+DATAC1' ;
set newname for datafile 64 to '+DATAC1' ;
set newname for datafile 65 to '+DATAC1' ;
set newname for datafile 66 to '+DATAC1' ;
set newname for datafile 67 to '+DATAC1' ;
set newname for datafile 68 to '+DATAC1' ;
set newname for datafile 69 to '+DATAC1' ;
set newname for datafile 70 to '+DATAC1' ;
set newname for datafile 71 to '+DATAC1' ;
set newname for datafile 72 to '+DATAC1' ;
set newname for datafile 73 to '+DATAC1' ;
set newname for datafile 74 to '+DATAC1' ;
set newname for datafile 75 to '+DATAC1' ;
set newname for datafile 76 to '+DATAC1' ;
set newname for datafile 77 to '+DATAC1' ;
set newname for datafile 78 to '+DATAC1' ;
set newname for datafile 79 to '+DATAC1' ;
set newname for datafile 80 to '+DATAC1' ;
set newname for datafile 81 to '+DATAC1' ;
set newname for datafile 82 to '+DATAC1' ;
set newname for datafile 83 to '+DATAC1' ;
set newname for datafile 84 to '+DATAC1' ;
set newname for datafile 85 to '+DATAC1' ;
set newname for datafile 86 to '+DATAC1' ;
set newname for datafile 87 to '+DATAC1' ;
set newname for datafile 88 to '+DATAC1' ;
set newname for datafile 89 to '+DATAC1' ;
set newname for datafile 90 to '+DATAC1' ;
set newname for datafile 91 to '+DATAC1' ;
set newname for datafile 92 to '+DATAC1' ;
set newname for datafile 93 to '+DATAC1' ;
set newname for datafile 94 to '+DATAC1' ;
set newname for datafile 95 to '+DATAC1' ;
set newname for datafile 96 to '+DATAC1' ;
set newname for datafile 97 to '+DATAC1' ;
set newname for datafile 98 to '+DATAC1' ;
sql "alter databaserenamefile ''+DATA/ycythdb/onlinelog/redo05.log'' to ''+DATAC1'' " ;
sql "alter databaserenamefile ''+DATA/ycythdb/onlinelog/redo06.log'' to ''+DATAC1'' " ;
sql "alter databaserenamefile ''+DATA/ycythdb/onlinelog/redo07.log'' to ''+DATAC1'' " ;
sql "alter databaserenamefile ''+DATA/ycythdb/onlinelog/redo08.log'' to ''+DATAC1'' " ;
sql "alter databaserenamefile ''+DATA/ycythdb/onlinelog/redo09.log'' to ''+DATAC1'' " ;
sql "alter databaserenamefile ''+DATA/ycythdb/onlinelog/redo10.log'' to ''+DATAC1'' " ;
set newname for tempfile 1 to '+DATAC1' ;
set newname for tempfile 2 to '+DATAC1' ;
allocate channel t1 type disk ;
allocate channel t2 type disk ;
allocate channel t3 type disk ;
allocate channel t4 type disk ;
allocate channel t5 type disk ;
allocate channel t6 type disk ;
allocate channel t7 type disk ;
allocate channel t8 type disk ;
allocate channel t9 type disk ;
allocate channel t10 type disk ;
allocate channel t11 type disk ;
allocate channel t12 type disk ;
allocate channel t13 type disk ;
allocate channel t14 type disk ;
allocate channel t15 type disk ;
allocate channel t16 type disk ;
restore database ;
switch datafile all ;
switch tempfile all ;
release channel t1 ;
release channel t2 ;
release channel t3 ;
release channel t4 ;
release channel t5 ;
release channel t6 ;
release channel t7 ;
release channel t8 ;
release channel t9 ;
release channel t10 ;
release channel t11 ;
release channel t12 ;
release channel t13 ;
release channel t14 ;
release channel t15 ;
release channel t16 ;
}
rman>recover database ;
检查scn
col CHECKPOINT_CHANGE# format a20
SQL> SELECT CHECKPOINT_CHANGE# FROM V$DATAFILE_HEADER;
SQL>SELECT distinct CHECKPOINT_CHANGE# FROM V$DATAFILE;
select to_char( to_number( CHECKPOINT_CHANGE# )) from V$DATABASE;
select to_char( to_number( CHECKPOINT_CHANGE# )) from V$DATAFILE;
SELECT to_char( to_number( CHECKPOINT_CHANGE# )) FROM V$DATAFILE_HEADER;
SQL>alter database open resetlogs upgrade;
SQL> spool /tmp/upgrade.log
SQL> @?/rdbms/admin/catupgrd.sql
注册集群资源
srvctl add database -d ycythdb -n mmsdbadm03 -o /u01/app/oracle/product/11.2.0.4/dbhome_1 -p +DATAC1/ycythdb/parameterfile/spfile.1613.920302901 -a DATAC1,DBFS_DG,RECOC1
srvctl add instance -d ycythdb -i ycythdb1 -n mmsdbadm03
srvctl add instance -d ycythdb -i ycythdb2 -n mmsdbadm04
create spfile='+DATAC1' from memory;
修改initSID.ora
[oracle@ycfkdb2 dbs]$ vim initycfkdb2.ora
[oracle@ycfkdb2 dbs]$ more initycfkdb2.ora
SPFILE='+dgdata/ycfkdb/parameterfile/spfile.513.920637845'