使用rman建立standby database的過程

tolywang發表於2007-12-06
Standby database 在中小型企業中有它的一席之地,是容災的一個比較好的方式。建立standby databse有幾種方式,例如冷備份的建立,熱備份的建立,這個只是討論rman的方法建立。

環境:
Win2000+oracle8.1.7.4
Primary DB :138.198.197.75
Standby DB :10.93.13.22
(和 Primary有相同的的目錄)

為了方便測試,在STANDBY的主機上安裝ORACLE,並建立一個和PRODUCT計算機上相同名字的資料庫,在product database上修改tnsnames.ora,增加standby的連通性。
TAN9030.SZS.ST.COM =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 138.198.197.75)(PORT = 1530))
(CONNECT_DATA =
(SID = TEST)
)
)

STANDBY.SZS.ST.COM =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.93.13.22)(PORT = 1521))
(CONNECT_DATA =
(SID = TEST)
)
)
然後shutdown 這個standby資料庫,刪除掉資料檔案/redo檔案/控制檔案/初始化引數/
/密碼檔案/ 以便測試。

1. 把init.ora pfile檔案從product PC copy 到 standby PC.
2. Rman 建立在tan9030上
目標資料庫是tan9030
auxiliary 資料庫是standby.

3.備份prodcut database by rman.
C:>rman
Rman> connect catalog rman/rman@tan9030
Connect target system/system@tan9030
run {
allocate channel d1 type disk;
allocate channel d2 type disk;
setlimit channel d1 kbytes 2097150;
setlimit channel d2 kbytes 2097150;
backup incremental level 0 format '/beta/home/marrocha/backup/df_%U' database
include current controlfile for standby;
sql "alter system archive log current";
backup
archivelog all format '/beta/home/marrocha/backup/al_%U' delete input;
}
4.copy所有的備份集到standby pc 的相同目錄下(一定要相同)。
5.建立standby database by rman
C:>rman
Recovery Manager: Release 8.1.7.0.0 - Production
RMAN> connect catalog rman/rman@tan9030
RMAN-06008: connected to recovery catalog database
RMAN> connect target system/system@tan9030
RMAN-06005: connected to target database: TEST (DBID=2075906292)
RMAN> connect auxiliary sys/sys@standby
RMAN-06020: connected to auxiliary database
RMAN> run {
2> # set command id to 'standby';
3> # set until time "to_date('22-JUL-2000 15:34:38,'DD-MON-YYYY HH24:MI:SS')";
4> allocate auxiliary channel dup1 type disk;
5> allocate auxiliary channel dup2 type disk;
6> set newname for datafile 1 to 'D:ORACLEORADATATESTSYSTEM01.DBF';
7> set newname for datafile 2 to 'D:ORACLEORADATATESTRBS01.DBF';
8> set newname for datafile 3 to 'D:ORACLEORADATATESTUSERS01.DBF';
9> set newname for datafile 4 to 'D:ORACLEORADATATESTTEMP01.DBF';
10> set newname for datafile 5 to 'D:ORACLEORADATATESTTOOLS.DBF';
11> set newname for datafile 6 to 'D:ORACLEORADATATESTINDX01.DBF';
12> set newname for datafile 7 to 'D:ORACLEORADATATESTDATA_01.DBF';
13> set newname for datafile 8 to 'D:ORACLEORADATATESTRMAN_TS_01.ORA';
14> set newname for datafile 27 to 'D:ORACLEORADATATESTRBS02.DBF';
15> duplicate target database for standby
16> dorecover
17> nofilenamecheck;
18> }

RMAN-03022: compiling command: allocate
RMAN-03023: executing command: allocate
RMAN-08030: allocated channel: dup1
RMAN-08500: channel dup1: sid=15 devtype=DISK
RMAN-03022: compiling command: allocate
RMAN-03023: executing command: allocate
RMAN-08030: allocated channel: dup2
RMAN-08500: channel dup2: sid=16 devtype=DISK
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: Duplicate Db
RMAN-03027: printing stored script: Memory Script
{
restore clone standby controlfile to clone_cf;
replicate clone controlfile from clone_cf;
sql clone 'alter database mount standby database';
}
RMAN-03021: executing script: Memory Script
RMAN-03022: compiling command: restore
RMAN-03022: compiling command: IRESTORE
RMAN-03023: executing command: IRESTORE
RMAN-08016: channel dup1: starting datafile backupset restore
RMAN-08502: set_count=4 set_stamp=530381070 creation_time=2004-07-01:16:04:30
RMAN-08021: channel dup1: restoring controlfile
RMAN-08505: output filename=D:ORACLEORADATATESTCONTROL01.CTL
RMAN-08023: channel dup1: restored backup piece 1
RMAN-08511: piece handle=D:LOCAL_BKDF_04FPPU8E tag=null params=NULL
RMAN-08024: channel dup1: restore complete

RMAN-03022: compiling command: replicate
RMAN-03023: executing command: replicate
RMAN-08058: replicating controlfile
RMAN-08506: input filename=D:ORACLEORADATATESTCONTROL01.CTL
RMAN-08505: output filename=D:ORACLEORADATATESTCONTROL02.CTL
RMAN-08505: output filename=D:ORACLEORADATATESTCONTROL03.CTL

RMAN-03022: compiling command: sql
RMAN-06162: sql statement: alter database mount standby database
RMAN-03023: executing command: sql

