【kingsql分享】將RAC資料庫異機恢復到單例項(Ⅰ)

kingsql發表於2014-11-12

本文將陸續講述如何將一個RAC資料庫,異機恢復到單例項

實驗的大致思路是,備份一個RAC資料庫,把RMAN備份集複製到一個單機,然後透過RMAN做異機恢復,恢復成單例項資料庫

本實驗的意義在於,當只剩下一個節點或者資料庫全癱瘓的狀態下,應急恢復業務

1.建立測試使用者

建立一個使用者hongzhuohui,賦予DBA許可權,用於建立測試表

SYS@testora2%10gR2> create user hongzhuohui identified by oracle;
 
User created.
 
SYS@testora2%10gR2> grant dba to hongzhuohui;
 
Grant succeeded.

2.檢視例項名

登入第二個節點的資料庫,檢視例項名為testora2,那麼資料庫名其實是testora

SYS@testora2%10gR2> select instance_name from v$instance;
 
INSTANCE_NAME
----------------
testora2

3.建立測試表

在hongzhuohui使用者裡建立測試表,那麼做全備份之後,恢復之後,如果資料庫裡有這個表,則證明實驗成功

SYS@testora2%10gR2> conn hongzhuohui/oracle
Connected.
SYS@testora2%10gR2> create table test001 (x int); 
 
Table created.
 
SYS@testora2%10gR2> insert into test001 values (99);
 
1 row created.
 
SYS@testora2%10gR2> commit;
 
Commit complete.
 
SYS@testora2%10gR2> select * from test001;
 
         X
----------
        99
 
SYS@testora2%10gR2> show user;
USER is "hongzhuohui"
 
4.備份資料庫

對testora2做全備份,記錄資料庫DBID 676818789使用者恢復

[oracle@rac2 ~]$ rman target /
 
Recovery Manager: Release 10.2.0.1.0 - Production on Sun Nov 9 22:18:58 2014
 
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
 
connected to target database: TESTORA (DBID=676818789)
 
RMAN> run
{
allocate channel d1 type disk maxpiecesize 4000m ;
backup as compressed backupset incremental level = 0 database
format '/home/oracle/xpg/db_%d_%s_%p_%T'
plus archivelog skip inaccessible delete all input
format '/home/oracle/xpg/log_%d_%s_%p_%T';
SYS@testora2%10gR2 'alter system archive log current';
release channel d1;
}2> 3> 4> 5> 6> 7> 8> 9> 10> 
 
using target database control file instead of recovery catalog
allocated channel: d1
channel d1: sid=141 instance=testora2 devtype=DISK
 
 
Starting backup at 09-NOV-14
current log archived
channel d1: starting compressed archive log backupset
channel d1: specifying archive log(s) in backup set
input archive log thread=1 sequence=42 recid=27 stamp=863192962
input archive log thread=1 sequence=43 recid=30 stamp=863216434
input archive log thread=2 sequence=15 recid=28 stamp=863192967
input archive log thread=2 sequence=16 recid=29 stamp=863216065
input archive log thread=2 sequence=17 recid=31 stamp=863216438
channel d1: starting piece 1 at 09-NOV-14
channel d1: finished piece 1 at 09-NOV-14
piece handle=/home/oracle/xpg/log_TESTORA_5_1_20141109 tag=TAG20141109T222038 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:02
channel d1: deleting archive log(s)
archive log filename=+DATA/testora/1_42_854718629.dbf recid=27 stamp=863192962
archive log filename=+DATA/testora/1_43_854718629.dbf recid=30 stamp=863216434
archive log filename=+DATA/testora/2_15_854718629.dbf recid=28 stamp=863192967
archive log filename=+DATA/testora/2_16_854718629.dbf recid=29 stamp=863216065
archive log filename=+DATA/testora/2_17_854718629.dbf recid=31 stamp=863216438
Finished backup at 09-NOV-14
 
Starting backup at 09-NOV-14
channel d1: starting compressed incremental level 0 datafile backupset
channel d1: specifying datafile(s) in backupset
input datafile fno=00001 name=+DATA/testora/datafile/system.259.854718649
input datafile fno=00002 name=+DATA/testora/datafile/undotbs1.260.854718659
input datafile fno=00003 name=+DATA/testora/datafile/sysaux.261.854718665
input datafile fno=00004 name=+DATA/testora/datafile/undotbs2.263.854718673
input datafile fno=00005 name=+DATA/testora/datafile/users.264.854718679
channel d1: starting piece 1 at 09-NOV-14
channel d1: finished piece 1 at 09-NOV-14
piece handle=/home/oracle/xpg/db_TESTORA_6_1_20141109 tag=TAG20141109T222042 comment=NONE
channel d1: backup set complete, elapsed time: 00:01:05
channel d1: starting compressed incremental level 0 datafile backupset
channel d1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel d1: starting piece 1 at 09-NOV-14
channel d1: finished piece 1 at 09-NOV-14
piece handle=/home/oracle/xpg/db_TESTORA_7_1_20141109 tag=TAG20141109T222042 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:05
Finished backup at 09-NOV-14
 
Starting backup at 09-NOV-14
current log archived
channel d1: starting compressed archive log backupset
channel d1: specifying archive log(s) in backup set
input archive log thread=1 sequence=44 recid=32 stamp=863216513
input archive log thread=2 sequence=18 recid=33 stamp=863216513
channel d1: starting piece 1 at 09-NOV-14
channel d1: finished piece 1 at 09-NOV-14
piece handle=/home/oracle/xpg/log_TESTORA_8_1_20141109 tag=TAG20141109T222153 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:02
channel d1: deleting archive log(s)
archive log filename=+DATA/testora/1_44_854718629.dbf recid=32 stamp=863216513
archive log filename=+DATA/testora/2_18_854718629.dbf recid=33 stamp=863216513
Finished backup at 09-NOV-14
 
SQL statement: alter system archive log current
 
released channel: d1

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
我的QQ 1749160152
我的郵箱 hongzhuohui@kingsql.com
我的百科 洪卓輝
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


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

相關文章