一、設置
1、設置broker
2、在主庫上操作
DGMGRL> help
DGMGRL> help create
DGMGRL> CREATE CONFIGURATION c1 AS PRIMARY DATABASE IS PROD1 CONNECT IDENTIFIER IS PROD1;
DGMGRL> help add
DGMGRL> ADD DATABASE DG AS CONNECT IDENTIFIER IS DG;
DGMGRL> help enable
DGMGRL> ENABLE CONFIGURATION;
DGMGRL> help show
DGMGRL> SHOW CONFIGURATION;
SQL> startup open read only;
最好加一下read only,因為有時broker有時會把它拉回到mount狀態!!!
SQL> select open_mode from v$database;
OPEN_MODE
SQL> select flashback_on from v$database;
FLASHBACK_ON
SQL> show parameter recovery
NAME TYPE VALUE
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database flashback on;
二、snapshot
1、主庫
DGMGRL> help convert
DGMGRL> CONVERT DATABASE DG TO SNAPSHOT STANDBY; ---如果這裡有失敗可能是監聽DG_DGMGRL沒設
DGMGRL> SHOW CONFIGURATION;
2、備庫
Table created.
SQL> insert into t1 values(1,'AAAA');
1 row created.
SQL> commit;
Commit complete.
三、還原到物理備庫
1、主庫
DGMGRL> CONVERT DATABASE DG TO PHYSICAL STANDBY; ---如果這裡有失敗可能是監聽DG_DGMGRL沒設
四、來回切換庫
1、在主庫PROD1上操作
Configuration
Fast-Start Failover: DISABLED
Current status for "c1":
DGMGRL> help switch
Switch roles between the primary database and a standby database
Syntax:
SWITCHOVER TO <standby database name>;
DGMGRL> SWITCHOVER TO DG;
Database dismounted.
DGMGRL> SHOW CONFIGURATION
Configuration
Fast-Start Failover: DISABLED
Current status for "c1":
DGMGRL> SWITCHOVER TO PROD1
Database dismounted.
五、修改傳輸模式
DGMGRL> SHOW DATABASE VERBOSE PROD1
DGMGRL> help edit
DGMGRL> EDIT DATABASE PROD1 SET PROPERTY LogXptMode=SYNC; ---主庫
Failed.
DGMGRL> EDIT DATABASE PROD1 SET PROPERTY LogXptMode=SYNC; ---主庫
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability; ---主庫
以上Error: ORA-16627: 錯誤馬上消失。。。。
++++備庫的一些基本命令可以記下:
Database altered.
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database open;
Database altered.
六、故障切換
1、主庫
DGMGRL> ENABLE FAST_START FAILOVER;
2、備庫
DGMGRL> help start
DGMGRL> START OBSERVER
3、主庫
4、備庫
17:05:29.04 Friday, November 21, 2014
(2)stop observer(觀察到上面的信息就停止掉,以防來回切換)
5、主庫
SQL*Plus: Release 11.1.0.7.0 - Production on Fri Nov 21 17:10:14 2014
Copyright (c) 1982, 2008, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup mount;
Total System Global Area 418484224 bytes
6、切回去
Configuration
Fast-Start Failover: ENABLED
Current status for "c1":
DGMGRL> SWITCHOVER TO PROD1
Failed.
DGMGRL> DISABLE FAST_START FAILOVER;
Failed.
DGMGRL> SHOW CONFIGURATION;
Configuration
Fast-Start Failover: DISABLED
Current status for "c1":
DGMGRL> switchover to prod1; ----------------------------------->這個錯誤的一般出現在VM中。。。
Performing switchover NOW, please wait...
Failed.
Current status for "prod1":
Database dismounted.
Configuration
Fast-Start Failover: DISABLED
Current status for "c1":
Database dismounted.
DGMGRL> show configuration;
Configuration
Fast-Start Failover: DISABLED
Current status for "c1":