Oracle 利用RMAN 完成資料移轉

來源:互聯網
上載者:User

Oracle 利用RMAN 完成資料移轉

整體流程:對A機的資料庫來一個熱備,並且是一個全備,然後通過scp命令把備份傳到B機,然後把A庫停掉(注意關庫不會觸發歸檔),之後再把歸檔日誌和redo日誌傳給B機,最後再在B庫上 restore 和recover

資料檔案,控制檔案,參數檔案  的恢複過程:根據資料庫的啟動流程,可以知道最先讀取資料檔案,所以應該先還原參數檔案,然後會讀控制檔案,所以你要再修複控制檔案,最後再修複資料檔案,具體操作流程:一:對A庫做一個熱全備,RMAN> backup as backupset database include current controlfile plus archivelog format '/u01/app/Oracle/arch_%U.rmn' delete all input;省列。。。。Finished backup at 14-AUG-14二:把所做的備份用scp傳給B機。 如紅色命令會把A機的ENMOEDU接到B機的Oracle/下,,即Oracle/ENMOEDU[oracle@ENMOEDU ENMOEDU]$ scp -r /u01/app/oracle/fast_recovery_area/ENMOEDU     oracle@192.168.80.11:/u01/app/oracle/ 
The authenticity of host '192.168.80.11 (192.168.80.11)' can't be established. 
RSA key fingerprint is 54:78:71:4c:93:51:01:f4:e3:83:b5:35:8f:9f:d5:b1. 
Are you sure you want to continue connecting (yes/no)? y 
Please type 'yes' or 'no': yes 
Warning: Permanently added '192.168.80.11' (RSA) to the list of known hosts. 
oracle@192.168.80.11's password: 
o1_mf_nnndf_SECTION_DF1_9srh9o7k_.bkp 100% 148MB 36.9MB/s 00:04 
o1_mf_ncnnf_SECTION_DF1_9srh9ws3_.bkp 100% 9568KB 9.3MB/s 00:01 
o1_mf_nnndf_SECTION_DF1_9srh9n9o_.bkp 100% 97MB 24.2MB/s 00:04 
o1_mf_nnsnf_SECTION_DF1_9srh9nml_.bkp 100% 96KB 96.0KB/s 00:00 
o1_mf_nnndf_SECTION_DF1_9srh9o26_.bkp 100% 140MB 28.0MB/s 00:05 
o1_mf_nnndf_SECTION_DF1_9srh9v71_.bkp 100% 145MB 29.0MB/s 00:05 
o1_mf_nnndf_SECTION_DF1_9srhb0dh_.bkp 100% 81MB 27.0MB/s 00:03 
o1_mf_ncsnf_TAG20140814T203309_9ysc8x14_.bkp 100% 9600KB 4.7MB/s 00:02 
o1_mf_nnndf_TAG20140814T203309_9ysc46go_.bkp 100% 1140MB 24.3MB/s 00:47 
control02.ctl                                                            100% 9520KB 9.3MB/s 00:01 
三:把A庫資料庫關閉,把歸檔和redo傳給B機,(因為你備份的時候沒有關閉資料庫,難免會再產生新的歸檔和redo,為保證一致性,還有必要進行這步)1.SYS@ENMOEDU> select * from v$log;                      #顯示第三組  正在被使用,所以只傳它就行(因為別的已經被歸檔,)

GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC 
---------- ---------- ---------- ---------- ---------- ---------- --- 
STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME 
---------------- ------------- --------- ------------ --------- 
1 1 100 52428800 512 1 YES 
INACTIVE 1365811 14-AUG-14 1365876 14-AUG-14 

2 1 101 52428800 512 1 YES 
INACTIVE 1365876 14-AUG-14 1365981 14-AUG-14 

3 1 102 52428800 512 1 NO 
CURRENT 1365981 14-AUG-14 2.8147E+14 


2.SYS@ENMOEDU> select * from v$logfile;     #查看日誌的具體位置

GROUP# STATUS TYPE 
---------- ------- ------- 
MEMBER 
-------------------------------------------------------------------------------- 
IS_ 
--- 
1 ONLINE 
/u01/app/oracle/oradata/ENMOEDU/redo01.log 
NO 

