实验DG Snapshot Standby



备库切换为SnapshotStandby

备机的状态

SQL> select DB_UNIQUE_NAME,NAME,database_role,open_mode from v$database;

DB_UNIQUE_NAME                 NAME      DATABASE_ROLE    OPEN_MODE
------------------------------ --------- ---------------- --------------------
newcdbdg                       NEWCDB    PHYSICAL STANDBY READ ONLY WITH APPLY
备库切换为Snapshot Standby

DGMGRL> CONVERT DATABASE newcdbdg to SNAPSHOT STANDBY;
Converting database "newcdbdg" to a Snapshot Standby database, please wait...
Error: ORA-38786: Recovery area is not enabled.

Failed.
Failed to convert database "newcdbdg"
一个报错,原因是备库需要启用recover area
SQL> alter system set db_recovery_file_dest_size=2g;
System altered.

SQL> alter system set db_recovery_file_dest='/arch/recovery';
System altered.
备库再次切换为Snapshot Standby
DGMGRL> CONVERT DATABASE newcdbdg to SNAPSHOT STANDBY;
Converting database "newcdbdg" to a Snapshot Standby database, please wait...
Database "newcdbdg" converted successfully
DGMGRL> SHOW CONFIGURATION;

Configuration - dg_newcdb

  Protection Mode: MaxPerformance
  Members:
  newcdb   - Primary database
    newcdbdg - Snapshot standby database 

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 6 seconds ago)
备库可以读写
SQL> select DB_UNIQUE_NAME,NAME,database_role,open_mode from v$database;

DB_UNIQUE_NAME                 NAME      DATABASE_ROLE    OPEN_MODE
------------------------------ --------- ---------------- --------------------
newcdbdg                       NEWCDB    SNAPSHOT STANDBY READ WRITE
测试备库写入
SQL> create table test as select * from dba_objects;
Table created.

SQL> select count(*) from test;
  COUNT(*)
----------
     72658

备库切换回PhysicalStandby

DGMGRL> CONVERT DATABASE newcdbdg to PHYSICAL STANDBY;
Converting database "newcdbdg" to a Physical Standby database, please wait...
Operation requires shut down of instance "newcdb" on database "newcdbdg"
Shutting down instance "newcdb"...
Unable to connect to database using (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.16.130)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=newcdbdg_DGMGRL)(INSTANCE_NAME=newcdb)(SERVER=DEDICATED)))
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

Failed.
Warning: You are no longer connected to ORACLE.

Please complete the following steps and reissue the CONVERT command:
        shut down instance "newcdb" of database "newcdbdg"
        start up and mount instance "newcdb" of database "newcdbdg"

又一个报错,原因是备库需要重启到mount状态再切换回Physical Standby
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  838860800 bytes
Fixed Size                  8798312 bytes
Variable Size             322965400 bytes
Database Buffers          503316480 bytes
Redo Buffers                3780608 bytes
Database mounted.
DGMGRL> CONVERT DATABASE newcdbdg to PHYSICAL STANDBY;
Converting database "newcdbdg" to a Physical Standby database, please wait...
Database "newcdbdg" converted successfully

DGMGRL> SHOW CONFIGURATION;

Configuration - dg_newcdb

  Protection Mode: MaxPerformance
  Members:
  newcdb   - Primary database
    newcdbdg - Physical standby database 

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 29 seconds ago)

DGMGRL> show database newcdbdg;

Database - newcdbdg

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      0 seconds (computed 0 seconds ago)
  Apply Lag:          0 seconds (computed 0 seconds ago)
  Average Apply Rate: 8.00 KByte/s
  Real Time Query:    ON
  Instance(s):
    newcdb

Database Status:
SUCCESS

SQL> show pdbs;  

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 DGPDB1                         READ ONLY  NO
         4 DGPDB2                         READ ONLY  NO
         5 DGPDB3                         READ ONLY  NO
也可以使用以下SQL命令切换
Alter database  convert to snapshot standby;
alter database convert to physical standby;


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值