前回の記事ではFar Syncインスタンスの構築、および構築後の簡単な確認を行いました。
今回はその構成を使って基本動作 (Switchover、Failover、Far Syncインスタンス障害) を確認したいと思います。
以下は前回の記事でも掲載した、Far Syncを利用した場合のDG構成イメージです。

目次
Switchover
Data Guard Brokerを使ってSwitchoverします。
今回はPrimaryから実行します。
まずは現在の構成を確認します。
dgmgrl sys@orcl
DGMGRL> show configuration
Configuration - adgconfig
Protection Mode: MaxAvailability
Members:
orcl - Primary database
orclfs1 - Far sync instance
orclstby - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 54 seconds ago)
Switchoverできる状態か、正常性を確認します。
## ORCLSTBYの確認
DGMGRL> validate database ORCLSTBY
Database Role: Physical standby database
Primary Database: orcl
Ready for Switchover: Yes
Ready for Failover: Yes (Primary Running)
Flashback Database Status:
orcl : On
orclstby: Off
Managed by Clusterware:
orcl : NO
orclstby: NO
Validating static connect identifier for the primary database orcl...
The static connect identifier allows for a connection to database "orcl".
## ORCLFS1の確認
DGMGRL> validate far_sync ORCLFS1
Member Role: Far Sync Instance
When Primary Is: orcl
Active Redo Source: orcl
Redo Destinations:
orclstby
Thread # Online Redo Log Groups Standby Redo Log Groups Status
orcl orclfs1
1 3 4 Sufficient SRLs
Switchoverを実行し、ORCLSTBYを新Primaryに昇格させます。
DGMGRL> switchover to orclstby
Performing switchover NOW, please wait...
Operation requires a connection to database "orclstby"
Connecting ...
Connected to "ORCLSTBY"
Connected as SYSDBA.
New primary database "orclstby" is opening...
Operation requires start up of instance "ORCL" on database "orcl"
Starting instance "ORCL"...
Connected to an idle instance.
ORACLE instance started.
Connected to "ORCL"
Database mounted.
Database opened.
Switchover succeeded, new primary is "orclstby"
Data Guardの状態を確認します。
DGMGRL> show configuration
Configuration - adgconfig
Protection Mode: MaxAvailability
Members:
orclstby - Primary database
orcl - Physical standby database
Members Not Receiving Redo:
orclfs1 - Far sync instance
Warning: ORA-12154: TNS:could not resolve the connect identifier specified
Fast-Start Failover: Disabled
Configuration Status:
WARNING (status updated 61 seconds ago)
orclstbyがPrimaryに昇格し、orclが新しいStandbyになりました。
一方でorclstbyからorclに対するデータ同期にはFar Syncインスタンスが構成されていないため、orclfs1は構成メンバーとならず、REDOを受信していません。
ちなみにこの状態の保護モードは上記ログの通りMaxAvailability (最大可用性モード) になっています。
Far Syncインスタンスがない状態では、本来 MaxPerformance (最大パフォーマンスモード) となっている状態が期待されます。
そのため、Switchover してから暫く経って構成情報を確認すると、以下の通り Warning が出力されます。
DGMGRL> show configuration
Configuration - adgconfig
Protection Mode: MaxAvailability
Members:
orclstby - Primary database
Warning: ORA-16629: database reports a different protection level from the protection mode
orcl - Physical standby database
Members Not Receiving Redo:
orclfs1 - Far sync instance
Fast-Start Failover: Disabled
Configuration Status:
WARNING (status updated 71 seconds ago)
この状況で Switchback を試みると以下の通りエラー (ORA-16629) となります。
DGMGRL> switchover to orcl
Performing switchover NOW, please wait...
Error: ORA-16629: database reports a different protection level from the protection mode
Failed.
Unable to switchover, primary database is still "orclstby"
以上より Switchover した後は次のように保護モードの変更が必要となります。
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxPerformance;
Succeeded.
変更後しばらくすると構成情報から Warning が消えます。
DGMGRL> show configuration;
Configuration - adgconfig
Protection Mode: MaxPerformance
Members:
orclstby - Primary database
orcl - Physical standby database
Members Not Receiving Redo:
orclfs1 - Far sync instance
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 32 seconds ago)
これで Switchback できますので、まずは事前チェックを実行します。
DGMGRL> validate database ORCL
Database Role: Physical standby database
Primary Database: orclstby
Ready for Switchover: Yes
Ready for Failover: Yes (Primary Running)
Flashback Database Status:
orclstby: Off
orcl : On
Managed by Clusterware:
orclstby: NO
orcl : NO
Validating static connect identifier for the primary database orclstby...
The static connect identifier allows for a connection to database "orclstby".
問題なさそうですので、Switchback を実行します。
DGMGRL> switchover to orcl
Performing switchover NOW, please wait...
New primary database "orcl" is opening...
Operation requires start up of instance "ORCL" on database "orclstby"
Starting instance "ORCL"...
Connected to an idle instance.
ORACLE instance started.
Connected to "ORCLSTBY"
Database mounted.
Database opened.
Switchover succeeded, new primary is "orcl"
改めて構成情報を確認します。
DGMGRL> show configuration
Configuration - adgconfig
Protection Mode: MaxPerformance
Members:
orcl - Primary database
orclfs1 - Far sync instance
orclstby - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 45 seconds ago)
再びFar Syncインスタンスである orclfs1 が組み込まれました。
一方で保護モードが MaxPerformance のままとなっているため、最大可用性モードに変更しておきます。
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability;
Succeeded.
DGMGRL> show configuration
Configuration - adgconfig
Protection Mode: MaxAvailability
Members:
orcl - Primary database
orclfs1 - Far sync instance
orclstby - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 40 seconds ago)
以上が Switchover でした。
Failover
続いて Failover です。
まずは Failover 後の旧Primary復旧をフラッシュバック・データベースで迅速に対応したいため、フラッシュバック機能が有効かPrimaryで確認します。
SQL> select open_mode,database_role,flashback_on from v$database;
OPEN_MODE DATABASE_ROLE FLASHBACK_ON
-------------------- ---------------- ------------------
READ ONLY WITH APPLY PHYSICAL STANDBY YES
もし無効化されている場合は以下手順を例に有効化します。
-- DBが起動している場合は停止
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
-- MOUNTで起動
SQL> startup mount;
ORACLE instance started.
Total System Global Area 4949277232 bytes
Fixed Size 9173552 bytes
Variable Size 889192448 bytes
Database Buffers 4043309056 bytes
Redo Buffers 7602176 bytes
Database mounted.
-- フラッシュバック・ログを格納するディレクトリを作成
SQL> !mkdir -p /u01/app/oracle/fra/ORCL
-- 高速リカバリ領域のサイズを設定
SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST_SIZE = 10G SCOPE=BOTH;
System altered.
-- 高速リカバリ領域のパスを設定
SQL> ALTER SYSTEM SET DB_RECOVERY_FILE_DEST = '/u01/app/oracle/fra/ORCL' SCOPE=BOTH;
System altered.
-- フラッシュバックを有効化
SQL> alter database flashback on;
Database altered.
-- DBをオープン
SQL> alter database open;
Database altered.
SQL> alter pluggable database all open;
Pluggable database altered.
-- フラッシュバック・データベースが有効化されているか確認
SQL> select open_mode,database_role,flashback_on from v$database;
OPEN_MODE DATABASE_ROLE FLASHBACK_ON
-------------------- ---------------- ------------------
READ WRITE PRIMARY YES
次に DGMGRL から Failover 前の事前チェックを行います。
ややこしいのですが、本検証では以下状態で Failover しようとしています。
- Primary: orclstby
- Standby: orcl
DGMGRL> validate database orclstby
Database Role: Primary database
Ready for Switchover: Yes
Managed by Clusterware:
orclstby: NO
Validating static connect identifier for the primary database orclstby...
The static connect identifier allows for a connection to database "orclstby".
DGMGRL> validate database orcl
Database Role: Physical standby database
Primary Database: orclstby
Ready for Switchover: Yes
Ready for Failover: Yes (Primary Running)
Managed by Clusterware:
orclstby: NO
orcl : NO
Validating static connect identifier for the primary database orclstby...
The static connect identifier allows for a connection to database "orclstby".
orcl 側が Failover できる状態のため、Failover を実行します。
DGMGRL> failover to orcl
Performing failover NOW, please wait...
Failover succeeded, new primary is "orcl"
Failover 後の構成情報を確認します。
DGMGRL> show configuration
Configuration - adgconfig
Protection Mode: MaxPerformance
Members:
orcl - Primary database
orclfs1 - Far sync instance
Members Not Receiving Redo:
orclstby - Physical standby database (disabled)
ORA-16661: the standby database needs to be reinstated
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 108 seconds ago)
Switchover と同様、保護モードが最大パフォーマンスになっているため変更します。
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability;
Succeeded.
変更後の構成情報を確認します。
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability;
Succeeded.
DGMGRL> show configuration
Configuration - adgconfig
Protection Mode: MaxAvailability
Members:
orcl - Primary database
Warning: ORA-16809: multiple warnings detected for the member
orclfs1 - Far sync instance
Members Not Receiving Redo:
orclstby - Physical standby database (disabled)
ORA-16661: the standby database needs to be reinstated
Fast-Start Failover: Disabled
Configuration Status:
WARNING (status updated 36 seconds ago)
Data Guard構成を復旧させるため、orclstby を Reinstateします (内部でフラッシュバック・データベースが実行されます)。
まずは orclstby を停止して MOUNT で起動します。
DGMGRL> connect sys/Ora_DB4U@orclstby
Connected to "ORCLSTBY"
Connected as SYSDBA.
DGMGRL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
Connected to an idle instance.
DGMGRL> startup mount
Connected to "ORCLSTBY"
ORACLE instance started.
Database mounted.
Reinstate を実行します。
DGMGRL> connect sys/Ora_DB4U@orcl
Connected to "ORCL"
Connected as SYSDBA.
DGMGRL> reinstate database orclstby
Reinstating database "orclstby", please wait...
Reinstatement of database "orclstby" succeeded
構成情報を確認します。
DGMGRL> show configuration
Configuration - adgconfig
Protection Mode: MaxAvailability
Members:
orcl - Primary database
orclfs1 - Far sync instance
orclstby - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 12 seconds ago)
Reinstate 直後は以下の Warning が出力されるかもしれませんが、時間が経つと解消されます。
Warning: ORA-16856: transport lag could not be determined
Far Syncインスタンス障害
Far Syncインスタンスがダウンした場合、PrimaryとStandbyが直接やり取りし始めます。
本当にそうなるのか動作確認してみます。
まずはVMを停止するなどで、Far Syncインスタンスの疑似障害を起こします。
その後、各構成情報を確認してみます。
障害発生直後のData Guardの状態は以下の通りです。
DGMGRL> show configuration
Configuration - adgconfig
Protection Mode: MaxAvailability
Members:
orcl - Primary database
Warning: ORA-16629: database reports a different protection level from the protection mode
orclstby - Physical standby database (alternate of orclfs1)
Warning: ORA-16809: multiple warnings detected for the member
Members Not Receiving Redo:
orclfs1 - Far sync instance
Fast-Start Failover: Disabled
Configuration Status:
WARNING (status updated 189 seconds ago)
orcl と orclstby は直接やり取りしていますが、保護モードが最大可用性モードになっています (最大パフォーマンスへの変更が必要)。
また orclstby には alternate of orclfs1 と出力されており、orclfs1 がダウンしているため直接同期をはかっている点が見て取れます。
orcl の状態は以下の通りです。
DGMGRL> show database orcl
Database - orcl
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
ORCL
Database Warning(s):
ORA-16629: database reports a different protection level from the protection mode
Database Status:
WARNING
保護モードが違う、という内容のエラー (ORA-16629) が出力されています。
最後に orclstby の状態は以下の通りです。
DGMGRL> show database orclstby
Database - orclstby
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 3 minutes 4 seconds (computed 1 second ago)
Apply Lag: 3 minutes 4 seconds (computed 1 second ago)
Average Apply Rate: 59.00 KByte/s
Real Time Query: ON
Instance(s):
ORCL
Database Warning(s):
ORA-16853: apply lag has exceeded specified threshold
ORA-16855: transport lag has exceeded specified threshold
Database Status:
WARNING
apply lag と transport lag がしきい値を超えていると出力されています。
Far Syncインスタンスが使えない状態がしばらく続く場合は、保護モードを最大パフォーマンスへ変更しておきます。
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxPerformance;
Succeeded.
DGMGRL> show configuration;
Configuration - adgconfig
Protection Mode: MaxPerformance
Members:
orcl - Primary database
orclstby - Physical standby database (alternate of orclfs1)
Members Not Receiving Redo:
orclfs1 - Far sync instance
Warning: ORA-16662: network timeout when contacting a member
Fast-Start Failover: Disabled
Configuration Status:
WARNING (status updated 91 seconds ago)
ではダウンしているFar Syncインスタンスを復旧させてみます。
Far Syncインスタンスを MOUNT で起動します。
SQL> startup mount;
ORACLE instance started.
Total System Global Area 243268144 bytes
Fixed Size 8923696 bytes
Variable Size 192937984 bytes
Database Buffers 33554432 bytes
Redo Buffers 7852032 bytes
Database mounted.
リスナーも停止していれば起動しておきます。
$ lsnrctl start
DGMGRL からData Guardの構成情報を確認します。
DGMGRL> show configuration
Configuration - adgconfig
Protection Mode: MaxPerformance
Members:
orcl - Primary database
orclfs1 - Far sync instance
Error: ORA-16525: The Oracle Data Guard broker is not yet available.
orclstby - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
ERROR (status updated 45 seconds ago)
Far Syncインスタンス復旧直後は ORA-16525 が出力されますが、しばらく経つと以下の通り正常に戻ります。
DGMGRL> show configuration
Configuration - adgconfig
Protection Mode: MaxPerformance
Members:
orcl - Primary database
orclfs1 - Far sync instance
orclstby - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 19 seconds ago)
各DBの状態も確認しておきます。
# orcl
DGMGRL> show database orcl
Database - orcl
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
ORCL
Database Status:
SUCCESS
# orclstby
DGMGRL> show database orclstby
Database - orclstby
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 1 second ago)
Apply Lag: 0 seconds (computed 0 seconds ago)
Average Apply Rate: 27.00 KByte/s
Real Time Query: ON
Instance(s):
ORCL
Database Status:
SUCCESS
# orclfs1
DGMGRL> show far_sync orclfs1
Far Sync Instance - orclfs1
Transport Lag: 0 seconds (computed 0 seconds ago)
Instance(s):
ORCL
Far Sync Instance Status:
SUCCESS
いずれも正常な状態に戻りました。
最後に保護モードを最大可用性モードに変更しておきます。
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability;
Succeeded.
DGMGRL> show configuration
Configuration - adgconfig
Protection Mode: MaxAvailability
Members:
orcl - Primary database
orclfs1 - Far sync instance
orclstby - Physical standby database
Fast-Start Failover: Disabled
Configuration Status:
SUCCESS (status updated 40 seconds ago)
まとめ
以上が Switchover、Failover、Far Syncインスタンス障害 の動作確認でした。
今回の構成では一方向のデータ同期に対してのみFar Syncインスタンスが構成されていたため、Switchover や Failover した際の構成が非対称となっていました。
それに伴い Switchover / Failover した後に保護モードの手動変更が必要でした。
理想的な構成は双方向に対してFar Syncインスタンスを構成した状態で、今回でいうと以下のようなイメージです。
- 平常時:
orcl-->orclfs1-->orclstby - Switchover / Failover後:
orclstby-->orclfs2-->orcl
ということで、次回は orclfs2 を追加して、Switchover / Failover 後もFar Syncインスタンスが利用できる状態にしたいと思います。
その状態であれば保護モードの手動変更も不要となるのでは、と期待しています。