RMAN-03027: printing stored script: Memory Script
{
set until scn 18610075639;
set newname for datafile 1 to
"D:ORACLEORADATATESTSYSTEM01.DBF";
set newname for datafile 2 to
"D:ORACLEORADATATESTRBS01.DBF";
set newname for datafile 3 to
"D:ORACLEORADATATESTUSERS01.DBF";
set newname for datafile 4 to
"D:ORACLEORADATATESTTEMP01.DBF";
set newname for datafile 5 to
"D:ORACLEORADATATESTTOOLS.DBF";
set newname for datafile 6 to
"D:ORACLEORADATATESTINDX01.DBF";
set newname for datafile 7 to
"D:ORACLEORADATATESTDATA_01.DBF";
set newname for datafile 8 to
"D:ORACLEORADATATESTRMAN_TS_01.ORA";
set newname for datafile 27 to
"D:ORACLEORADATATESTRBS02.DBF";
restore
check readonly
clone database
;
}
RMAN-03021: executing script: Memory Script

RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: set
RMAN-03022: compiling command: restore
RMAN-03022: compiling command: IRESTORE
RMAN-03023: executing command: IRESTORE
RMAN-08016: channel dup1: starting datafile backupset restore
RMAN-08502: set_count=4 set_stamp=530381070 creation_time=2004-07-01:16:04:30
RMAN-08089: channel dup1: specifying datafile(s) to restore from backup set
RMAN-08523: restoring datafile 00001 to D:ORACLEORADATATESTSYSTEM01.DBF
RMAN-08523: restoring datafile 00002 to D:ORACLEORADATATESTRBS01.DBF
RMAN-08523: restoring datafile 00006 to D:ORACLEORADATATESTINDX01.DBF
RMAN-08523: restoring datafile 00027 to D:ORACLEORADATATESTRBS02.DBF
RMAN-08016: channel dup2: starting datafile backupset restore
RMAN-08502: set_count=5 set_stamp=530381071 creation_time=2004-07-01:16:04:31
RMAN-08089: channel dup2: specifying datafile(s) to restore from backup set
RMAN-08523: restoring datafile 00003 to D:ORACLEORADATATESTUSERS01.DBF
RMAN-08523: restoring datafile 00004 to D:ORACLEORADATATESTTEMP01.DBF
RMAN-08523: restoring datafile 00005 to D:ORACLEORADATATESTTOOLS.DBF
RMAN-08523: restoring datafile 00007 to D:ORACLEORADATATESTDATA_01.DBF
RMAN-08523: restoring datafile 00008 to D:ORACLEORADATATESTRMAN_TS_01.ORA
RMAN-08023: channel dup2: restored backup piece 1
RMAN-08511: piece handle=D:LOCAL_BKDF_05FPPU8F tag=null params=NULL
RMAN-08024: channel dup2: restore complete
RMAN-08023: channel dup1: restored backup piece 1
RMAN-08511: piece handle=D:LOCAL_BKDF_04FPPU8E tag=null params=NULL
RMAN-08024: channel dup1: restore complete

RMAN-03027: printing stored script: Memory Script
{
switch clone datafile all;
}
RMAN-03021: executing script: Memory Script

RMAN-03022: compiling command: switch
RMAN-03023: executing command: switch
RMAN-08015: datafile 5 switched to datafile copy
RMAN-08507: input datafilecopy recid=10 stamp=530440460 filename=D:ORACLEORADA
TATESTTOOLS.DBF
RMAN-08015: datafile 7 switched to datafile copy
RMAN-08507: input datafilecopy recid=11 stamp=530440461 filename=D:ORACLEORADA
TATESTDATA_01.DBF
RMAN-08015: datafile 8 switched to datafile copy
RMAN-08507: input datafilecopy recid=12 stamp=530440461 filename=D:ORACLEORADA
TATESTRMAN_TS_01.ORA
RMAN-08015: datafile 27 switched to datafile copy
RMAN-08507: input datafilecopy recid=13 stamp=530440461 filename=D:ORACLEORADA
TATESTRBS02.DBF

RMAN-03027: printing stored script: Memory Script
{
set until scn 18610075639;
recover
standby
clone database
check readonly
;
}
RMAN-03021: executing script: Memory Script
RMAN-03022: compiling command: set
RMAN-03022: compiling command: recover
RMAN-03022: compiling command: recover(1)
RMAN-03022: compiling command: recover(2)
RMAN-03022: compiling command: recover(3)
RMAN-03023: executing command: recover(3)
RMAN-08054: starting media recovery
RMAN-03022: compiling command: recover(4)
RMAN-03023: executing command: recover(4)
RMAN-08017: channel dup1: starting archivelog restore to default destination
RMAN-08022: channel dup1: restoring archivelog
RMAN-08510: archivelog thread=1 sequence=1556
RMAN-08023: channel dup1: restored backup piece 1
RMAN-08511: piece handle=D:LOCAL_BKAL_08FPPUG4 tag=null params=NULL
RMAN-08024: channel dup1: restore complete
RMAN-08515: archivelog filename=D:ORACLEORADATATESTARCHIVETESTT001S0155
6.ARC thread=1 sequence=1556
RMAN-08055: media recovery complete
RMAN-08031: released channel: dup1
RMAN-08031: released channel: dup2

RMAN>
6.關於step5的說明
a. connect auxiliary sys/sys@standby
這裡我遇到了問題,剛開始的時候出現了找不到密碼檔案,我重新建立了這個檔案
orapwd file=d:oracleora81databasePWDTEST.ora password=sys entires=5

b.這樣做standby database 一定要用nofilenamecheck引數,解決了檔案衝突的問題。
多謝piner的指導。
7.日常維護
1). copy archived log from product database to standby database.
2). Startup nomout
alter database mount standby database;
Recover standby database;
auto
3).啟用standby
alter database activate standby database;
4).開啟standby database
alter database open.
或者
shutdown;
startup;

http://www.itpub.net/238631.html

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

相關文章