從nub備份恢復(同平臺)恢復RAC至單例項

記錄每一次錯誤發表於2018-12-18

前段時間從生產的RAC的nub備份恢復到單例項資料庫,過程如下:

 1 將11.2.0.4 下的rac庫備份並恢復到11.2.0.4 下的單例項環境下。  

 2.    由於是同步nub備份恢復所有不需要備份源端的RAC庫,直接在nbu上找到備份,開始恢復

    2.1.在單例項資料庫中配置關於資料庫的資訊,.bash_profile檔案,要注意字符集的定義,安裝完成資料庫軟體。

    2.2.在單例項資料庫中建立引數檔案,手工建立或者在源端庫建立建立一個文字檔案scp至目錄庫都行

方法一 :

     手工建立:

    cd  $ORACLE_HOME/dbs

grep init.ora|grep -v ^$|grep -v ^#>initorcl.ora

然後修改裡面的內容

方法二:

     從生產庫上

     執行create pfile='/home/oracle/rman_back/initorcl.ora' from spfile;

使用scp傳輸至目標庫的單例項下的$ORACLE_HOME/dbs下     

修改完成以後內容如下

*.audit_file_dest='/u01/app/oracle/admin/orcl/adump'

*.audit_trail='db'

*.compatible='11.2.0.4.0'

*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/oradata/orcl/control02.ctl'

*.db_block_size=8192

*.db_domain=''

*.db_name='orcl'

*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'

*.db_recovery_file_dest_size=4070572032

*.diagnostic_dest='/u01/app/oracle'

*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'

*.log_archive_format='%t_%s_%r.dbf'

*.memory_target=524288000

*.nls_date_format='YYYY-MM-DD HH24:mi:ss'

*.open_cursors=300

*.processes=1500

*.remote_login_passwordfile='exclusive'

使用以下命令建立三個目錄

mkdir -p /u01/app/oracle/oradata/orcl/

mkdir -p /u01/app/oracle/flash_recovery_area

mkdir -p /u01/app/oracle/admin/orcl/adump

      2.3 使用sqlplus 登入,

   執行create  spfile  from pfile;

        startup  nomount;-----啟動資料庫至nomount狀態,

      2.4 然後另外開啟一個介面(我是使用的crt連線到資料庫做的恢復),執行rman   target /  命令透過nub恢復控制檔案,(在執行命令以前一定要源端庫所在的主機上執行/usr/openv/netbackup/bin/oracle_link把這個db_link建立一下)

        命令如下:    

run {

allocate channel c1 type  'SBT_TAPE';      

SEND 'NB_ORA_SERV=BJV5240-02.nbadongbu.com.cn,NB_ORA_CLIENT=xf01orcl01-dr';

restore controlfile from '/cntrl_7755_1_110';

release channel c1;

}

命令解釋:  

allocate channel c1 type  'SBT_TAPE';--------定義了通道一的恢復型別是 SBT_TAPE(這個意思就是磁帶備份恢復).

SEND 'NB_ORA_SERV=BJV5240-02.nbadongbu.com.cn,NB_ORA_CLIENT=xf01db01-dr'; ---------這個我們恢復控制檔案的時候要去尋找的主機,後面是nbu客戶端的型別,NB_ORA_SERV和,NB_ORA_CLIENT在備份指令碼中都有(指令碼的路徑一般為/usr/openv/netbackup/script),需要和系統管理員確認一下,是不是這臺主機。

restore controlfile from '/cntrl_7755_1_110';--------控制檔名字,需要在源端庫上使用list backupset of  controlfile 查詢控制檔案的名字,需要注意的找full  database的時候的控制檔案的名字。

控制檔案恢復完成。需要執行alter database mount;

      2.5 恢復資料檔案,執行命令

run {

allocate channel t1 type 'sbt_tape';

allocate channel t2 type 'sbt_tape';

allocate channel t3 type 'sbt_tape';

allocate channel t4 type 'sbt_tape';

SEND 'NB_ORA_SERV=BJV5240-02.nbadongbu.com.cn,NB_ORA_CLIENT=xf01orcl01-dr';

set newname for datafile  1 to   '/u01/app/oracle/oradata/orcl/system01.dbf';                                           

set newname for datafile  2 to    '/u01/app/oracle/oradata/orcl/sysaux01.dbf';                                            

set newname for datafile  3 to    '/u01/app/oracle/oradata/orcl/users01.dbf';                                             

set newname for datafile  4 to    '/u01/app/oracle/oradata/orcl/undotbs01.dbf';                                                                                    

restore database;

switch datafile all;

release channel t1;

release channel t2;

release channel t3;

release channel t4;

}

需要注意的是還原路徑/u01/app/oracle/oradata/orcl這個目標端單例項資料庫的路徑。

    2.6 recover database;

RMAN> recover database;

Starting recover at 22-MAR-18

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=1441 instance=orcl device type=sbt_tape

starting media recovery

Oracle Error: 

ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below

ORA-01152: file 1 was not restored from a sufficiently old backup 

ORA-01110: data file 1: '+DATAC110/orcl/datafile/system01.dbf'

RMAN-00571: 

RMAN-00569: ====ERROR MESSAGE STACK FOLLOWS =====

RMAN-00571: 

RMAN-03002: failure of recover command at 03/22/2018 21:56:01

RMAN-06053: unable to perform media recovery because of missing log

RMAN-06102: no channel to restore a backup or copy of archived log for thread 1 with sequence 7469 and starting SCN of 389605961

RMAN-06102: no channel to restore a backup or copy of archived log for thread 2 with sequence 2277 and starting SCN of 389605958

RMAN-06102: no channel to restore a backup or copy of archived log for thread 1 with sequence 7468 and starting SCN of 389557852

RMAN-06102: no channel to restore a backup or copy of archived log for thread 2 with sequence 2276 and starting SCN of 389445397

    2.7 恢復歸檔日誌

RMAN> run {

allocate channel c1 type 'sbt_tape';

allocate channel c2 type 'sbt_tape';

SEND 'NB_ORA_SERV=BJV5240-02.nbadongbu.com.cn,NB_ORA_CLIENT=xf01orcl01-dr';

restore archivelog  sequence between 7468 and 7469 thread 1;

restore archivelog  sequence between 22762 and 2277 thread 2;

release channel c1;

release channel c2;

 恢復的 sequence between 7468 and 7469 thread 1  

       sequence between 22762 and 2277 thread 2;  

歸檔的序列號區間需要執行list backupset of  controlfile;檢視從我們恢復full  database時候的控制檔案中開始的歸檔序列號,結束的歸檔序列為控制檔案中最後顯示的歸檔序列號。執行緒號1是源端rac的節點1,執行緒號2是源端rac的節點2.

    2.8  恢復完成以後,再次執行recover database

RMAN-00571: 

RMAN-00569: === ERROR MESSAGE STACK FOLLOWS ====

RMAN-00571: 

RMAN-03002: failure of recover command at 03/22/2018 21:58:47

RMAN-06054: media recovery requesting unknown archived log for thread 2 with sequence 2278 and starting SCN of 389605979

    2.9   recover database

RMAN> recover database until scn 389605979;

    3.0  開啟資料庫

RMAN> alter database open resetlogs;


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31547066/viewspace-2284385/,如需轉載,請註明出處,否則將追究法律責任。

相關文章