八、更改物理备库为最大可用或最大保护模式
前面建立的备库默认是最大性能模式,一般都设置成最大可用性模式,如果备库发生问题,主库会自动降级为最大性能模式,对主库不会有影响。
8.1 备库配置standby redolog(vmtwo)
SQL> recover managed standby database cancel;
SQL> alter database add standby logfile
group 4 ('/orahome/oradata/PHYSTDBY/stdby_redo04.log') size 50m,
group 5 ('/orahome/oradata/PHYSTDBY/stdby_redo05.log') size 50m,
group 6 ('/orahome/oradata/PHYSTDBY/stdby_redo06.log') size 50m,
group 7 ('/orahome/oradata/PHYSTDBY/stdby_redo07.log') size 50m;
standby redolog的组数参考公式:(online redolog组数 + 1) * 数据库线程数;单机线程数为1,RAC一般为2。
standby redolog的组成员数和大小也尽量和online redolog一样。
SQL> recover managed standby database disconnect;
8.2 备库配置standby redolog(vmthree)
SQL> recover managed standby database cancel;
SQL> alter database add standby logfile
group 4 ('/orahome/oradata/LOGSTDBY/stdby_redo04.log') size 50m,
group 5 ('/orahome/oradata/LOGSTDBY/stdby_redo05.log') size 50m,
group 6 ('/orahome/oradata/LOGSTDBY/stdby_redo06.log') size 50m,
group 7 ('/orahome/oradata/LOGSTDBY/stdby_redo07.log') size 50m;
SQL> recover managed standby database disconnect;
8.3 修改主库远程归档目的地的属性为同步传送和同步写磁盘(vmone)
需设置log_archive_dest_2/3为联机日志方式(LGWR)同步(SYNC)传送日志,并且同步写磁盘(AFFIRM),为了防止备库发生网络故障引发主库挂起还设置每隔一小时重新传送失败的日志(REOPEN=3600)。
SQL> alter system set log_archive_dest_2='SERVICE=db_phystdby LGWR SYNC AFFIRM REOPEN=1800 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PHYSTDBY' scope=both;
SQL> alter system set log_archive_dest_3='SERVICE=db_logstdby LGWR SYNC AFFIRM REOPEN=1800 VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=LOGSTDBY' scope=both;
8.4 更改主库为最大保护模式(vmone)
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database set standby database to maximize protection;
提示:maximize 后可跟{PROTECTION | AVAILABILITY | PERFORMANCE},分别对应最大保护,最高可用性及最高性能。
SQL> alter database open;
8.5 更改后主备库日志应用测试
主库一(vmone):
SQL> select name,database_role,db_unique_name,open_mode,protection_mode,protection_level,switchover_status,supplemental_log_data_pk,supplemental_log_data_ui from v$database;
NAME DATABASE_ROLE DB_UNIQUE_NAME OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL SWITCHOVER_STATUS SUP SUP
-------- ---------------- ------------------------------ ---------- -------------------- -------------------- -------------------- --- ---
ORCLDB PRIMARY WENDING READ WRITE MAXIMUM PROTECTION MAXIMUM PROTECTION SESSIONS ACTIVE NO NO
SQL> create table u_test.t_test2 as select * from dba_users;
此时发现消耗时间明显加长,因为它要保证两个备库同时也提交了该操作才算完成了当前事务。
物理备库一(vmtwo):
SQL> select name,database_role,db_unique_name,open_mode,protection_mode,protection_level,switchover_status,supplemental_log_data_pk,supplemental_log_data_ui from v$database;
NAME DATABASE_ROLE DB_UNIQUE_NAME OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL SWITCHOVER_STATUS SUP SUP
-------- ---------------- ------------------------------ ---------- -------------------- -------------------- -------------------- --- ---
ORCLDB PHYSICAL STANDBY PHYSTDBY MOUNTED MAXIMUM PROTECTION MAXIMUM PROTECTION NOT ALLOWED NO NO
物理备库二(vmthree):
SQL> select name,database_role,db_unique_name,open_mode,protection_mode,protection_level,switchover_status,supplemental_log_data_pk,supplemental_log_data_ui from v$database;
NAME DATABASE_ROLE DB_UNIQUE_NAME OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL SWITCHOVER_STATUS SUP SUP
-------- ---------------- ------------------------------ ---------- -------------------- -------------------- -------------------- --- ---
ORCLDB PHYSICAL STANDBY LOGSTDBY MOUNTED MAXIMUM PROTECTION MAXIMUM PROTECTION NOT ALLOWED NO NO
现在备库不能shutdown数据库,除非shutdown abort:
SQL> shutdown immediate;
ORA-01154: 数据库忙。现在不允许打开, 关闭, 装载和卸载
后续再修改为maximize availability或maximize performance模式可以在数据库open状态下随时修改,但修改为maximize protection模式则必需在mount状态下修改。
SQL> alter database set standby database to maximize performance;
SQL> alter database set standby database to maximize availability;
最终测试发现,是可以随时修改,但是没有得到想要的效果,晕!!!
--End--
from:http://hi.baidu.com/edeed/blog/item/6c7db600a9c32080e950cd18.html