劉佔平甲骨文(中國)軟體系統****
2023年10月23日
目錄1 雙向複製方案簡介 3
2 雙向複製方案實現過程 3
2.1 同步表說明 4
2.2 使用者配置 4
2.2.1 同步使用者 4
2.2.2 源資料庫使用者 4
2.2.3 目標資料庫使用者 4
2.3 源資料庫端配置 5
2.3.1 增加extract 5
2.3.2 增加replicat 5
2.3.3 檢查啟動狀態 6
2.4 目標資料庫配置 6
2.4.1 增加extract 6
2.4.2 增加replicat 7
2.4.3 檢查啟動狀態 7
3 測試 7
在雙向複製(bidirectional)方案中,可以採用以下兩種部署方式:
方式一:配置源和目標資料庫可以同時保持active狀態,同時進行應用系統的事務處理,此時需由應用系統進行控制,避免對同一記錄進行處理產生的衝突。
方式二:配置源為active,目標為standing-by,在源出現故障時,切換到目標資料庫。
雙向複製方案配置如下圖所示:
圖 11 雙向複製方案
如上圖所示,在源端和目標端都需要配置extract和replicat來實現雙向複製。在雙向複製方案中最重要的避免迴圈,即在由源資料庫向目標端插入資料的時候,不應該再產生trail(cdc資料),否則將進入乙個死迴圈。goldengate採用排除同步時使用者的方式來實現雙向複製。
雙向複製方案可應用於客戶有特定複製需求的業務場景,具體實現過程見下面的描述。
如圖1-1所示,在雙向複製的過程中,每個資料庫既是源資料庫又是目標資料庫,為便於理解,在下面的描述中,我們將左面的資料庫稱為「源資料庫」,右面的資料庫稱為「目標資料庫」。
本文以「tcustmer」表作為同步的資料庫表。建表指令碼如下:
create table tcustmer
( cust_code varchar2(4),
namevarchar2(30),
cityvarchar2(20),
statechar(2),
primary key (cust_code)
using index
);該使用者用於在goldengate中將源資料庫中的資料同步到目標資料庫,該使用者必須能夠訪問源資料庫使用者和目標資料庫使用者下面的所有資料。
本文中以「gg_bi」作為同步使用者。
本文中以「gg_src」作為源資料庫使用者。
本文中以「gg_tgt」作為目標資料庫使用者。
ggsci > add extract extbi, tranlog, begin now, threads 1
extract added.
ggsci > edit params extbi
extract extbi
userid gg_bi, password gg_bi ――該使用者為同步使用者
tranlogoptions excludeuser gg_bi ――將同步使用者進行排除,避免迴圈
rmthost , mgrport 10002
rmttrail ./dirdat/bi
table gg_ ――這裡為實際要同步的使用者及其資料庫表
ggsci > add rmttrail ./dirdat/bi, extract extbi,megabytes 5
ggsci > start extract extbi
下面是增加check point,如果已經配置檢查點,則不用再次執行
ggsci> edit params ./globals
增加下面一行
checkpointtable gg_
ggsci> exit ――重新登入以啟用global引數
shell> ggsci
ggsci> dblogin userid gg_src, password gg_src
ggsci> add checkpointtable
ggsci > add replicat repbi, exttrail ./dirdat/bi
replicat added.
ggsci > edit param repbi
replicat repbi
userid gg_bi, password gg_bi ――該使用者為同步使用者
handlecollisions
assumetargetdefs
discardfile ./dirrpt/ purge
map gg_ target gg_
ggsci > start replicat repbi
檢視extract和replicat狀態,確保都正常執行
ggsci > info all
program status group lagtime since chkpt
manager running
extract running extbi 00:00:00 00:00:09
replicat running repbi 00:00:00 00:00:04
ggsci > add extract extbi, tranlog, begin now, threads 1
extract added.
ggsci > edit params extbi
extract extbi
userid gg_bi, password gg_bi ――該使用者為同步使用者
tranlogoptions excludeuser gg_bi ――將同步使用者進行排除,避免迴圈
rmthost , mgrport 10001
rmttrail ./dirdat/bi
table gg_
ggsci > add rmttrail ./dirdat/bi, extract extbi,megabytes 5
ggsci > start extract extbi
建立check point,同上,這裡省略。
ggsci > add replicat repbi, exttrail ./dirdat/bi
replicat added.
ggsci > edit param repbi
replicat repbi
userid gg_bi, password gg_bi ――該使用者為同步使用者
handlecollisions
assumetargetdefs
discardfile ./dirrpt/ purge
map gg_ target gg_
ggsci > start replicat repbi
檢視extract和replicat狀態,確保都正常執行
ggsci > info all
program status group lagtime since chkpt
manager running
extract running extbi 00:00:00 00:00:03
replicat running repbi 00:00:00 00:00:01
以gg_src登入源資料庫,執行insert操作:
insert into tcustmer values('will','bg software co.','seattle','wa');
以gg_tgt登入目標資料庫,執行insert操作:
insert into tcustmer values('jane','rocky flyer inc.','denver','co');
在源資料庫和目標資料庫檢視tcustomer表,都應該包含新插入的兩條記錄。
在源資料庫和目標資料庫進行其它操作測試,測試後源資料庫和目標資料庫資料應保持一致。
HP SureStore DDS 4備份解決方案
dds 4大大增強了領先的網路備份技術 簡介 1998年4月8日,dds製造商集團通過了新一代數位化資料儲存 dds 的技術規範。dds 4規範確認了20gb的非壓縮本機容量 典型壓縮為40gb dds製造商的發展過程早已表明了這一點,同時也宣告了本機傳輸率範圍在每秒1.5mb與3mb之間。dds ...
有線電視接入網雙向改造解決方案
有線電視接入網 雙向改造解決方案 深圳速浪數字技術 二o一o年三月 隨著科學技術的進步,epon和eoc技術在廣電網雙向改造中的應用,給有線電視網路經營者帶來了無限的商機。epon和eoc技術使有線電視網的資源充分發揮了應有的作用,也可為有線電視網路的經營者創造很好的經濟效益和社會效益。當前有線電視...
壩頂500噸雙向門式啟閉機門機移交工作方案
壩頂5000 250kn雙向門式啟閉機 移交工作方案 2013年4月 一 必備條件 1 裝置安裝完畢,並完成相關除錯 試驗。2 具備正常供電條件。3 若試驗條件不能滿足要求,採取臨時措施時,替代條件必須符合正常條件要求。二 標準及依據 1 現行相關國家規程 規範及標準 2 裝置招投標檔案 設計檔案 ...