ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 使用rman建立standby database的过程

使用rman建立standby database的过程

原创 Linux操作系统 作者:tolywang 时间:2007-12-06 00:00:00 0 删除 编辑
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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle , MySQL, SAP IQ, SAP HANA, PostgreSQL, Tableau 技术讨论,希望在这里一起分享知识,讨论技术,畅谈人生 。

注册时间:2007-12-10

  • 博文量
    5595
  • 访问量
    13205725