分类: Oracle
2008-05-14 11:08:30
来源:赛迪网 作者:Alice |
4. 测试
◆4.1 在主库测试alter system switch logfile;看是否能够顺利切出logfile,备库上是否有arch传输过来。
◆4.2 测试switchover
◆4.2.1 在主库将primary切换到physical standby:
sys@ORALOCAL(192.168.0.11)> alter database commit
to switchover to physical standby with session shutdown;
数据库已更改。
sys@ORALOCAL(192.168.0.11)> shutdown immediate;
ORA-01507: 未安装数据库
ORACLE 例程已经关闭。
sys@ORALOCAL(192.168.0.11)> startup nomount;
ORACLE 例程已经启动。
Total System Global Area 139533192 bytes
Fixed Size 453512 bytes
Variable Size 109051904 bytes
Database Buffers 29360128 bytes
Redo Buffers 667648 bytes
sys@ORALOCAL(192.168.0.11)> alter database mount standby database;
数据库已更改。
已用时间: 00: 00: 04.08
sys@ORALOCAL(192.168.0.11)> alter database
recover managed standby database disconnect from session;
数据库已更改。
◆4.2.2 在备库,switchover到primary:
> alter database commit to switchover to primary;
Database altered.
Elapsed: 00:00:08.03
> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
>
> startup
ORACLE instance started.
Total System Global Area 139533192 bytes
Fixed Size 453512 bytes
Variable Size 109051904 bytes
Database Buffers 29360128 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
◆4.2.3 将主库和备库的tnsnames文件中的standby数据库和primary数据库的IP交换:
############# TNS FILE OF TEST DATA GUARD DATABASE #########################################
standby =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.12)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER=DEDICATED)
(SERVICE_NAME = oralocal)
)
)
primary =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.11)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER=DEDICATED)
(SERVICE_NAME = oralocal)
)
)
5. 切换后测试能否正常switch logfile
6. 切换回去主备
7.关于failover
当主库已经挂掉,不能将主库switchover成备库时,我们将把备库failover成主库(一旦实施failover,就不能将切成主库的备库再次还原成备库)
◆7.1.正常情况下的failover
alter database recover managed standby database finish;
or
alter database recover managed standby database finish skip standby logfile;
alter database commit to switchover to primary;
shutdown immediate;
startup;
◆7.2.提示需要介质恢复,采用硬激活standby数据库,该方法将可能丢失一个redolog的数据:
alter database recover managed standby database finish skip standby logfile;
alter database activate standby database;
shutdown immediate;
startup;
注意点:
A) 在1.2步,如果安装完软件,建立了服务,但是没有改注册表或者set oracle_sid=XXXX,在sqlplus登录的时候会报TNS的错。
B)在2.3步,primary和standby如果在不同主机上,须将rman的backup set拷贝到备机,不然会报错:
通道 ORA_AUX_DISK_1: 正在开始恢复数据文件备份集
通道 ORA_AUX_DISK_1: 正在恢复控制文件
输出文件名=D:\ORACLE\CONTROL_FILES\ORALOCAL\CONTROL01.CTL
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 10/18/2007 23:10:33
RMAN-03015: error occurred in stored script Memory Script
ORA-19505: 无法识别文件"D:\BACK UP\DB BAK\RMAN_BK\FOR_STANDBY_0IIUR7ME118.RMN"
ORA-27041: 无法打开文件
OSD-04002: 无法打开文件
O/S-Error: (OS 2) 系统找不到指定的文件。
C)在2.4步,如果不加nofilenamecheck参数会有以下报错:
sql 语句: alter database mount standby database
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 10/18/2007 22:38:40
RMAN-05501: aborting duplication of target database
RMAN-05001: auxiliary filename
D:\ORACLE\ORADATA\ORALOCAL\TS_DATA_DYNAMIC_02.DBF conflicts with a file used by the target database
RMAN-05001: auxiliary filename
D:\ORACLE\ORADATA\ORALOCAL\TS_INDEX_DYNAMIC.DBF conflicts with a file used by the target database
RMAN-05001: auxiliary filename
D:\ORACLE\ORADATA\ORALOCAL\TS_INDEX_HISTORY.DBF conflicts with a file used by the target database
RMAN-05001: auxiliary filename
D:\ORACLE\ORADATA\ORALOCAL\TS_DATA_ADMIN.DBF conflicts with a file used by the target database
RMAN-05001: auxiliary filename
D:\ORACLE\ORADATA\ORALOCAL\TS_DATA_CDR.DBF conflicts with a file used by the target database
RMAN-05001: auxiliary filename D:\ORACLE\ORADATA\ORALOCAL\TS_DATA_DYNAMIC.DBF conflicts with a file used by the target database
RMAN-05001: auxiliary filename
D:\ORACLE\ORADATA\ORALOCAL\TS_DATA_HIS01.DBF conflicts with a file used by the target database
RMAN-05001: auxiliary filename
D:\ORACLE\ORADATA\ORALOCAL\TS_DATA_HISTORY.DBF conflicts with a file used by the target database
RMAN-05001: auxiliary filename
D:\ORACLE\ORADATA\ORALOCAL\TS_DATA_PORTAL.DBF conflicts with a file used by the target database
RMAN-05001: auxiliary filename
D:\ORACLE\ORADATA\ORALOCAL\TS_DATA_RPT.DBF conflicts with a file used by the target database
RMAN-05001: auxiliary filename
D:\ORACLE\ORADATA\ORALOCAL\TS_DATA_RPT01.DBF conflicts with a file used by the target database
RMAN-05001: auxiliary filename
D:\ORACLE\ORADATA\ORALOCAL\TS_DATA_RPT02.DBF conflicts with a file used by the target database
RMAN-05001: auxiliary filename
D:\ORACLE\ORADATA\ORALOCAL\TS_DATA_RPT03.DBF conflicts with a file used by the target database
注:备机上的redolog,是在备机switchover切换到主机是生成,就是在4.2.2步中的alter database commit to switchover to primary中生成。 |