2 ONLINE 
/u01/app/oracle/oradata/ENMOEDU/redo02.log 
NO 

GROUP# STATUS TYPE 
---------- ------- ------- 
MEMBER 
-------------------------------------------------------------------------------- 
IS_ 
--- 

3 ONLINE 
/u01/app/oracle/oradata/ENMOEDU/redo03.log 
NO[oracle@ENMOEDU ENMOEDU]$ scp /u01/app/oracle/oradata/ENMOEDU/redo03.log oracle@192.168.80.11:/u01/app/oracle 
oracle@192.168.80.11's password: 
redo03.log 100% 50MB 50.0MB/s 00:01   至于歸檔嘛  我在測試的時候沒有切換日誌,也不存在日誌組寫滿的情況,所以沒有產生歸檔,又因為我在備份的時候加上了delete all input 所以會把已經備份的歸檔刪掉,所以你不會看到新的歸檔  也就不用傳了  呵呵四:在B機操作1,開啟偽執行個體,注意可不要把B機的資料庫執行個體給開啟了  因為我的測試B機也有資料庫。[oracle@ENMOEDU ~]$ set DBID=87396644               #設成A機的資料庫編號RMAN> startup                #啟動偽執行個體    [oracle@ENMOEDU ENMOEDU]$ rman target / RMAN> restore spfile from '/u01/app/oracle/ENMOEDU/backupset/2014_08_14/o1_mf_ncsnf_TAG20140814T203309_9ysc8x14_.bkp';  Starting restore at 15-AUG-14using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=20 device type=DISK channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/ENMOEDU/backupset/2014_08_14/o1_mf_ncsnf_TAG20140814T203309_9ysc8x14_.bkpchannel ORA_DISK_1: SPFILE restore from AUTOBACKUP completeFinished restore at 15-AUG-14[oracle@ENMOEDU dbs]$ ls                  #恢複的參數檔案在$ORACLE_HOME/dbs  下
hc_ENMOEDU2.dat    lkDUMMY   orapwENMOEDU    spfileENMOEDU2.oraRMAN> shutdown immediate                           #關偽執行個體 Oracle instance shut down2.然後再起真正的執行個體,恢複控制檔案(要注意,他原來就有,你這樣起,把B機的所有檔案包括  資料檔案 ,控制檔案,參數檔案,記錄檔都刪掉)SQL> startupORACLE instance started. Total System Global Area 422670336 bytesFixed Size 1345380 bytesVariable Size 260049052 bytesDatabase Buffers 155189248 bytesRedo Buffers 6086656 bytesORA-00205: error in identifying control file, check alert log for more infoRMAN> restore controlfile from '/u01/app/oracle/ENMOEDU/backupset/2014_08_14/o1_mf_ncsnf_TAG20140814T203309_9ysc8x14_.bkp'; Starting restore at 15-AUG-14using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=18 device type=DISK channel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:01output file name=/u01/app/oracle/oradata/ENMOEDU/control01.ctloutput file name=/u01/app/oracle/fast_recovery_area/ENMOEDU/control02.ctlFinished restore at 15-AUG-143.把資料庫開到mount狀態,以便修複資料檔案。RMAN> alter database mount; database mountedreleased channel: ORA_DISK_1RMAN> restore database;                    #恢複資料檔案   發現報錯,很可能是備份已經到期已經, Starting restore at 15-AUG-14using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=1 device type=DISK creating datafile file number=1 name=/u01/app/oracle/oradata/ENMOEDU/system01.dbfRMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of restore command at 08/15/2014 23:21:00ORA-01180: can not create datafile 1ORA-01110: data file 1: '/u01/app/oracle/oradata/ENMOEDU/system01.dbf'RMAN> list backup;          #查看備份資訊    發現確實到期10 13.85M DISK 00:00:02 14-AUG-14        BP Key: 14 Status: EXPIRED Compressed: NO Tag: TAG20140814T203306        Piece Name: /u01/app/oracle/arch_50pfv1g2_1_1.rmn然後再去A機  再來一個整體備份  再傳給B機  不在贅述,再恢複控制檔案,然後再恢複資料檔案,  再啟動到open即可。 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.