編輯:關於 Android 開發
近期一直在學習 Oracle 12c 數據庫,順手整理了一份文檔。這裡主要記錄如何在 Oracle 12c 的 Far Sync + Active Data Guard 架構上完成 DG Broker 的配置。
SQL> col BANNER for a90 SQL> select * from v$version; BANNER CON_ID ------------------------------------------------------------------------------------------ ---------- Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production 0 PL/SQL Release 12.1.0.2.0 - Production 0 CORE 12.1.0.2.0 Production 0 TNS for Linux: Version 12.1.0.2.0 - Production 0 NLSRTL Version 12.1.0.2.0 - Production 0
這一點是 12c 與早期版本的重要差異,很容易忽略。
-- primary alter system set log_archive_dest_2=''; alter system set log_archive_dest_3=''; -- far sync alter system set log_archive_dest_2=''; -- standby alter system set log_archive_dest_2=''; alter system set log_archive_dest_3='';
為什麼必須這麼做:在 12cR1 之前的版本中,配置 DG Broker 並不需要清理這些參數;但在 12cR1 及以後版本中,如果已經手動配置了 DG redo log 同步參數卻未清除,創建 Broker 配置時就會直接報錯:
DGMGRL> create configuration dg12c_broker as primary database is dg12cpy connect identifier is xxxx; Error: ORA-16698: LOG_ARCHIVE_DEST_n parameter set for object to be added Failed.
這個錯誤含義很明確:待加入的對象上已經設置了 LOG_ARCHIVE_DEST_n 參數,Broker 拒絕接管,因為 redo 傳輸策略此後應由 Broker 統一管理。
在主庫、Far Sync 實例和備庫上分別執行:
SQL> alter system set dg_broker_start=true scope=both;
以下操作在主庫的 DGMGRL 中完成。
1. 創建 Broker 配置
DGMGRL> create configuration dg12c_broker as primary database is dg12cpy connect identifier is dg12cpy; Configuration "dg12c_broker" created with primary database "dg12cpy"
2. 添加物理備庫
DGMGRL> add database dg12csd as connect identifier is dg12csd maintained as physical; Database "dg12csd" added
3. 啟用整個配置
DGMGRL> enable configuration Enabled.
4. 查看配置狀態
DGMGRL> show configuration
Configuration - dg12c_broker
Protection Mode: MaxPerformance
Members:
dg12cpy - Primary database
dg12csd - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 20 seconds ago)
備庫的詳細屬性可以用 verbose 參數展開查看,其中需要重點關注 Transport Lag、Apply Lag、Apply Rate 以及 LogXptMode 等指標:
DGMGRL> show database verbose 'dg12csd'
Database - dg12csd
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: 20.00 KByte/s
Active Apply Rate: 1.05 MByte/s
Maximum Apply Rate: 3.18 MByte/s
Real Time Query: ON
Instance(s):
dg12c
Properties:
DGConnectIdentifier = 'dg12csd'
LogXptMode = 'ASYNC'
RedoRoutes = ''
DelayMins = '0'
Binding = 'optional'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '30'
RedoCompression = 'DISABLE'
LogShipping = 'ON'
ApplyInstanceTimeout = '0'
ApplyLagThreshold = '0'
TransportLagThreshold = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'AUTO'
LogArchiveMaxProcesses = '4'
StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dgsd)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=dg12csd_DGMGRL)(INSTANCE_NAME=dg12c)(SERVER=DEDICATED)))'
StandbyArchiveLocation = '/opt/oracle/oradata/dg12c/archive'
LogArchiveFormat = 'arch_%r_%t_%s.dbf'
Database Status:
SUCCESS
5. 啟用 Standby 應用
DGMGRL> ENABLE DATABASE 'dg12csd'; Enabled. DGMGRL> show database 'dg12csd'; Database - dg12csd Role: PHYSICAL STANDBY Intended State: APPLY-ON Transport Lag: 0 seconds Apply Lag: 0 seconds Average Apply Rate: 20.00 KByte/s Real Time Query: ON Database Status: SUCCESS
6. 加入 Far Sync 實例
DGMGRL> ENABLE FAR_SYNC dg12cfy;
Enabled.
DGMGRL> show configuration;
Configuration - dg12c_broker
Protection Mode: MaxPerformance
Members:
dg12cpy - Primary database
dg12csd - Physical standby database
dg12cfy - Far sync instance
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 7 seconds ago)
7. 在 Broker 中定義 Redo 傳輸路徑
這是 Far Sync 架構的核心:主庫以 SYNC 方式把 redo 發送給本地附近的 Far Sync 實例,再由 Far Sync 以 ASYNC 方式轉發到遠端備庫。這樣既保證了主庫的低提交延遲,又兼顧了跨地域傳輸的帶寬與時延現實。
DGMGRL> EDIT DATABASE 'dg12cpy' SET PROPERTY 'RedoRoutes'='(LOCAL : dg12cfy SYNC)'; Property "RedoRoutes" updated DGMGRL> EDIT FAR_SYNC 'dg12cfy' SET PROPERTY 'RedoRoutes'='(dg12cpy : dg12csd ASYNC)'; Property "RedoRoutes" updated
確認配置:
DGMGRL> SHOW CONFIGURATION;
Configuration - dg12c_broker
Protection Mode: MaxPerformance
Members:
dg12cpy - Primary database
dg12cfy - Far sync instance
dg12csd - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 23 seconds ago)
8. 調整高可用模式
由於 Far Sync 具備零數據丟失的傳輸能力,可以把保護模式提升到 MaxAvailability:
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MaxAvailability;
Succeeded.
DGMGRL> SHOW CONFIGURATION;
Configuration - dg12c_broker
Protection Mode: MaxAvailability
Members:
dg12cpy - Primary database
dg12cfy - Far sync instance
dg12csd - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 30 seconds ago)
主庫側:
SQL> alter session set container=pdb1; Session altered. SQL> create table t2 as select * from t1 where 1=0; Table created. SQL> insert into t2(id,name) values (1,'dfrt'); 1 row created. SQL> commit; Commit complete. SQL> select * from t2; ID NAME ---------- ---------------------------------------- 1 dfrt
備庫側:
SQL> alter session set container=pdb1; Session altered. SQL> select * from t2; no rows selected -- 稍候再查,redo 已應用完成 SQL> select * from t2; ID NAME ---------- ---------------------------------------- 1 dfrt
備庫首次查詢查不到數據、稍後查詢即可見,正說明 redo 正在通過 Far Sync 節點持續傳輸並應用。配合 Active Data Guard 的 Real Time Query 特性,備庫在應用 redo 的同時仍可保持打開讀取狀態,這也是 12c 這套架構實用性較強的地方。
log_archive_dest_n,否則會撞上 ORA-16698。dg_broker_start。Transport Lag 與 Apply Lag 判斷鏈路健康度。
Android 學習指南(一):Android 開發環境建置圖解
Android 開發環境準備 本單元以圖解方式說明 Android 開發環境的建立流程,使用的版本以 Android 2.2 為例。整體環境通常包含 Java JDK、E
3D圖片採集與展示實戰:SurfaceView自適應Camera、錄屏抽幀全流程
3D圖片採集與展示實戰:SurfaceView自適應Camera、錄屏抽幀全流程 最近在做一個3D圖片採集與展示的功能。 主要功能為:自定義Camera(Google已
Android Shape 與 GradientDrawable 圖文詳解
概覽Android 可透過 XML 定義多種 Drawable,其中 shape 節點常用來建立 GradientDrawable。這類 drawable 可放在 res
Android Support Library 之 Toolbar 完全指南
Android Support Library 之 Toolbar 完全指南 從 Android 3.0 開始,所有主題預設把 ActionBar 作為 App Bar,