您好,登錄后才能下訂單哦!
最近有幾項業務下線,需要從一張表中刪除6.8億多條數據。想辦法把數據刪除掉了,但對應的ogg災備端復制時有了的延遲,而且延遲的時間起來越長。
對于表太多造成的延遲可以把所有表分為多個組來做復制,于是想復制進程是否可以對單表復制開并行。上網查到了相關的資料,可以使用@RANGE函數對單表作表內的拆分,通過對表上主鍵列作hash算法將該表上發生的變更均分到多個replicat上來降低單個replicat組件的負載。
動手實驗一下:
ogg搭建過程不再重復,從網上就可以查到。
實驗過程:模擬在源端對表scott.emp1做大量的dml操作,復制進程出現延遲,在目標端對復制表scott.emp1開并行3個進程。
源端插入數據:
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
目標端有延遲
GGSCI (rhel5) 15> info all Program Status Group Lag Time Since Chkpt MANAGER RUNNING REPLICAT RUNNING REPTAB 00:09:08 00:00:04
停掉復制進程
拆分復制進程,對表scott.emp1分三個進程復制
#源復制進程
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 ;
源進程修改為
map scott.emp1, target scott.emp1 ,FILTER(@RANGE(1,3));多復制出兩個參數文件:
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));
添加兩個復制進程,extseqno和extrba與源進程一致
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.
啟動復制進程
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
查看數據庫里ogg對應的會話
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)
可以看到出現了三個會話,都是對應的對表scott.emp1的插入語句。也就是說實現了對scott.emp1表的并行復制。
MOS上也有相關的文檔介紹相應的功能,文檔:1320133.1和1512633.1
參考:blog.itpub.net/15187685/viewspace-1219731/
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。