程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> oraclerman異機恢復

oraclerman異機恢復

編輯:Oracle教程

oraclerman異機恢復


 

  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的內容

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved