最近有幾項業(yè)務(wù)下線,需要從一張表中刪除6.8億多條數(shù)據(jù)。想辦法把數(shù)據(jù)刪除掉了,但對應(yīng)的ogg災(zāi)備端復(fù)制時有了的延遲,而且延遲的時間起來越長。
薌城網(wǎng)站制作公司哪家好,找成都創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、成都響應(yīng)式網(wǎng)站建設(shè)公司等網(wǎng)站項目制作,到程序開發(fā),運營維護(hù)。成都創(chuàng)新互聯(lián)2013年開創(chuàng)至今到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗和運維經(jīng)驗,來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選成都創(chuàng)新互聯(lián)。對于表太多造成的延遲可以把所有表分為多個組來做復(fù)制,于是想復(fù)制進(jìn)程是否可以對單表復(fù)制開并行。上網(wǎng)查到了相關(guān)的資料,可以使用@RANGE函數(shù)對單表作表內(nèi)的拆分,通過對表上主鍵列作hash算法將該表上發(fā)生的變更均分到多個replicat上來降低單個replicat組件的負(fù)載。
動手實驗一下:
ogg搭建過程不再重復(fù),從網(wǎng)上就可以查到。
實驗過程:模擬在源端對表scott.emp1做大量的dml操作,復(fù)制進(jìn)程出現(xiàn)延遲,在目標(biāo)端對復(fù)制表scott.emp1開并行3個進(jìn)程。
源端插入數(shù)據(jù):
SQL> insert into scott.emp1 select * from scott.emp; 14 rows created. SQL> commit; Commit complete. SQL> insert into scott.emp1 select * from scott.emp1; 14 rows created. SQL> / 28 rows created. SQL> / ....... SQL> / 1835008 rows created. SQL> commit; Commit complete. SQL> select count(*) from scott.emp1; COUNT(*) ---------- 3670016目標(biāo)端有延遲
GGSCI (rhel5) 15> info all Program Status Group Lag Time Since Chkpt MANAGER RUNNING REPLICAT RUNNING REPTAB 00:09:08 00:00:04停掉復(fù)制進(jìn)程
拆分復(fù)制進(jìn)程,對表scott.emp1分三個進(jìn)程復(fù)制
#源復(fù)制進(jìn)程
GGSCI (rhel5) 23> view params reptab replicat reptab SETENV (NLS_LANG="AMERICAN_AMERICA.ZHS16GBK") SETENV (ORACLE_SID="orcl") userid ogg,password 123456 reperror default,discard assumetargetdefs discardfile /goldengate/dirrpt/reptab.dsc,append,megabytes 1024 gettruncates dynamicresolution map scott.emp1, target scott.emp1 ; map scott.emp, target scott.emp ;源進(jìn)程修改為
map scott.emp1, target scott.emp1 ,FILTER(@RANGE(1,3));多復(fù)制出兩個參數(shù)文件:
GGSCI (rhel5) 1> view params reptab02 replicat reptab02 SETENV (NLS_LANG="AMERICAN_AMERICA.ZHS16GBK") SETENV (ORACLE_SID="orcl") userid ogg,password 123456 reperror default,discard assumetargetdefs discardfile /goldengate/dirrpt/reptab.dsc,append,megabytes 1024 gettruncates dynamicresolution map scott.emp1, target scott.emp1 ,FILTER (@RANGE(2,3)); GGSCI (rhel5) 2> view params reptab03 replicat reptab03 SETENV (NLS_LANG="AMERICAN_AMERICA.ZHS16GBK") SETENV (ORACLE_SID="orcl") userid ogg,password 123456 reperror default,discard assumetargetdefs discardfile /goldengate/dirrpt/reptab.dsc,append,megabytes 1024 gettruncates dynamicresolution map scott.emp1, target scott.emp1 ,FILTER (@RANGE(3,3));添加兩個復(fù)制進(jìn)程,extseqno和extrba與源進(jìn)程一致
GGSCI (rhel5) 9> info reptab REPLICAT REPTAB Last Started 2017-05-05 16:18 Status ABENDED Checkpoint Lag 00:09:08 (updated 00:09:38 ago) Log Read Checkpoint File ./dirdat/tl000003 2017-05-05 16:09:11.000187 RBA 194186157 GGSCI (rhel5) 10> add replicat reptab02, exttrail ./dirdat/tl,extseqno 3 extrba 194186157,checkpointtable ogg.checkpoint REPLICAT added. GGSCI (rhel5) 11> add replicat reptab03, exttrail ./dirdat/tl,extseqno 3 extrba 194186157,checkpointtable ogg.checkpoint REPLICAT added.啟動復(fù)制進(jìn)程
GGSCI (rhel5) 12> start reptab* Sending START request to MANAGER ... REPLICAT REPTAB starting Sending START request to MANAGER ... REPLICAT REPTAB02 starting Sending START request to MANAGER ... REPLICAT REPTAB03 starting查看數(shù)據(jù)庫里ogg對應(yīng)的會話
SQL> select module,sql_id from v$session where username='OGG'; MODULE SQL_ID ------------------------------------------------------------------------------------------------------------------------------------------------ --------------------------------------- OGG-REPTAB03-OPEN_DATA_SOURCE 1cxrusnmn01hz OGG-REPTAB-OPEN_DATA_SOURCE 1cxrusnmn01hz OGG-REPTAB02-OPEN_DATA_SOURCE 1cxrusnmn01hz SQL> select sql_text from v$sqlarea where sql_id='1cxrusnmn01hz'; SQL_TEXT -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- INSERT INTO "SCOTT"."EMP1" ("EMPNO","ENAME","JOB","MGR","HIREDATE","SAL","COMM","DEPTNO") VALUES (:a0,:a1,:a2,:a3,:a4,:a5,:a6,:a7)可以看到出現(xiàn)了三個會話,都是對應(yīng)的對表scott.emp1的插入語句。也就是說實現(xiàn)了對scott.emp1表的并行復(fù)制。
MOS上也有相關(guān)的文檔介紹相應(yīng)的功能,文檔:1320133.1和1512633.1
參考:blog.itpub.net/15187685/viewspace-1219731/
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。