1. Standby로 switchover
A) Primary에 DGMGRL로 접속
DGMGRL로 primary DB에 접속
dgmgrl sys/[sys 계정 암호]@[primary 네트워크 서비스명]
[oracle@orcl ~]$ export NLS_DATE_FORMAT="yyyy/mm/dd hh24:mi:ss" [oracle@orcl ~]$ dgmgrl sys/oracle@SEOUL_SYN DGMGRL for Linux: Release 19.0.0.0.0 - Production on Tue Feb 13 15:09:01 2024 Version 19.11.0.0.0 Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved. Welcome to DGMGRL, type "help" for information. Connected to "orcl" Connected as SYSDBA.
{}
Primary에서 standby로 switchover하기 위해 DGMGRL로 접속합니다.
B) Standby로 switchover
Standby로 switchover 수행
SWITCHOVER TO [standby 글로벌 DB명];
DGMGRL> SWITCHOVER TO orcl_stby; Performing switchover NOW, please wait... Operation requires a connection to database "orcl_stby" Connecting ... Connected to "orcl_stby" Connected as SYSDBA. New primary database "orcl_stby" 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. Connected to "orcl" Switchover succeeded, new primary is "orcl_stby"
Switchover 명령어를 사용하여 standby로 데이터베이스를 switchover 합니다.
C) Switchover 결과 확인
Switchover 결과 확인
SHOW CONFIGURATION; SHOW DATABASE [primary 글로벌 DB명]; SHOW DATABASE [standby 글로벌 DB명];
DGMGRL> SHOW CONFIGURATION; Configuration - dg_orcl Protection Mode: MaxPerformance Members: orcl_stby - Primary database orcl - Physical standby database Fast-Start Failover: Disabled Configuration Status: SUCCESS (status updated 50 seconds ago) DGMGRL> SHOW DATABASE orcl; Database - orcl Role: PHYSICAL STANDBY Intended State: APPLY-ON Transport Lag: 0 seconds (computed 1 second ago) Apply Lag: 0 seconds (computed 1 second ago) Average Apply Rate: 3.02 MByte/s Real Time Query: OFF Instance(s): orcl Database Status: SUCCESS DGMGRL> SHOW DATABASE orcl_stby; Database - orcl_stby Role: PRIMARY Intended State: TRANSPORT-ON Instance(s): orcl Database Status: SUCCESS
Show 명령을 통해 DGMGRL에서 switchover 상태를 확인할 수 있습니다.
D) Switchover 후 데이터베이스 상태 확인
Primary DB와 Standby DB에서 수행
SELECT db_unique_name, open_mode, database_role, switchover_status FROM v$database;
SQL> set lines 200 SQL> col db_unique_name form a20 SQL> col open_mode form a20 SQL> col database_role form a20 SQL> col switchover_status form a20 SQL> SELECT db_unique_name, open_mode, database_role, switchover_status FROM v$database; DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS -------------------- -------------------- -------------------- -------------------- orcl_stby READ WRITE PRIMARY TO STANDBY
SQL> set lines 200 SQL> col db_unique_name form a20 SQL> col open_mode form a20 SQL> col database_role form a20 SQL> col switchover_status form a20 SQL> SELECT db_unique_name, open_mode, database_role, switchover_status FROM v$database; DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS -------------------- -------------------- -------------------- -------------------- orcl MOUNTED PHYSICAL STANDBY NOT ALLOWED
Primary와 standby 데이터베이스의 상태도 변경된 것을 v$database 뷰에서 확인할 수 있습니다.
2. Primary로 복원
A) Standby에 DGMGRL로 접속
Standby에 DGMGRL로 접속
dgmgrl sys/[sys 계정 암호]@[standby 네트워크 서비스명]
[oracle@orcl ~]$ dgmgrl sys/oracle@BUSAN_SYN DGMGRL for Linux: Release 19.0.0.0.0 - Production on Tue Feb 13 15:27:12 2024 Version 19.11.0.0.0 Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved. Welcome to DGMGRL, type "help" for information. Connected to "orcl_stby" Connected as SYSDBA.
Standby에서 primary로 복원하기 위해 DGMGRL로 접속합니다.
B) Primary로 switchover
Primary로 switchover 수행
SWITCHOVER TO [primary 글로벌 DB명];
DGMGRL> SWITCHOVER TO orcl; Performing switchover NOW, please wait... Operation requires a connection to database "orcl" Connecting ... Connected to "orcl" Connected as SYSDBA. New primary database "orcl" is opening... Operation requires start up of instance "orcl" on database "orcl_stby" Starting instance "orcl"... Connected to an idle instance. ORACLE instance started. Connected to "orcl_stby" Database mounted. Connected to "orcl_stby" Switchover succeeded, new primary is "orcl"
Switchover 명령어를 사용하여 primary로 데이터베이스를 switchover 합니다.
C) 복원 결과 확인
복원 결과 확인
SHOW CONFIGURATION; SHOW DATABASE [primary 글로벌 DB명]; SHOW DATABASE [standby 글로벌 DB명];
DGMGRL> SHOW CONFIGURATION; Configuration - dg_orcl Protection Mode: MaxPerformance Members: orcl - Primary database orcl_stby - Physical standby database Fast-Start Failover: Disabled Configuration Status: SUCCESS (status updated 52 seconds ago) DGMGRL> SHOW DATABASE orcl; Database - orcl Role: PRIMARY Intended State: TRANSPORT-ON Instance(s): orcl Database Status: SUCCESS DGMGRL> SHOW DATABASE orcl_stby; Database - orcl_stby Role: PHYSICAL STANDBY Intended State: APPLY-ON Transport Lag: 0 seconds (computed 1 second ago) Apply Lag: 0 seconds (computed 1 second ago) Average Apply Rate: 3.91 MByte/s Real Time Query: OFF Instance(s): orcl Database Status: SUCCESS
DGMGRL에서 Show 명령어로 복원된 결과를 확인할 수 있습니다.
D) 복원 후 데이터베이스 상태 확인
Primary DB와 Standby DB에서 수행
SELECT db_unique_name, open_mode, database_role, switchover_status FROM v$database;
SQL> set lines 200 SQL> col db_unique_name form a20 SQL> col open_mode form a20 SQL> col database_role form a20 SQL> col switchover_status form a20 SQL> SELECT db_unique_name, open_mode, database_role, switchover_status FROM v$database; DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS -------------------- -------------------- -------------------- -------------------- orcl READ WRITE PRIMARY TO STANDBY
SQL> set lines 200 SQL> col db_unique_name form a20 SQL> col open_mode form a20 SQL> col database_role form a20 SQL> col switchover_status form a20 SQL> SELECT db_unique_name, open_mode, database_role, switchover_status FROM v$database; DB_UNIQUE_NAME OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS -------------------- -------------------- -------------------- -------------------- orcl_stby MOUNTED PHYSICAL STANDBY NOT ALLOWED
데이터베이스의 상태도 다시 원래대로 복원된 것을 v$database 뷰로 확인할 수 있습니다.