Oracle源主机 | Oracle目标主机 | |
主机平台 | CentOS6.2(final) | CentOs6.2(FInal) |
主机名 | vick | rman |
IP地址 | 192.168.1.11 | 192.168.1.10 |
实例名字 | orcl | orcl |
Oracle版本 | 11.2.0.4 | 11。2.0.4 |
Oracle数据文件存储 | filesystem | filesystem |
控制文件路径 | /u01/app/oracle/oradata | /u01/app/oracle/oradata |
数据文件路径 | /u01/app/oracle/oradata | /u01/app/oracle/oradata |
在线重做日志路径 | /u01/app/oracle/oradata | /u01/app/oracle/oradata |
查看源库的控制文件信息:
SQL> select name from v$controlfile;
NAME
------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/control01.ctl
/u01/app/oracle/fast_recovery_area/orcl/control02.ctl
源库的数据文件信息:
SQL> select file#,name from v$datafile;
FILE# NAME
--------------------------------------------------------------------------------
1 /u01/app/oracle/oradata/orcl/system01.dbf
2 /u01/app/oracle/oradata/orcl/sysaux01.dbf
3 /u01/app/oracle/oradata/orcl/undotbs01.dbf
4 /u01/app/oracle/oradata/orcl/users01.dbf
5 /u01/app/oracle/oradata/orcl/tbs_catalog.dbf
6 /u01/app/oracle/oradata/orcl/dave01.dbf
源库在线重做日志文件:
SQL> select group#,member from v$logfile;
GROUP#MEMBER
--------------------------------------------------------------------------------
1 /u01/app/oracle/oradata/orcl/redo01.log
2 /u01/app/oracle/oradata/orcl/redo02.log
3 /u01/app/oracle/oradata/orcl/redo03.log
如果路径有不同的地方则需要进行相关操作
在源数据库上用rman备份数据库,包括数据库
[oracle@vick ~]$ mkdir /u01/backup
[oracle@vick ~]$ rman target /
RMAN> run {
2> allocate channel c1 device type disk;
3> backup incremental level 0
4> format '/u01/backup/db_full_%U.bkp'
5> tag '2014-11-14-FULL'
6> database plus archivelog;
7> release channel c1;
8> }
RMAN> backup current controlfile format '/u01/backup/control20141114 .bak';
RMAN> backup spfile format '/u01/backup/spfile20141114.bak';
二、在目标主机上复制备份数据,并准备好相关目录
将备份传到目标主机
[oracle@vick backup]$ scp * 192.168.1.10:/u01/backup
db_full_3kpnjk76_1_1.bkp 100% 148MB 11.4MB/s 00:13
db_full_3lpnjk7l_1_1.bkp 100% 1103MB 7.8MB/s 02:22
control20141114 .bak 100% 9664KB 9.4MB/s 00:01
spfile20141114.bak 100% 96KB 96.0KB/s 00:00
创建相关目录
[oracle@rman orcl]$ mkdir {adump,bdump,cdump,dpdump,udump,pfile}
[oracle@rman ~]$ mkdir -p /u01/app/oracle/oradata/orcl
[oracle@rman ~]$ mkdir -p /u01/app/oracle/fast_recovery_area/ORCL
创建密码文件:
[oracle@rman dbs]$ orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle
创建initorcl.ora文件
[oracle@rman ~]$ echo 'db_name=orcl'>$ORACLE_HOME/dbs/initorcl.ora
异机恢复-->以下操作在目标主机执行
设置DBID
查看寻源主机DBID
SQL> select dbid from v$database;
DBID
----------
1387254920
[oracle@rman dbs]$ rman target /
RMAN> set dbid 1387254920
executing command: SET DBID
MAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area 217157632 bytes
Fixed Size 2251816 bytes
Variable Size 159384536 bytes
Database Buffers 50331648 bytes
Redo Buffers 5189632 bytes
恢复参数文件
RMAN> restore spfile from '/u01/backup/spfile20141114.bak';
Starting restore at 14-NOV-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/backup/spfile20141114.bak
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 14-NOV-14
重启nomout
RMAN> startup nomount force;
Oracle instance started
Total System Global Area 613797888 bytes
Fixed Size 2255712 bytes
Variable Size 427820192 bytes
Database Buffers 180355072 bytes
Redo Buffers 3366912 bytes
RMAN> restore controlfile from '/u01/backup/control20141114 .bak';
Starting restore at 14-NOV-14
using channel ORA_DISK_1
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/orcl/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/orcl/control02.ctl
Finished restore at 14-NOV-14
RMAN> startup mount
RMAN>restore database;
如果这一步没法执行可以使用list incarnation产看相关信息,切换一下再执行
reset database to incarnation XX;
RMAN> recover database;
RMAN-03002: failure of recover command at 11/14/2014 22:19:36
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of archived log for thread 1 with sequence 13 and starting SCN of 1208284
这一步竟然报错了,后来我发现没有执行catalog
然后我执行了catalog start with ‘/u01/backup/’;
完了再次执行recover
但是还是出错现了同样的错误
然后我执行list backup of archivelog all查看后,执行了以下脚本就好了
RMAN> run {
2> set until scn 1208284;
3> recover database;
4> }
executing command: SET until clause
Starting recover at 14-NOV-14
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 14-NOV-14
然后登陆数据库执行
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-19751: could not create the change tracking file
ORA-19750: change tracking file:
'/u01/app/oracle/oradata/orcl/ORCL/changetracking/o1_mf_b51rj77x_.chg'
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 1
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
又出错了,我就去/u01/app/oracle/oradata/orcl/ORCL/changetracking/目录查看没有这个目录
然后我执行了
SQL>ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;
然后关闭数据库shutdown immediate;
再执行startup;
数据库成功启动
搞这个异机恢复,第一次搞了2天,头都大了,好多解决方法都没用,以上为个人遇到的问题,希望对一些遇到同类问题的朋友有帮助
改变change tracking file的位置
1) 不关闭数据库的方式
SQL> ALTER DATABASE DISABLE BLOCK CHANGE TRACKING;
SQL> ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE 'new_location';
注意:这种方式会丢失change tracking file的内容