RHCE9 1月周末班 正在授课 欢迎试学         2026!志存高远,启航新程         锁定 2026年首 OCP 周末班,以 ORACLE 为基,其他数据库         KCP金仓数据库认证专家         19cOCP 9月周末班 正在授课 欢迎试听         Oracle,Redhat暑假班学习计划         RHCA培训+认证,助同学们实现梦想         PostgreSQL 高级认证考试         PostgreSQL 中级认证考试(DBA 方向)         PostgreSQL 初级认证考试         

使用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>>

课程名称 开课时间 上课类型 状态
PGCE 专家 1月 周末班 授课中...
OCP认证培训 1月 周末班 授课中...
RHCE培训 1月 周末班 授课中...
OCP培训 3月 精英班 报名中...
OCM培训 3月 周末班 报名中...
RHCE培训 常年 周末班 报名中...
MySQL培训 常年 周末班 报名中...
<<