这篇文章主要讨论DG环境下如何切换保护级别。
数据库环境是linux as4 +10gr2。
一、最大性能到最大可用
1、检查当前主备库的保护模式
--主库
SQL> SELECT PROTECTION_MODE,PROTECTION_LEVEL FROM V$DATABASE;
PROTECTION_MODE PROTECTION_LEVEL
-------------------- --------------------
MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE
--备库
SQL> SELECT PROTECTION_MODE,PROTECTION_LEVEL FROM V$DATABASE;
PROTECTION_MODE PROTECTION_LEVEL
-------------------- --------------------
MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE
2、修改主库的相关参数
1)重启到mount状态
SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP MOUNT
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1260696 bytes
Variable Size 75498344 bytes
Database Buffers 88080384 bytes
Redo Buffers 2932736 bytes
Database mounted.
2)修改参数
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=standby LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby';
System altered.
3)切换到最大可用模式
SQL> ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE AVAILABILITY;
Database altered.
4)打开主库
SQL> ALTER DATABASE OPEN;
Database altered.
3、验证此时主备库的保护模式
--主库
SQL> SELECT PROTECTION_MODE,PROTECTION_LEVEL FROM V$DATABASE;
PROTECTION_MODE PROTECTION_LEVEL
-------------------- --------------------
MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY
--备库
SQL> SELECT PROTECTION_MODE,PROTECTION_LEVEL FROM V$DATABASE;
PROTECTION_MODE PROTECTION_LEVEL
-------------------- --------------------
MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY
4、修改备库的相关参数
这一步可以省略,但为了以后的switch over方便,最好也修改了
在备库执行:
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=primary LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=primary';
System altered.
至此,就完成了DG从最大性能模式到最大可用模式的转换。