您好,登錄后才能下訂單哦!
Oracle Study之--Oracle等待事件(2)
Control file parallel write
當數據庫中有多個控制文件的拷貝時,Oracle 需要保證信息同步地寫到各個控制文件當中,這是一個并行的物理操作過程,因為稱為控制文件并行寫,當發生這樣的操作時,就會產生control file parallel write等待事件。
控制文件頻繁寫入的原因很多,比如:
· 日志切換太過頻繁,導致控制文件信息相應地需要頻繁更新。
· 系統I/O 出現瓶頸,導致所有I/O出現等待。
當系統出現日志切換過于頻繁的情形時,可以考慮適當地增大日志文件的大小來降低日志切換頻率。
當系統出現大量的control file parallel write 等待事件時,可以通過比如降低控制文件的拷貝數量,將控制文件的拷貝存放在不同的物理磁盤上的方式來緩解I/O 爭用。
這個等待事件包含三個參數:
Files: Oracle 要寫入的控制文件個數。
Blocks: 寫入控制文件的數據塊數目。
Requests: 寫入控制請求的I/O 次數。
Control file sequential read
當數據庫需要讀取控制文件上的信息時,會出現這個等待事件,因為控制文件的信息是順序寫的,所以讀取的時候也是順序的,因此稱為控制文件順序讀,它經常發生在以下情況:
備份控制文件
RAC 環境下不同實例之間控制文件的信息共享
讀取控制文件的文件頭信息
讀取控制文件其他信息
這個等待事件有三個參數:
File#: 要讀取信息的控制文件的文件號。
Block#: 讀取控制文件信息的起始數據塊號。
Blocks: 需要讀取的控制文件數據塊數目。
模擬案例:
1、模擬事務處理
16:59:48 SYS@ test1>select username,sid,serial# from v$session where username is not null; USERNAME SID SERIAL# ------------------------------ ---------- ---------- SCOTT 1 7 SYS 34 4 TOM 41 3 16:59:57 SCOTT@ test1>begin 17:04:05 2 for i in 1..1000000 loop 17:04:05 3 execute immediate 'insert into t1(id) values ('||i||')'; 17:04:05 4 end loop; 17:04:05 5 end; 17:04:05 6 / 17:00:00 TOM@ test1> begin 17:04:15 2 for i in 1..1000000 loop 17:04:15 3 execute immediate 'insert into scott.t1(id) values ('||i||')'; 17:04:15 4 end loop; 17:04:15 5 end; 17:04:15 6 /
2、查看等待事件:
17:05:40 SYS@ test1>select sid,event,p1,p2,p3,WAIT_TIME from v$session_wait where sid in (1,41); SID EVENT P1 P2 P3 WAIT_TIME ---------- -------------------------------------------------- ---------- ---------- ----- 1 latch: redo allocation 1993106152 182 0 -1 41 latch: cache buffers chains 2011026752 150 0 -1 Elapsed: 00:00:00.01 17:06:11 SYS@ test1>r 1* select sid,event,p1,p2,p3,WAIT_TIME from v$session_wait where sid in (1,41) SID EVENT P1 P2 P3 WAIT_TIME ---------- -------------------------------------------------- ---------- ---------- ------- 1 log file switch (checkpoint incomplete) 0 0 0 3 41 buffer busy waits 4 4048 1 94 Elapsed: 00:00:00.01 17:06:16 SYS@ test1>r 1* select sid,event,p1,p2,p3,WAIT_TIME from v$session_wait where sid in (1,41) SID EVENT P1 P2 P3 WAIT_TIME ---------- -------------------------------------------------- ---------- ---------- ----- 1 log file switch (checkpoint incomplete) 0 0 0 0 41 log file switch (checkpoint incomplete) 0 0 0 0 Elapsed: 00:00:00.02 17:06:18 SYS@ test1>r 1* select sid,event,p1,p2,p3,WAIT_TIME from v$session_wait where sid in (1,41) SID EVENT P1 P2 P3 WAIT_TIME ---------- -------------------------------------------------- ---------- ---------- ---------- ---------- 1 log buffer space 0 0 0 0 41 log buffer space 0 0 0 0 Elapsed: 00:00:00.01 17:06:20 SYS@ test1>r 1* select sid,event,p1,p2,p3,WAIT_TIME from v$session_wait where sid in (1,41) SID EVENT P1 P2 P3 WAIT_TIME ---------- -------------------------------------------------- ---------- ---------- ----- 1 log file switch (checkpoint incomplete) 0 0 0 134 41 log file switch (checkpoint incomplete) 0 0 0 3 Elapsed: 00:00:00.01 17:06:22 SYS@ test1>r 1* select sid,event,p1,p2,p3,WAIT_TIME from v$session_wait where sid in (1,41) SID EVENT P1 P2 P3 WAIT_TIME ---------- -------------------------------------------------- ---------- ---------- ---------- ---------- 1 latch: cache buffers chains 2011026752 150 0 -1 41 latch: cache buffers chains 2011026752 150 0 -1 Elapsed: 00:00:00.01
3、查看關于controlfile的事件
17:06:24 SYS@ test1>select EVENT ,TOTAL_WAITS,TIME_WAITED from v$system_event where event like '%control%'; EVENT TOTAL_WAITS TIME_WAITED -------------------------------------------------- ----------- ----------- control file sequential read 51623 326 control file parallel write 6327 5102 control file heartbeat 1 400 Elapsed: 00:00:00.02 17:07:31 SYS@ test1>r 1* select EVENT ,TOTAL_WAITS,TIME_WAITED from v$system_event where event like '%control%' EVENT TOTAL_WAITS TIME_WAITED -------------------------------------------------- ----------- ----------- control file sequential read 52314 329 control file parallel write 6410 5164 control file heartbeat 1 400 Elapsed: 00:00:00.03 17:07:41 SYS@ test1>r 1* select EVENT ,TOTAL_WAITS,TIME_WAITED from v$system_event where event like '%control%' EVENT TOTAL_WAITS TIME_WAITED -------------------------------------------------- ----------- ----------- control file sequential read 52597 330 control file parallel write 6433 5177 control file heartbeat 1 400 Elapsed: 00:00:00.02
4、查看告警日志:
Beginning log switch checkpoint up to RBA [0x438.2.10], SCN: 1762466 Thread 1 advanced to log sequence 1080 (LGWR switch) Current log# 3 seq# 1080 mem# 0: /u01/app/oracle/oradata/redo03a.log Fri Jul 25 17:10:26 2014 Archived Log entry 1065 added for thread 1 sequence 1079 ID 0x4906548b dest 1: Thread 1 cannot allocate new log, sequence 1081 Checkpoint not complete Current log# 3 seq# 1080 mem# 0: /u01/app/oracle/oradata/redo03a.log Completed checkpoint up to RBA [0x438.2.10], SCN: 1762466 Beginning log switch checkpoint up to RBA [0x439.2.10], SCN: 1762522 Thread 1 advanced to log sequence 1081 (LGWR switch) Current log# 4 seq# 1081 mem# 0: /u01/app/oracle/oradata/redo04a.log Fri Jul 25 17:10:29 2014 Archived Log entry 1066 added for thread 1 sequence 1080 ID 0x4906548b dest 1: Thread 1 cannot allocate new log, sequence 1082 Checkpoint not complete Current log# 4 seq# 1081 mem# 0: /u01/app/oracle/oradata/redo04a.log Completed checkpoint up to RBA [0x439.2.10], SCN: 1762522 Fri Jul 25 17:10:32 2014 Beginning log switch checkpoint up to RBA [0x43a.2.10], SCN: 1762575 Thread 1 advanced to log sequence 1082 (LGWR switch) Current log# 3 seq# 1082 mem# 0: /u01/app/oracle/oradata/redo03a.log Archived Log entry 1067 added for thread 1 sequence 1081 ID 0x4906548b dest 1:
5、查看日志組信息
17:16:22 SYS@ test1>select group#,sequence#,status,bytes/1024/1024 from v$log; GROUP# SEQUENCE# STATUS BYTES/1024/1024 ---------- ---------- ---------------- --------------- 3 1082 CURRENT 4 4 1081 INACTIVE 4 Elapsed: 00:00:00.03 日志組size太小,日志組數量較少,日志切換太頻繁,導致產生大量的控制文件讀和寫,調整日志組的size,并增加日志組的個數。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。