1.显示当前配置
DGMGRL> show configuration;
Configuration - cfgocm1
Protection Mode: MaxPerformance
Databases:
prod1 - Primary database
sbdb1 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
当前备库是物理备库
2.切换到快照
DGMGRL> CONVERT DATABASE sbdb1 to SNAPSHOT STANDBY;
Converting database "sbdb1" to a Snapshot Standby database, please wait...
Database "sbdb1" converted successfully
3.确认已经切换到快照库
查看配置:
DGMGRL> show configuration ;
Configuration - cfgocm1
Protection Mode: MaxPerformance
Databases:
prod1 - Primary database
sbdb1 - Snapshot standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
4.在快照库做dml操作测试
SQL> select name,DATABASE_ROLE,open_mode from v$database;
NAME DATABASE_ROLE OPEN_MODE
--------- ---------------- --------------------
PROD1 SNAPSHOT STANDBY READ WRITE
--建立一张测试表
SQL> create table sztech as select * from all_tables;
Table created.
SQL> select count(*) from sztech;
COUNT(*)
----------
2843
5.由快照库切换回物理备库
语法:
DGMGRL> help convert
Converts a database from one type to another
Syntax:
CONVERT DATABASE <database name> TO
{SNAPSHOT STANDBY|PHYSICAL STANDBY};
DGMGRL> CONVERT DATABASE sbdb1 to PHYSICAL STANDBY;
Converting database "sbdb1" to a Physical Standby database, please wait...
Operation requires shutdown of instance "sbdb1" on database "sbdb1"
Shutting down instance "sbdb1"...
Database closed.
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "sbdb1" on database "sbdb1"
Starting instance "sbdb1"...
ORACLE instance started.
Database mounted.
Continuing to convert database "sbdb1" ...
Operation requires shutdown of instance "sbdb1" on database "sbdb1"
Shutting down instance "sbdb1"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "sbdb1" on database "sbdb1"
Starting instance "sbdb1"...
ORACLE instance started.
Database mounted.
Database "sbdb1" converted successfully
DGMGRL>
6.验证已经切换回物理备库
DGMGRL> show configuration ;
Configuration - cfgocm1
Protection Mode: MaxPerformance
Databases:
prod1 - Primary database
sbdb1 - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
--快照库创建的表,已经不见。
SQL> conn sys/oracle@sbdb1 as sysdba
Connected.
SQL> select name,DATABASE_ROLE,open_mode from v$database;
NAME DATABASE_ROLE OPEN_MODE
--------- ---------------- --------------------
PROD1 PHYSICAL STANDBY READ ONLY WITH APPLY
SQL> select count(*) from sztech;
select count(*) from sztech
*
ERROR at line 1:
ORA-00942: table or view does not exist
到此,使用broker 命令行dgmgrl手工切换快照库并回切到物理备库完成。
|