DG中3种保护模式之间的切换

对于生成当中的数据库,不同公司不同业务需求或者不同时间,对主库与备库的保护模式需求不一样,
这样,就需要 切换主数据库与备用数据库之间 的保护模式。以下是模式之间的 切换过程。

--查看主库的保护模式:
SQL> select open_mode,protection_mode,switchover_status,database_role from v$database;
OPEN_MODE            PROTECTION_MODE      SWITCHOVER_STATUS    DATABASE_ROLE
-------------------- -------------------- -------------------- ----------------
READ WRITE           MAXIMUM PERFORMANCE  TO STANDBY           PRIMARY

--查看备库的保护模式:
SQL> select open_mode,protection_mode,switchover_status,database_role from v$database;
OPEN_MODE            PROTECTION_MODE      SWITCHOVER_STATUS    DATABASE_ROLE
-------------------- -------------------- -------------------- ----------------
READ ONLY            MAXIMUM PERFORMANCE  NOT ALLOWED          PHYSICAL STANDBY

----Data Guard三种保护模块式之间的转换:
--最大性能转换至最大可用:
--关闭主库,重启到mount状态:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  835104768 bytes
Fixed Size                  2257840 bytes
Variable Size             683674704 bytes
Database Buffers          146800640 bytes
Redo Buffers                2371584 bytes
Database mounted.

--在主库修改参数信息:
SQL> alter system set 
  2  LOG_ARCHIVE_DEST_2='SERVICE=PROD LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PROD';
System altered.

--SQL> alter database set standby database to maximize availability;
Database altered.

--打开主库并验证:
SQL> alter database open;
Database altered.

--验证主库:
SQL> select open_mode,protection_mode,switchover_status,database_role from v$database;
OPEN_MODE            PROTECTION_MODE      SWITCHOVER_STATUS    DATABASE_ROLE
-------------------- -------------------- -------------------- ----------------
READ WRITE           MAXIMUM AVAILABILITY TO STANDBY           PRIMARY

--确认备库:
SQL> select open_mode,protection_mode,switchover_status,database_role from v$database;
OPEN_MODE            PROTECTION_MODE      SWITCHOVER_STATUS    DATABASE_ROLE
-------------------- -------------------- -------------------- ----------------
READ ONLY WITH APPLY MAXIMUM AVAILABILITY NOT ALLOWED          PHYSICAL STANDBY
备库也已经把模式改变到最大可用模式。

--将主库与备库调至最大保护模式:
--由于最大保护模式与最大可用模式的重做归档进程、网络传输与磁盘写选项是一样的
--所以可以直接更改模式就可以了,不需要先修改参数信息:

--把主库与备库调至最大保护模式:
--直接修改到maximize protection模式:
SQL> alter database set standby database to maximize protection;
Database altered.
--验证主库:
SQL> select open_mode,protection_mode,switchover_status,database_role from v$database;
OPEN_MODE            PROTECTION_MODE      SWITCHOVER_STATUS    DATABASE_ROLE
-------------------- -------------------- -------------------- ----------------
READ WRITE           MAXIMUM PROTECTION   TO STANDBY           PRIMARY

--确认备库:
SQL> select open_mode,protection_mode,switchover_status,database_role from v$database;
OPEN_MODE            PROTECTION_MODE      SWITCHOVER_STATUS    DATABASE_ROLE
-------------------- -------------------- -------------------- ----------------
READ ONLY WITH APPLY MAXIMUM PROTECTION   NOT ALLOWED          PHYSICAL STANDBY
可以看到主库与备库都调至到最大保护模式。

--把数据库重新调至回到最大性能模式:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  835104768 bytes
Fixed Size                  2257840 bytes
Variable Size             687869008 bytes
Database Buffers          142606336 bytes
Redo Buffers                2371584 bytes
Database mounted.
SQL> 
SQL> alter system set
  2  LOG_ARCHIVE_DEST_2='SERVICE=PROD ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PROD';
System altered.

SQL> alter database set standby database to maximize performance;
Database altered.

--验证主库:
SQL> select open_mode,protection_mode,switchover_status,database_role from v$database;
OPEN_MODE            PROTECTION_MODE      SWITCHOVER_STATUS    DATABASE_ROLE
-------------------- -------------------- -------------------- ----------------
MOUNTED              MAXIMUM PERFORMANCE  NOT ALLOWED          PRIMARY

--确认备库:
SQL> select open_mode,protection_mode,switchover_status,database_role from v$database;
OPEN_MODE            PROTECTION_MODE      SWITCHOVER_STATUS    DATABASE_ROLE
-------------------- -------------------- -------------------- ----------------
MOUNTED              MAXIMUM PERFORMANCE  NOT ALLOWED          PRIMARY

---最后打开主库:
SQL> alter database open;
Database altered.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31392094/viewspace-2126846/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/31392094/viewspace-2126846/

你可能感兴趣的:(DG中3种保护模式之间的切换)