您好,登錄后才能下訂單哦!
關于Oracle DataGuard Broker的體系結構和詳細說明,請參閱另外的文章,本小節是對一個已經完全配置好的DG環境中使用 Data Guard 命令行界面 (DGMGRL)控制和監視 Data Guard 配置。通過 DGMGRL 在配置中執行管理和監視數據庫所要求的大部分活動。本文所展示的是通過DGMGRL來實現DG環境中各種保護模式之間的切換和主備之間的SwitchOver
為了能夠比較清楚的看清楚后面的說明,我這里先聲明一些東西:
數據庫 | DB_NAME | DB_UNIQUE_NAME | INSTANCE_NAME |
主數據庫 | DG_DEMO | Primary | Primary |
物理備用數據庫 | DG_DEMO | Standby | Standby |
以下測試是在Windows XP + Oracle 10.2.0.4單機環境中完成的!
1、提前條件
你已經創建好了一個沒有問題的DG環境(這里可以參見我為了本次實驗而專門搭建的DG環境說明和詳細的配置步驟一文)
2、創建Broker配置
這里面涉及到一些相關的參數和網絡配置,這部分比較簡單,也不說了,下面從create configuration開始
SQL> show parameter dg
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file1 string D:ORACLE10GDATABASEDR1PRIMARY.DAT
dg_broker_config_file2 string D:ORACLE10GDATABASEDR2PRIMARY.DAT
dg_broker_start boolean TRUE
SQL> show parameter local_listener;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string LISTENER_DGDEMO
SQL>
先熟悉一下DGMGLR的命令
DGMGRL> help 可使用以下命令: add 在中介配置中添加備用數據庫 connect 連接 Oracle 實例 create 創建中介配置 disable 禁用配置, 數據庫或快速啟動故障轉移 edit 編輯配置, 數據庫或實例 enable 啟用配置, 數據庫或快速啟動故障轉移 exit 退出程序 failover 將備用數據庫更改為主數據庫 help 顯示命令的說明和語法 quit 退出程序 reinstate 將已禁用的數據庫更改為可行的備用數據庫 rem DGMGRL 會忽略注釋 remove 刪除配置, 數據庫或實例 show 顯示有關配置, 數據庫或實例的信息 shutdown 關閉當前正在運行的 Oracle 實例 start 啟動快速啟動故障轉移觀察器 startup 啟動 Oracle 數據庫實例 stop 停止快速啟動故障轉移觀察器 switchover 在主數據庫和備用數據庫之間切換角色 使用 "help " 可以查看各個命令的語法 DGMGRL>
1)通過DGMGRL創建一個配置
D:oracle10g>dgmgrl DGMGRL for 32-bit Windows: Version 10.2.0.4.0 - Production Copyright (c) 2000, 2005, Oracle. All rights reserved. 歡迎使用 DGMGRL, 要獲取有關信息請鍵入 "help"。 DGMGRL> connect sys/admin@primary 已連接。 DGMGRL> create configuration dgcfg1 as --dgcfg1是自己定義的一個標識符 > primary database is primary --primary是主庫,tns連接串也是primary > connect identifier is primary; 已創建配置 "dgcfg1", 其中主數據庫為 "primary"
DGMGRL> add database standby as --將備節點加進來 > connect identifier is standby --備節點的intance_name和tns連接串均為standbhy > maintained as physical; 已添加數據庫 "standby"
DGMGRL> show configuration --顯示配置信息 Configuration Name: dgcfg1 Enabled: NO --還沒有enable,在后面第三步里實現enable的動作 Protection Mode: MaxPerformance --最開始我的保護模式是最大性能模式 Fast-Start Failover: DISABLED Databases: primary - Primary database standby - Physical standby database "dgcfg1" 的當前狀態: DISABLED
2)查看上面的配置信息,如果和你期望的不一樣,可以做適當的編輯
DGMGRL> show database verbose primary Database Name: primary Role: PRIMARY Enabled: NO Intended State: OFFLINE Instance(s): primary Properties: InitialConnectIdentifier = 'primary' ObserverConnectIdentifier = '' LogXptMode = 'ASYNC' Dependency = '' DelayMins = '0' Binding = 'OPTIONAL' MaxFailure = '0' MaxConnections = '1' ReopenSecs = '300' NetTimeout = '180' LogShipping = 'ON' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyParallel = 'AUTO' StandbyFileManagement = 'AUTO' ArchiveLagTarget = '0' LogArchiveMaxProcesses = '2' LogArchiveMinSucceedDest = '1' DbFileNameConvert = 'd:oracle10goradatastandby, d:oracle10goradataprimary' LogFileNameConvert = 'd:oracle10goradatastandby, d:oracle10goradataprimary' FastStartFailoverTarget = '' StatusReport = '(monitor)' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' SendQEntries = '(monitor)' LogXptStatus = '(monitor)' RecvQEntries = '(monitor)' HostName = 'zhangrp-cn' SidName = 'primary' LocalListenerAddress = '(ADDRESS=(PROTOCOL=TCP)(HOST=zhangrp-cn)(PORT=1527))' StandbyArchiveLocation = 'dgsby_primary' AlternateLocation = '' LogArchiveTrace = '0' LogArchiveFormat = 'dg_demo_%t_%s_%r.arc' LatestLog = '(monitor)' TopWaitEvents = '(monitor)' "primary" 的當前狀態:DISABLED 比如我上面這個色的地方,我想把他明確改到如下的路徑中: DGMGRL> edit database primary set property StandbyArchiveLocation ='d:oracle10goradataprimaryarch_std'; 已更新屬性 "standbyarchivelocation" DGMGRL> show database verbose primary Database Name: primary Role: PRIMARY Enabled: NO Intended State: OFFLINE Instance(s): primary Properties: InitialConnectIdentifier = 'primary' ObserverConnectIdentifier = '' LogXptMode = 'ASYNC' Dependency = '' DelayMins = '0' Binding = 'OPTIONAL' MaxFailure = '0' MaxConnections = '1' ReopenSecs = '300' NetTimeout = '180' LogShipping = 'ON' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyParallel = 'AUTO' StandbyFileManagement = 'AUTO' ArchiveLagTarget = '0' LogArchiveMaxProcesses = '2' LogArchiveMinSucceedDest = '1' DbFileNameConvert = 'd:oracle10goradatastandby, d:oracle10goradataprimary' LogFileNameConvert = 'd:oracle10goradatastandby, d:oracle10goradataprimary' FastStartFailoverTarget = '' StatusReport = '(monitor)' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' SendQEntries = '(monitor)' LogXptStatus = '(monitor)' RecvQEntries = '(monitor)' HostName = 'zhangrp-cn' SidName = 'primary' LocalListenerAddress = '(ADDRESS=(PROTOCOL=TCP)(HOST=zhangrp-cn)(PORT=1527))' StandbyArchiveLocation = 'd:oracle10goradataprimaryarch_std' --改過來了 AlternateLocation = '' LogArchiveTrace = '0' LogArchiveFormat = 'dg_demo_%t_%s_%r.arc' LatestLog = '(monitor)' TopWaitEvents = '(monitor)' "primary" 的當前狀態:DISABLED
再看一下備庫上是不是有需要調整的地方:
DGMGRL> show database verbose standby Database Name: standby Role: PHYSICAL STANDBY Enabled: NO Intended State: OFFLINE Instance(s): standby Properties: InitialConnectIdentifier = 'standby' ObserverConnectIdentifier = '' LogXptMode = 'ASYNC' Dependency = '' DelayMins = '0' Binding = 'OPTIONAL' MaxFailure = '0' MaxConnections = '1' ReopenSecs = '300' NetTimeout = '300' LogShipping = 'ON' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyParallel = 'AUTO' StandbyFileManagement = 'AUTO' ArchiveLagTarget = '0' LogArchiveMaxProcesses = '2' LogArchiveMinSucceedDest = '1' DbFileNameConvert = 'd:oracle10goradataprimary, d:oracle10goradatastandby' LogFileNameConvert = 'd:oracle10goradataprimary, d:oracle10goradatastandby' FastStartFailoverTarget = '' StatusReport = '(monitor)' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' SendQEntries = '(monitor)' LogXptStatus = '(monitor)' RecvQEntries = '(monitor)' HostName = 'zhangrp-cn' SidName = 'standby' LocalListenerAddress = '(ADDRESS=(PROTOCOL=TCP)(HOST=zhangrp-cn)(PORT=1527))' StandbyArchiveLocation = 'd:oracle10goradatastandbyarch' AlternateLocation = '' LogArchiveTrace = '0' LogArchiveFormat = 'dg_demo_%t_%s_%r.arc' LatestLog = '(monitor)' TopWaitEvents = '(monitor)' "standby" 的當前狀態: DISABLED
好,備庫不需要做任何調整,那么繼續往下走。
3、啟用Broker配置
1)enable Broker的配置和相關的數據庫
DGMGRL> enable configuration; 已啟用。 DGMGRL> show configuration; Configuration Name: dgcfg1 Enabled: YES --enable成功 Protection Mode: MaxPerformance Fast-Start Failover: DISABLED Databases: primary - Primary database standby - Physical standby database "dgcfg1" 的當前狀態:SUCCESS DGMGRL> show database verbose primary; Database Name: primary Role: PRIMARY Enabled: YES Intended State: ONLINE Instance(s): primary Properties: InitialConnectIdentifier = 'primary' ObserverConnectIdentifier = '' LogXptMode = 'ASYNC' Dependency = '' DelayMins = '0' Binding = 'OPTIONAL' MaxFailure = '0' MaxConnections = '1' ReopenSecs = '300' NetTimeout = '180' LogShipping = 'ON' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyParallel = 'AUTO' StandbyFileManagement = 'AUTO' ArchiveLagTarget = '0' LogArchiveMaxProcesses = '2' LogArchiveMinSucceedDest = '1' DbFileNameConvert = 'd:oracle10goradatastandby, d:oracle10goradataprimary' LogFileNameConvert = 'd:oracle10goradatastandby, d:oracle10goradataprimary' FastStartFailoverTarget = '' StatusReport = '(monitor)' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' SendQEntries = '(monitor)' LogXptStatus = '(monitor)' RecvQEntries = '(monitor)' HostName = 'zhangrp-cn' SidName = 'primary' LocalListenerAddress = '(ADDRESS=(PROTOCOL=TCP)(HOST=zhangrp-cn)(PORT=1527))' StandbyArchiveLocation = 'd:oracle10goradataprimaryarch_std' AlternateLocation = '' LogArchiveTrace = '0' LogArchiveFormat = 'dg_demo_%t_%s_%r.arc' LatestLog = '(monitor)' TopWaitEvents = '(monitor)' "primary" 的當前狀態:SUCCESS DGMGRL> show database verbose standby; Database Name: standby Role: PHYSICAL STANDBY Enabled: YES Intended State: ONLINE Instance(s): standby Properties: InitialConnectIdentifier = 'standby' ObserverConnectIdentifier = '' LogXptMode = 'ASYNC' Dependency = '' DelayMins = '0' Binding = 'OPTIONAL' MaxFailure = '0' MaxConnections = '1' ReopenSecs = '300' NetTimeout = '300' LogShipping = 'ON' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyParallel = 'AUTO' StandbyFileManagement = 'AUTO' ArchiveLagTarget = '0' LogArchiveMaxProcesses = '2' LogArchiveMinSucceedDest = '1' DbFileNameConvert = 'd:oracle10goradataprimary, d:oracle10goradatastandby' LogFileNameConvert = 'd:oracle10goradataprimary, d:oracle10goradatastandby' FastStartFailoverTarget = '' StatusReport = '(monitor)' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' SendQEntries = '(monitor)' LogXptStatus = '(monitor)' RecvQEntries = '(monitor)' HostName = 'zhangrp-cn' SidName = 'standby' LocalListenerAddress = '(ADDRESS=(PROTOCOL=TCP)(HOST=zhangrp-cn)(PORT=1527))' StandbyArchiveLocation = 'd:oracle10goradatastandbyarch' AlternateLocation = '' LogArchiveTrace = '0' LogArchiveFormat = 'dg_demo_%t_%s_%r.arc' LatestLog = '(monitor)' TopWaitEvents = '(monitor)' "standby" 的當前狀態:SUCCESS
2)看一下enable的過程中系統做了些什么
大家在配置這個東西的過程中,一定要實時的觀察alert日志的信息,不要讓自己走了彎路,如果遇到問題提前修復!
主庫(instance_name=primary)上的日志信息:
Sun Mar 08 16:42:56 2009 ARCH shutting down ARC2: Archival stopped NSV1 started with pid=26, OS id=412 RSM0 started with pid=28, OS id=5752 Sun Mar 08 16:45:51 2009 ALTER SYSTEM SET log_archive_dest_2='service="(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST=zhangrp-cn)(PORT=1527)))(CONNECT_DATA=(SERVICE_NAME=standby_XPT)(INSTANCE_NAME=STANDBY) (SERVER=dedicated)))"',' LGWR ASYNC NOAFFIRM delay=0 OPTIONAL max_failure=0 max_connections=1 reopen=300 db_unique_name="standby" register net_timeout=300 valid_for=(online_logfile,primary_role)' SCOPE=BOTH; Sun Mar 08 16:45:51 2009 ALTER SYSTEM SET log_archive_dest_state_2='ENABLE' SCOPE=BOTH; Sun Mar 08 16:45:51 2009 ALTER SYSTEM SET standby_archive_dest='' SCOPE=BOTH SID='primary'; Sun Mar 08 16:45:51 2009 ALTER SYSTEM SET log_archive_trace=0 SCOPE=BOTH SID='primary'; Sun Mar 08 16:45:52 2009 ALTER SYSTEM SET log_archive_format='dg_demo_%t_%s_%r.arc' SCOPE=SPFILE SID='primary'; Sun Mar 08 16:45:52 2009 ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=BOTH SID='*'; Sun Mar 08 16:45:52 2009 ALTER SYSTEM SET archive_lag_target=0 SCOPE=BOTH SID='*'; Sun Mar 08 16:45:52 2009 ALTER SYSTEM SET log_archive_max_processes=2 SCOPE=BOTH SID='*'; Sun Mar 08 16:45:52 2009 ALTER SYSTEM SET log_archive_min_succeed_dest=1 SCOPE=BOTH SID='*'; Sun Mar 08 16:45:52 2009 ALTER SYSTEM SET db_file_name_convert='d:oracle10goradatastandby','d:oracle10goradataprimary' SCOPE=SPFILE; Sun Mar 08 16:45:52 2009 ALTER SYSTEM SET log_file_name_convert='d:oracle10goradatastandby','d:oracle10goradataprimary' SCOPE=SPFILE; Sun Mar 08 16:45:52 2009 ALTER SYSTEM ARCHIVE LOG Sun Mar 08 16:45:53 2009 Thread 1 advanced to log sequence 141 (LGWR switch) Current log# 3 seq# 141 mem# 0: D:ORACLE10GORADATAPRIMARYREDO03.LOG Sun Mar 08 16:45:55 2009 ****************************************************************** LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2 ****************************************************************** LNS: Standby redo logfile selected for thread 1 sequence 141 for destination LOG_ARCHIVE_DEST_2 Sun Mar 08 16:46:06 2009 ALTER SYSTEM SET log_archive_dest_2='service="(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST=zhangrp-cn)(PORT=1527)))(CONNECT_DATA=(SERVICE_NAME=standby_XPT)(INSTANCE_NAME=STANDBY) (SERVER=dedicated)))"',' LGWR ASYNC NOAFFIRM delay=0 OPTIONAL max_failure=0 max_connections=1 reopen=300 db_unique_name="standby" register net_timeout=300 valid_for=(online_logfile,primary_role)' SCOPE=BOTH; Sun Mar 08 16:46:06 2009 ALTER SYSTEM SET log_archive_dest_state_2='ENABLE' SCOPE=BOTH; Sun Mar 08 16:46:06 2009 ALTER SYSTEM ARCHIVE LOG Sun Mar 08 16:46:07 2009 Thread 1 advanced to log sequence 142 (LGWR switch) Current log# 1 seq# 142 mem# 0: D:ORACLE10GORADATAPRIMARYREDO01.LOG Sun Mar 08 16:46:08 2009 ****************************************************************** LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2 ****************************************************************** LNS: Standby redo logfile selected for thread 1 sequence 142 for destination LOG_ARCHIVE_DEST_2 Sun Mar 08 16:46:56 2009 ALTER SYSTEM SET log_archive_dest_2='service="(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP) (HOST=zhangrp-cn)(PORT=1527)))(CONNECT_DATA=(SERVICE_NAME=standby_XPT)(INSTANCE_NAME=STANDBY) (SERVER=dedicated)))"',' LGWR ASYNC NOAFFIRM delay=0 OPTIONAL max_failure=0 max_connections=1 reopen=300 db_unique_name="standby" register net_timeout=300 valid_for=(online_logfile,primary_role)' SCOPE=BOTH; Sun Mar 08 16:46:56 2009 ALTER SYSTEM SET log_archive_dest_state_2='ENABLE' SCOPE=BOTH; Sun Mar 08 16:46:56 2009 ALTER SYSTEM ARCHIVE LOG Sun Mar 08 16:46:56 2009 Thread 1 cannot allocate new log, sequence 143 Checkpoint not complete Current log# 1 seq# 142 mem# 0: D:ORACLE10GORADATAPRIMARYREDO01.LOG Sun Mar 08 16:46:58 2009 Thread 1 advanced to log sequence 143 (LGWR switch) Current log# 2 seq# 143 mem# 0: D:ORACLE10GORADATAPRIMARYREDO02.LOG Sun Mar 08 16:46:59 2009 ****************************************************************** LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2 ****************************************************************** LNS: Standby redo logfile selected for thread 1 sequence 143 for destination LOG_ARCHIVE_DEST_2
備庫(instance_name=standby)上的日志信息:
Redo Shipping Client Connected as PUBLIC -- Connected User is Valid RFS[5]: Assigned to RFS process 4972 RFS[5]: Identified database type as 'physical standby' Primary database is in MAXIMUM PERFORMANCE mode Primary database is in MAXIMUM PERFORMANCE mode RFS[5]: Successfully opened standby log 11: 'D:ORACLE10GORADATASTANDBYSTDREDO01.LOG' Sun Mar 08 16:46:09 2009 Media Recovery Waiting for thread 1 sequence 142 (in transit) Sun Mar 08 16:46:10 2009 Recovery of Online Redo Log: Thread 1 Group 11 Seq 142 Reading mem 0 Mem# 0: D:ORACLE10GORADATASTANDBYSTDREDO01.LOG Sun Mar 08 16:46:25 2009 Redo Shipping Client Connected as PUBLIC -- Connected User is Valid RFS[6]: Assigned to RFS process 1464 RFS[6]: Identified database type as 'physical standby' Sun Mar 08 16:46:46 2009 ALTER SYSTEM SET log_archive_dest_1='location="d:oracle10goradatastandbyarch"', 'valid_for=(ALL_LOGFILES,ALL_ROLES)' SCOPE=BOTH SID='standby'; Sun Mar 08 16:46:46 2009 ALTER SYSTEM SET log_archive_dest_state_1='ENABLE' SCOPE=BOTH SID='standby'; Sun Mar 08 16:46:46 2009 ALTER SYSTEM SET standby_archive_dest='d:oracle10goradatastandbyarch' SCOPE=BOTH SID='standby'; Sun Mar 08 16:46:46 2009 ALTER SYSTEM SET log_archive_trace=0 SCOPE=BOTH SID='standby'; Sun Mar 08 16:46:46 2009 ALTER SYSTEM SET log_archive_format='dg_demo_%t_%s_%r.arc' SCOPE=SPFILE SID='standby'; Sun Mar 08 16:46:46 2009 ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=BOTH SID='*'; Sun Mar 08 16:46:46 2009 ALTER SYSTEM SET archive_lag_target=0 SCOPE=BOTH SID='*'; Sun Mar 08 16:46:46 2009 ALTER SYSTEM SET log_archive_max_processes=2 SCOPE=BOTH SID='*'; Sun Mar 08 16:46:46 2009 ALTER SYSTEM SET log_archive_min_succeed_dest=1 SCOPE=BOTH SID='*'; Sun Mar 08 16:46:46 2009 ALTER SYSTEM SET db_file_name_convert='d:oracle10goradataprimary','d:oracle10goradatastandby' SCOPE=SPFILE; Sun Mar 08 16:46:46 2009 ALTER SYSTEM SET log_file_name_convert='d:oracle10goradataprimary','d:oracle10goradatastandby' SCOPE=SPFILE; Sun Mar 08 16:46:46 2009 ALTER SYSTEM SET fal_server='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=zhangrp-cn) (PORT=1527)))(CONNECT_DATA=(SERVICE_NAME=primary_XPT)(SERVER=dedicated)))' SCOPE=BOTH; Sun Mar 08 16:46:46 2009 ALTER SYSTEM SET fal_client='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=zhangrp-cn) (PORT=1527)))(CONNECT_DATA=(SERVICE_NAME=standby_XPT)(INSTANCE_NAME=STANDBY)(SERVER=dedicated)))' SCOPE=BOTH; Sun Mar 08 16:46:46 2009 ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL Sun Mar 08 16:46:47 2009 MRP0: Background Media Recovery cancelled with status 16037 Sun Mar 08 16:46:47 2009 Errors in file d:adminstandbybdumpstandby_mrp0_4788.trc: ORA-16037: user requested cancel of managed recovery operation Managed Standby Recovery not using Real Time Apply Recovery interrupted! Recovered data files to a consistent state at change 691632 Sun Mar 08 16:46:48 2009 Errors in file d:adminstandbybdumpstandby_mrp0_4788.trc: ORA-16037: user requested cancel of managed recovery operation Sun Mar 08 16:46:48 2009 Waiting for MRP0 pid 4788 to terminate Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL Sun Mar 08 16:46:50 2009 ALTER DATABASE RECOVER MANAGED STANDBY DATABASE THROUGH ALL SWITCHOVER DISCONNECT USING CURRENT LOGFILE MRP0 started with pid=20, OS id=6012 Managed Standby Recovery starting Real Time Apply parallel recovery started with 2 processes Sun Mar 08 16:46:55 2009 Waiting for all non-current ORLs to be archived... Media Recovery Waiting for thread 1 sequence 142 (in transit) Sun Mar 08 16:46:56 2009 Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE THROUGH ALL SWITCHOVER DISCONNECT USING CURRENT LOGFILE Sun Mar 08 16:46:56 2009 Recovery of Online Redo Log: Thread 1 Group 11 Seq 142 Reading mem 0 Mem# 0: D:ORACLE10GORADATASTANDBYSTDREDO01.LOG Sun Mar 08 16:47:00 2009 Redo Shipping Client Connected as PUBLIC -- Connected User is Valid RFS[7]: Assigned to RFS process 4372 RFS[7]: Identified database type as 'physical standby' Primary database is in MAXIMUM PERFORMANCE mode Re-archiving standby log 11 thread 1 sequence 142 Primary database is in MAXIMUM PERFORMANCE mode Sun Mar 08 16:47:01 2009 Media Recovery Waiting for thread 1 sequence 143 (in transit) Sun Mar 08 16:47:01 2009 RFS[7]: Successfully opened standby log 11: 'D:ORACLE10GORADATASTANDBYSTDREDO01.LOG' Sun Mar 08 16:47:06 2009 Recovery of Online Redo Log: Thread 1 Group 11 Seq 143 Reading mem 0 Mem# 0: D:ORACLE10GORADATASTANDBYSTDREDO01.LOG Sun Mar 08 16:47:26 2009 Redo Shipping Client Connected as PUBLIC -- Connected User is Valid RFS[8]: Assigned to RFS process 5208 RFS[8]: Identified database type as 'physical standby'
OK,到這里Broker就配置成功了,其實很簡單是不是(成功與否的關鍵是看你的DG環境是不是規劃的很好)下面我們體驗一下吧
4、保護模式切換體驗
我最初配置的DG的保護模式是最大性能模式(MAXIMUM PERFORMANCE),在下面的體驗中我分別完成如下模式的切換
最大性能-->最大保護
最大保護-->最大可用
最大可用-->最大保護
最大保護-->最大性能
1)最大性能到最大保護模式的切換
DGMGRL> edit database primary set property LogXptMode ='SYNC'; --為什么改為SYNC 大家很清楚吧 已更新屬性 "logxptmode" DGMGRL> edit database standby set property LogXptMode ='SYNC'; 已更新屬性 "logxptmode" DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXPROTECTION; --這個restart的過程是自動的 操作要求關閉實例 "primary" (在數據庫 "primary" 上) 正在關閉實例 "primary"... 數據庫已經關閉。 已經卸載數據庫。 ORACLE 例程已經關閉。 操作要求啟動實例 "primary" (在數據庫 "primary" 上) 正在啟動實例 "primary"... ORACLE 例程已經啟動。 數據庫裝載完畢。 DGMGRL>
--切換完成。
在主庫(instance_name=primary)查看一下 SQL> select name,log_mode,open_mode,protection_mode,database_role from v$database; NAME LOG_MODE OPEN_MODE PROTECTION_MODE DATABASE_ROLE --------- ------------ ---------- -------------------- ---------------- DG_DEMO ARCHIVELOG READ WRITE MAXIMUM PROTECTION PRIMARY 在備庫(instance_name=standby)查看一下 SQL> select name,log_mode,open_mode,protection_mode,database_role from v$database; NAME LOG_MODE OPEN_MODE PROTECTION_MODE DATABASE_ROLE --------- ------------ ---------- -------------------- ---------------- DG_DEMO ARCHIVELOG MOUNTED MAXIMUM PROTECTION PHYSICAL STANDBY 注:自己在學習的時候,要注意觀察alert日志的信息
2)最大保護到最大可用模式的切換
這個動作比較簡單。
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY; 成功。 在主庫(instance_name=primary)查看一下 SQL> select name,log_mode,open_mode,protection_mode,database_role from v$database; NAME LOG_MODE OPEN_MODE PROTECTION_MODE DATABASE_ROLE --------- ------------ ---------- -------------------- ---------------- DG_DEMO ARCHIVELOG READ WRITE MAXIMUM AVAILABILITY PRIMARY SQL> 在備庫(instance_name=standby)查看一下 SQL> select name,log_mode,open_mode,protection_mode,database_role from v$database; NAME LOG_MODE OPEN_MODE PROTECTION_MODE DATABASE_ROLE --------- ------------ ---------- -------------------- ---------------- DG_DEMO ARCHIVELOG MOUNTED MAXIMUM AVAILABILITY PHYSICAL STANDBY SQL>
注:自己在學習的時候,要注意觀察alert日志的信息
3)最大可用到最大保護模式的切換
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXPROTECTION; 操作要求關閉實例 "primary" (在數據庫 "primary" 上) 正在關閉實例 "primary"... 數據庫已經關閉。 已經卸載數據庫。 ORACLE 例程已經關閉。 操作要求啟動實例 "primary" (在數據庫 "primary" 上) 正在啟動實例 "primary"... ORACLE 例程已經啟動。 數據庫裝載完畢。 DGMGRL> 在主庫(instance_name=primary)查看一下 SQL> select name,log_mode,open_mode,protection_mode,database_role from v$database; NAME LOG_MODE OPEN_MODE PROTECTION_MODE DATABASE_ROLE --------- ------------ ---------- -------------------- ---------------- DG_DEMO ARCHIVELOG READ WRITE MAXIMUM PROTECTION PRIMARY 在備庫(instance_name=standby)查看一下 SQL> select name,log_mode,open_mode,protection_mode,database_role from v$database; NAME LOG_MODE OPEN_MODE PROTECTION_MODE DATABASE_ROLE --------- ------------ ---------- -------------------- ---------------- DG_DEMO ARCHIVELOG MOUNTED MAXIMUM PROTECTION PHYSICAL STANDBY
注:自己在學習的時候,要注意觀察alert日志的信息
4)最大保護到最大性能模式的切換
在測試的最后,我再從最大保護模式切回到最初的最大性能模式
DGMGRL> edit database primary set property LogXptMode ='ASYNC'; 已更新屬性 "logxptmode" DGMGRL> edit database standby set property LogXptMode ='ASYNC'; 錯誤: ORA-16805: LogXptMode 屬性的更改違反了全局保護模式 失敗。 DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXPERFORMANCE; 成功。 DGMGRL> edit database standby set property LogXptMode ='ASYNC'; 已更新屬性 "logxptmode" DGMGRL> DGMGRL> show configuration verbose Configuration Name: dgcfg1 Enabled: YES Protection Mode: MaxPerformance Fast-Start Failover: DISABLED Databases: primary - Primary database standby - Physical standby database "dgcfg1" 的當前狀態: SUCCESS DGMGRL> 在主庫(instance_name=primary)查看一下 SQL> select name,log_mode,open_mode,protection_mode,database_role from v$database; NAME LOG_MODE OPEN_MODE PROTECTION_MODE DATABASE_ROLE --------- ------------ ---------- -------------------- ---------------- DG_DEMO ARCHIVELOG READ WRITE MAXIMUM PERFORMANCE PRIMARY SQL> 在備庫(instance_name=standby)查看一下 SQL> select name,log_mode,open_mode,protection_mode,database_role from v$database; NAME LOG_MODE OPEN_MODE PROTECTION_MODE DATABASE_ROLE --------- ------------ ---------- -------------------- ---------------- DG_DEMO ARCHIVELOG MOUNTED MAXIMUM PERFORMANCE PHYSICAL STANDBY SQL> 注:自己在學習的時候,要注意觀察alert日志的信息
5、SwitchOver切換體驗
在這次實驗中,我一并做了SwitchOver的切換體驗,整個測試工作非常的順利。
DGMGRL> switchover to standby; --這個standby是我的環境中的備庫的名字
立即執行切換, 請稍候...
操作要求關閉實例 "primary" (在數據庫 "primary" 上)
正在關閉實例 "primary"...
ORA-01109: 數據庫未打開
已經卸載數據庫。
ORACLE 例程已經關閉。
操作要求關閉實例 "standby" (在數據庫 "standby" 上)
正在關閉實例 "standby"...
ORA-01109: 數據庫未打開
已經卸載數據庫。
ORACLE 例程已經關閉。
操作要求啟動實例 "primary" (在數據庫 "primary" 上)
正在啟動實例 "primary"...
ORACLE 例程已經啟動。
數據庫裝載完畢。
操作要求啟動實例 "standby" (在數據庫 "standby" 上)
正在啟動實例 "standby"...
ORACLE 例程已經啟動。
數據庫裝載完畢。
切換成功, 新的主數據庫為 "standby"
DGMGRL>
到這里切換完成。下面再分別連接到原來的主備庫上查看一下 在原主庫(instance_name=primary)查看一下 SQL> select name,log_mode,open_mode,protection_mode,database_role from v$database; NAME LOG_MODE OPEN_MODE PROTECTION_MODE DATABASE_ROLE --------- ------------ ---------- -------------------- ---------------- DG_DEMO ARCHIVELOG MOUNTED MAXIMUM PERFORMANCE PHYSICAL STANDBY --已經變成備庫 SQL> 在原備庫(instance_name=standby)查看一下 SQL> select name,log_mode,open_mode,protection_mode,database_role from v$database; NAME LOG_MODE OPEN_MODE PROTECTION_MODE DATABASE_ROLE --------- ------------ ---------- -------------------- ---------------- DG_DEMO ARCHIVELOG READ WRITE MAXIMUM PERFORMANCE PRIMARY --現在變成主庫了 SQL> DGMGRL> show database primary; Database Name: primary Role: PHYSICAL STANDBY Enabled: YES Intended State: ONLINE Instance(s): primary "primary" 的當前狀態: SUCCESS DGMGRL> show database standby; Database Name: standby Role: PRIMARY Enabled: YES Intended State: ONLINE Instance(s): standby "standby" 的當前狀態:SUCCESS DGMGRL>
切換成功!
再切換回來吧(我后面還有其他操作需要)
DGMGRL> switchover to primary 立即執行切換, 請稍候... 操作要求關閉實例 "standby" (在數據庫 "standby" 上) 正在關閉實例 "standby"... ORA-01109: 數據庫未打開 已經卸載數據庫。 ORACLE 例程已經關閉。 操作要求關閉實例 "primary" (在數據庫 "primary" 上) 正在關閉實例 "primary"... ORA-01109: 數據庫未打開 已經卸載數據庫。 ORACLE 例程已經關閉。 操作要求啟動實例 "standby" (在數據庫 "standby" 上) 正在啟動實例 "standby"... ORACLE 例程已經啟動。 數據庫裝載完畢。 操作要求啟動實例 "primary" (在數據庫 "primary" 上) 正在啟動實例 "primary"... ORACLE 例程已經啟動。 數據庫裝載完畢。 切換成功, 新的主數據庫為 "primary" DGMGRL> show database primary; Database Name: primary Role: PRIMARY Enabled: YES Intended State: ONLINE Instance(s): primary "primary" 的當前狀態:SUCCESS DGMGRL> show database standby; Database Name: standby Role: PHYSICAL STANDBY Enabled: YES Intended State: ONLINE Instance(s): standby "standby" 的當前狀態:SUCCESS DGMGRL> 在實驗最初的主庫(instance_name=primary)查看一下 SQL> select name,log_mode,open_mode,protection_mode,database_role from v$database; NAME LOG_MODE OPEN_MODE PROTECTION_MODE DATABASE_ROLE --------- ------------ ---------- -------------------- ---------------- DG_DEMO ARCHIVELOG READ WRITE MAXIMUM PERFORMANCE PRIMARY SQL> 在實驗最初的備庫(instance_name=standby)查看一下 SQL> select name,log_mode,open_mode,protection_mode,database_role from v$database; NAME LOG_MODE OPEN_MODE PROTECTION_MODE DATABASE_ROLE --------- ------------ ---------- -------------------- ---------------- DG_DEMO ARCHIVELOG READ WRITE MAXIMUM PERFORMANCE PHYSICAL STANDBY SQL>
好了,今天的體驗就到這里了!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。