hangcheck-timer模組

wtjiang2008發表於2014-02-11
從9.2.0.2版本開始,ORACLE RAC環境需要使用一個新的I/O fencing模組,叫做hangcheck-timer模組。
這個模組用來代替Watchdog模組,提供類似的fencing功能。Hangcheck-timer模組是標準的linux2.4以
上的核心中的一個子功能被髮布。
1. hangcheck-timer簡介
Hangcheck-timer應該在系統啟動的時候被載入, 並對於能夠影響RAC節點穩定性的長時間的系統操作HANG進行核心監控。
它執行在核心級別並使用Time Stamp Counter(TSC)來捕捉排程的延遲和節點HANG。這是透過設定一個timer,然後檢查這
個timer的fires情況來判斷是否延遲是否超過了誤差的幅度。如果這個週期超過了允許的時間(也就是hangcheck_tick+hangcheck_margin秒),機器將會被重啟,如果是CPU資源不足的時候,Hangcheck-timer將不會導致重啟。

Hangcheck-timer有三個配置引數:

hangcheck_tick:定義了hangcheck-timer檢查節點是否hang的頻率,單位是秒,預設是60秒
hangcheck_margin:定義期望的和真正的scheduling之間允許的誤差,單位是秒,預設值是180秒
hangcheck_reboot:定義瞭如果核心在hangcheck-tick和hangcheck-margin相加的時間內響應失敗的話,hangcheck-timer是否重啟節點。如果hangcheck_reboot的值大於等於1,hangcheck-timer模組將會重啟系統;如果設定為0,則即使系統hang的時候hangcheck-timer也不會重啟系統。在linux 2.4的核心中,這個預設值是1;在2.6的核心中,預設值是0。
當hangcheck_reboot=1並且滿足下面的公式時,hangcheck-timer將reboot系統
system hang time > (hangcheck_tick + hangcheck_margin)
所有的hangcheck-timer的引數的預設值必須在載入核心模組的時候被顯式的覆蓋,不同的oracle版本可以按照下面來設定:
9i: 假如"oracle misscount"的預設設定是220秒,則hangcheck_tick=30 hangcheck_margin=180 hangcheck_reboot=1
10g/11g: 假如"CSS misscount"的設定是30或者60秒,則hangcheck_tick=1 hangcheck_margin=10 hangcheck_reboot=1
不過對於目前大多數的環境,我問了幾個朋友的rac這幾個引數的設定一般為
misscount=220
hangcheck_tick=30
hangcheck_margin=180
注意:你必須設定叢集的misscount值大於hangcheck_tick + hangcheck_margin之和

2. hangcheck-timer.ko模組安裝
hangcheck-timer被預設安裝在linux版本 2.4.9-e.12 及之上版本中,可以用如下命令核查hangcheck-timer是否安裝。
[root@rac2 oracle]# find /lib -name "hangcheck-timer.ko"
/lib/modules/2.6.9-78.EL/kernel/drivers/char/hangcheck-timer.ko
/lib/modules/2.6.9-89.0.23.ELxenU/kernel/drivers/char/hangcheck-timer.ko
/lib/modules/2.6.9-78.ELsmp/kernel/drivers/char/hangcheck-timer.ko
有以上輸出,代表已經安裝了
modprobe命令將在模組路徑/lib/modules/'uname -r'/中搜尋所有的模組和檔案。
3. 配置hangcheck-timer
修改配置檔案/etc/modprobe.conf ,我的這個檔案的內容如下:
[root@rac2 oracle]# more /etc/modprobe.conf
alias eth0 pcnet32
alias eth1 pcnet32
alias scsi_hostadapter mptbase
alias scsi_hostadapter1 mptscsi
alias scsi_hostadapter2 mptspi
alias scsi_hostadapter3 mptsas
alias scsi_hostadapter4 mptscsih
alias scsi_hostadapter5 ata_piix

options hangcheck-timer hangcheck_tick=30 hangcheck_margin=180
[root@rac2 oracle]#
4. 載入hangcheck-timer模組

這個模組是在oracle需要時自動呼叫的,可以不需要用modprobe或insmod命令來放在啟動檔案載入。但是一般的條件下,
我們還是把這個命令放在系統引導檔案中。
為了使得在系統啟動的時候就自動載入,可以把上面的命令新增到/etc/rc.d/rc.local或者/etc/init.d/boot.local或者
/etc/rc.local中,這個根據不同的發行版來決定。
例如:
# echo "/sbin/modprobe hangcheck-timer" >> /etc/rc.local
說明:
在oracle linux、紅帽linux4/5或者SUSE linux9/10中,hangcheck-timer模組使用modprobe命令替換insmod命令
(因為modprobe更靈巧些)來進行載入:

# modprobe hangcheck-timer hangcheck_tick=1 hangcheck_margin=10 hangcheck_reboot=1

5. 查證hangcheck-timer的引數是否正確的方法
[root@rac2 ~]# /sbin/lsmod |grep hangcheck
hangcheck_timer         7897  0
hangcheck-timer的啟動資訊都會記錄在系統日誌裡“ /var/log/messages”
重啟時會記錄"Hangcheck: hangcheck is restarting the machine"資訊到/var/log/messages
如果你看到/var/log/messages中有"Hangcheck: hangcheck value past margin!"訊息,表示系
統需要重啟但是沒有重啟,因為hangcheck-reboot引數沒有設定為1。

[root@rac2 ~]#
[root@rac2 ~]# su -
[root@rac2 ~]# grep hangcheck /var/log/messages |tail -2
May 10 10:03:56 rac2 kernel: Hangcheck: starting hangcheck timer 0.9.0 (tick is 30 seconds, margin is 180 seconds).
[root@rac2 ~]#

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/527318/viewspace-1079368/,如需轉載,請註明出處,否則將追究法律責任。

相關文章