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
oracle
源庫的數據文件信息:app
SQL> select file#,name from v$datafile;
spa
FILE# NAME
rest
--------------------------------------------------------------------------------日誌
1 /u01/app/oracle/oradata/orcl/system01.dbform
2 /u01/app/oracle/oradata/orcl/sysaux01.dbfci
3 /u01/app/oracle/oradata/orcl/undotbs01.dbfrem
4 /u01/app/oracle/oradata/orcl/users01.dbfget
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';
2、在目標主機上覆製備份數據。並準備好相關文件夾
將備份傳到目標主機
[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
建立password文件:
[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的內容