您好,登錄后才能下訂單哦!
本篇內容介紹了“OGG怎么實現兩臺Oracle數據庫的同步”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
首先我們看看實驗環(huán)境
環(huán)境
源端是一個單實例
Oracle CENTOS 6+ ORACLE 10.2.0.4
IP :192.168.56.101
目標端是一個單實例
Oracle CENTOS 6+ ORACLE 10.2.0.4
IP :192.168.56.102
兩臺主機均已創(chuàng)建數據庫,sid分別為devdb 和 emrep
配置devdb 到 emrep的數據同步
goldengate版本11.2.1.0
1.配置數據庫信息
在源端數據庫中打開歸檔模式
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/archive1
Oldest online log sequence 180
Next log sequence to archive 181
Current log sequence 181
若處于非歸檔模式,則改為歸檔模式:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
在源端數據庫中打開force logging
SQL> select force_logging from v$database;
FOR
---
NO
SQL> alter database force logging;
Database altered.
SQL> select force_logging from v$database;
FOR
---
YES
在源端數據庫中打開supplemental log
SQL> select supplemental_log_data_min from v$database;
SUPPLEME
--------
NO
SQL> alter database add supplemental log data;
Database altered.
切換日志,使更改生效
SQL> alter system switch logfile;
System altered.
SQL> select supplemental_log_data_min from v$database;
SUPPLEME
--------
YES
在源端數據庫中關閉回收站
官方的說明是,由于一個已知的問題,回收站會對DDL觸發(fā)器產生影響,因此需要關閉。由此可見,我們只需要在源庫中關閉回收站即可。
SQL> show parameter recyclebin
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
recyclebin string on
SQL> alter system set recyclebin=off;
System altered.
SQL> show parameter recyclebin
NAME TYPE VALUE
------------------------------------ -------------------------------
recyclebin string OFF
創(chuàng)建goldengate數據庫用戶(源和目標)
注意:源和目標端都需要
[oracle@rac1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Fri Jan 9 11:56:28 2015
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 32bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create tablespace goldengate;
Tablespace created.
SQL> create user goldengate identified by goldengate default tablespace goldengate;
User created.
SQL> grant connect,resource to goldengate;
Grant succeeded.
SQL> grant execute on utl_file to goldengate;
Grant succeeded.
SQL>
抽取進程使用的數據庫用戶需要額外的權限,我們將這些權限也授予數據庫用戶goldengate(在源端數據庫中執(zhí)行)
SQL> exec dbms_streams_auth.grant_admin_privilege('GOLDENGATE');
PL/SQL procedure successfully completed.
SQL> grant insert on system.logmnr_restart_ckpt$ to goldengate;
Grant succeeded.
SQL> grant update on sys.streams$_capture_process to goldengate;
Grant succeeded.
SQL> grant become user to goldengate;
Grant succeeded.
SQL>
為了確保GoldenGate正常運行,特別是在目標端,賦予goldengate用戶DBA權限:
SQL> grant dba to goldengate;
2.GoldenGate安裝環(huán)境
解壓goldengate安裝文件到安裝目錄
安裝GoldenGate軟件很簡單,解壓即可
以goldengate用戶登錄
[goldengate@rac1 goldengateMedia]$ mkdir /opt/gg/goldengate、
[goldengate@rac1 goldengateMedia]$ cp ggs_Linux_ora10g_.tar /opt/gg/goldengate
[goldengate@rac1 goldengateMedia]$ cd /opt/gg/goldengate
[goldengate@rac1 goldengate]$ tar -xvf ggs_Linux_ora10g.tar
配置環(huán)境變量
源端和目標端:
修改goldengate用戶的環(huán)境變量配置文件(ORACLE_SID按實際情況修改)
cat>>/home/goldengate/.bashrc<<EOF
ORACLE_HOME=/opt/app/oracle/product/10.2.0/db_1
export ORACLE_HOME
ORACLE_SID=devdb
export ORACLE_SID
GG_HOME=/opt/gg/goldengate
export GG_HOME
PATH=\$ORACLE_HOME/bin:$GG_HOME:\$PATH
export PATH
LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$GG_HOME:\$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
EOF
應用剛剛修改的環(huán)境變量,然后進入GoldenGate安裝目錄,執(zhí)行l(wèi)dd ggsci,確定需要的庫文件都能夠找到。如果出現共享庫文件無法找到,例如libnnz10.so => not found,檢查LD_LIBRARY_PATH環(huán)境變量的設置
[goldengate@ggdb goldengate]$ source ~/.bashrc
[goldengate@ggdb goldengate]$ cd $GG_HOME
[goldengate@ggdb goldengate]$ ldd ggsci
我們可以認為ogg的安裝其實就是一個解壓。非常簡單。
創(chuàng)建goldengate工作目錄
源端和目標端:
[goldengate@rac1 goldengate]$ cd $GG_HOME
[goldengate@rac1 goldengate]$ ./ggsci
GGSCI (rac1) 1> create subdirs
Creating subdirectories under current directory /opt/gg/goldengate
Parameter files /opt/gg/goldengate/dirprm: created
Report files /opt/gg/goldengate/dirrpt: created
Checkpoint files /opt/gg/goldengate/dirchk: created
……
GGSCI (gg1) 2> exit
源和目標端:
[goldengate@rac1 ~]$ mkdir /opt/gg/trails
[goldengate@rac1 ~]$ ls -l /opt/gg | grep trails
源端和目標端:
DYNAMICPORTLIST中配置了GoldenGate(extract和replicat)進程使用的端口范圍
PORT參數指定MANAGER使用的端口
AUTORESTART參數使抽取/復制進程失敗后自動重啟
配置MANAGER的參數,PURGEOLDEXTRACTS參數指定:當根據checkpoint發(fā)現已經完成抽取和復制的trail文件將被自動刪除,但保留最近10個。
PURGEDDLHISTORY和PURGEMARKERHISTORY分別刪除DDL歷史表和marker表中的過期數據,以控制它們不會變得過于龐大。
GGSCI (gg1) 1> edit params mgr
PORT 5898
PURGEOLDEXTRACTS /opt/gg/trails/w1*, USECHECKPOINTS, MINKEEPFILES 10
AUTORESTART ER *, RETRIES 3, WAITMINUTES 5
PURGEDDLHISTORY MINKEEPDAYS 3, MAXKEEPDAYS 5, FREQUENCYMINUTES 30
PURGEMARKERHISTORY MINKEEPDAYS 3, MAXKEEPDAYS 5, FREQUENCYMINUTES 30
源端:
GGSCI (rac1) 2> edit params ./globals
GGSCHEMA goldengate
目標端:
創(chuàng)建一個checkpoint表
replicat通過這個表來維護trail文件中的read position。這不是個必須的操作,如果沒有這個表,則通過一個磁盤文件來維護
GGSCI (ggdb) 2> dblogin userid goldengate,password goldengate
Successfully logged into database.
GGSCI (ggdb) 3> add checkpointtable goldengate.chkpoint
Successfully created checkpoint table GOLDENGATE.CHKPOINT.
GGSCI (ggdb) 4> edit params ./globals
“OGG怎么實現兩臺Oracle數據庫的同步”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。