OGG案例分享:由於表缺少唯一性索引導致DML操作效能降低
環境資訊
源 端:Oracle 11.2.0.4 RAC R2
目標端:Oracle 11.2.0.4 RAC R2
源端是生產庫。目標端資料庫採用ogg,按表名 從生產庫同步至與生產庫配置相同的交換資料庫內的資料,提供客戶端只讀訪問。
故障處理思路
1.巡檢中發現交換庫端ogg的replicat程序為running狀態,且有延遲
GGSCI (hxbak2) 1> info all
Program Status Group Lag at Chkpt Time Since Chkpt
MANAGER RUNNING
EXTRACT RUNNING EX_PUB unknown 00:00:09
EXTRACT RUNNING EX_TLKZX 00:00:00 00:00:09
EXTRACT RUNNING EX_WEB 00:00:00 00:00:00
EXTRACT RUNNING EX_WEBR 00:00:00 00:00:04
EXTRACT RUNNING P_PUB 00:00:00 00:00:08
EXTRACT RUNNING P_TLKZX 00:00:00 00:00:05
EXTRACT RUNNING P_WEB 00:00:00 00:00:03
EXTRACT RUNNING P_WEBR 00:00:00 00:00:03
EXTRACT RUNNING P_WEBRB 00:00:00 00:00:02
REPLICAT RUNNING R_AC01 00:00:00 00:00:01
REPLICAT RUNNING R_OTH 00:00:00 00:00:01
REPLICAT RUNNING R_OTHB 00:00:00 00:00:01
REPLICAT RUNNING R_TLSI 43:47:46 02:35:48
REPLICAT RUNNING R_TLSIWW 00:00:00 00:00:00
REPLICAT RUNNING R_WEB 00:00:00 00:00:08
REPLICAT RUNNING R_WEBR 00:00:00 00:00:09
2.首先檢視本地檔案系統/ogg的空間使用情況 : #df -g
$df -g
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/dev/hd4 5.00 4.70 6% 10927 1% /
/dev/hd2 10.00 5.99 41% 62354 5% /usr
/dev/hd9var 5.00 4.15 18% 9020 1% /var
/dev/hd3 5.00 3.85 24% 3069 1% /tmp
/dev/hd1 6.00 1.00 84% 2120 1% /home
/dev/hd11admin 0.25 0.25 1% 5 1% /admin
/proc - - - - - /proc
/dev/hd10opt 5.00 4.71 6% 10590 1% /opt
/dev/livedump 0.25 0.25 1% 4 1% /var/adm/ras/livedump
/dev/fslv00 40.00 13.20 67% 499465 14% /u01
/dev/ogg_lv 350.00 334.80 5% 941 1% /ogg
/dev/explv 590.00 238.61 60% 419 1% /exp_backup
/dev/ITMLV 4.00 3.08 23% 4353 1% /opt/IBM/ITM
⚠️發現/ogg使用情況正常
3.檢視延遲程序當前事物狀態 : send r_tlsi statusGGSCI (hxbak2) 3> send R_TLSI status
Sending STATUS request to REPLICAT R_TLSI ...
Current status: Processing data
Sequence #: 15103
RBA: 83501358
5549 records in current transaction
GGSCI (hxbak2) 4> !
send R_TLSI status
Sending STATUS request to REPLICAT R_TLSI ...
Current status: Processing data
Sequence #: 15103
RBA: 83502483
5553 records in current transaction
GGSCI (hxbak2) 5> !
send R_TLSI status
Sending STATUS request to REPLICAT R_TLSI ...
Current status: Processing data
Sequence #: 15103
RBA: 83503334
5556 records in current transaction
⚠️發現延遲程序正在同步1503號歸檔日誌的內的事務
4.檢視延遲程序當前事物時間點狀態:stats r_tlsi hourly
Sending STATS request to REPLICAT R_TLSI ...
Start of Statistics at 2017-11-02 12:51:12.
Replicating from TLSI.ZE31 to TLSI.ZE31:
*** Hourly statistics since 2017-11-02 12:00:00 ***
No database operations have been performed.
Replicating from TLSI.KC22 to TLSI.KC22:
*** Hourly statistics since 2017-11-02 12:00:00 ***
No database operations have been performed.
*** Hourly statistics since 2017-11-02 12:00:00 ***
Total inserts 0.00
Total updates 0.00
Total deletes 3270.00
Total discards 0.00
Total operations 3270.00
5.在目標端檢視 tlsi 使用者在系統層面的程序 :ps -ef | grep tlsi
⚠️返回結果省略
6.在資料庫內檢視 r_tlsi 使用者下的會話資訊
SQL>select inst_id,sid,username,module,event,sql_id,last_call_et
SQL>from gv$session
SQL>where module like '%R_TLSI%' ;
INST_ID SID USERNAME MODULE EVENT SQL_ID LAST_CALL_ET
---------- ---------- ---------- ------------------------------ ------------------------------ ------------- ------------
1 756 OGG OGG-R_TLSI-OPEN_DATA_SOURCE SQL*Net message from client cn41135fzbkdw 1
7.在資料庫內根據sid和inst_id檢視會話資訊
SQL>select inst_id,sid,username,module,event,sql_id,last_call_et
SQL>from gv$session
SQL>where inst_id=1 and sid=756;
8。根據步驟7 在資料庫內檢視sql的執行計劃
SQL> select * from table(dbms_xplan.display_awr('步驟7查詢得到的sql_id'))
根據查詢結果,針對不同結果進一步優化