OCP 3月周末班,正在授课 欢迎试听         限时优惠:Oracle认证免费重考优惠         OCM周末班 正在报名 ,欢迎垂询!         MySQL认证周末班 正在招生 欢迎垂询!         RHCE 3月周末班 正在招生 欢迎垂询         2019和思庄一起再创辉煌         

使用broker命令行切换dg快照

更新时间: 2019-03-27 16:38

 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手工切换快照库并回切到物理备库完成。

开班信息MORE>>

课程名称 开课时间 上课类型 状态
RHCE认证 2月 周末班 授课中...
OCP认证 3月 周末班 授课中...
OCP认证 4月 周末班 报名中...
OCM认证 3月 周末班 报名中...
RHCE认证 3月 周末班 报名中...
MySQL认证培训 常年 周末班 报名中...
RAC实用技术 常年 周末、脱产 报名中...
<<