Oracle RAC集群時間同步告警PRVF-5436&PRVF-9652
本文轉載自微信公眾號「DBA閑思雜想錄」,作者瀟湘隱者。轉載本文請聯系DBA閑思雜想錄公眾號。
接手了一套RAC數據庫(Oracle 11g),結果在巡檢的時候發現集群節點間的時鐘同步有下面告警信息,如下所示:
- $ cluvfy comp clocksync -verbose
- Verifying Clock Synchronization across the cluster nodes
- Checking if Clusterware is installed on all nodes...
- Check of Clusterware install passed
- Checking if CTSS Resource is running on all nodes...
- Check: CTSS Resource running on all nodes
- Node Name Status
- ------------------------------------ ------------------------
- oracle1 passed
- Result: CTSS resource check passed
- Querying CTSS for time offset on all nodes...
- Result: Query of CTSS for time offset passed
- Check CTSS state started...
- Check: CTSS state
- Node Name State
- ------------------------------------ ------------------------
- oracle1 Observer
- CTSS is in Observer state. Switching over to clock synchronization checks using NTP
- Starting Clock synchronization checks using Network Time Protocol(NTP)...
- NTP Configuration file check started...
- The NTP configuration file "/etc/ntp.conf" is available on all nodes
- NTP Configuration file check passed
- Checking daemon liveness...
- Check: Liveness for "ntpd"
- Node Name Running?
- ------------------------------------ ------------------------
- oracle1 yes
- Result: Liveness check passed for "ntpd"
- Check for NTP daemon or service alive passed on all nodes
- Checking NTP daemon command line for slewing option "-x"
- Check: NTP daemon command line
- Node Name Slewing Option Set?
- ------------------------------------ ------------------------
- oracle1 no
- Result:
- NTP daemon slewing option check failed on some nodes
- PRVF-5436 : The NTP daemon running on one or more nodes lacks the slewing option "-x"
- Result: Clock synchronization check using Network Time Protocol(NTP) failed
- PRVF-9652 : Cluster Time Synchronization Services check failed
- Verification of Clock Synchronization across the cluster nodes was unsuccessful on all the specified nodes.
出現上面錯誤提示,是因為RAC集群服務器的NTP服務沒有啟用-x選項,如果沒有開啟slewing 選項,在時間差異超過特定(取決于平臺)閾值時,NTP 將向前或向后調整系統時鐘。大幅度向后調整時間會導致 Clusterware 以為錯過了簽到,從而發生節點驅逐的情況。出于此原因,強烈建議將 NTP 配置調整為slewing time (加快或減慢)時鐘時間以同步時間,以防止此類驅逐情況的發生。
What is slewing?
The NTP daemon will periodically update the system clock with the time from a reference clock. If the time on the reference clock is behind the time on the system clock, the system clock will be set backwards in one large decrement. Such swift changes in time can lead to Oracle shutting down the node due to inconsistent timers. To avoid this problem, NTP can be configured to slew the clock. When slewing the clock the time on system is incremented slower until the system clock is in sync with the time on the reference system.
“-x”選項用于阻止ntp向后調整時鐘,向后則意味著時間回逆,可能導致數據庫、集群出現重啟.驅逐等問題。
之前維護這套RAC的人可能在安裝的時候就從未留意過這個問題,那么問題來了,如果是安裝、調試階段,直接修改配置,重啟NTP服務就完事了,但是現在這套RAC正在對外提供關鍵服務,那么可以重啟NTP服務嗎?會不會引發什么問題呢?
答案是不會,如果兩個(或多個)節點之間沒有時間差,完全可以重啟NTP服務,不影響RAC的集群服務。你可以一個節點一個節點處理。當然這個也是經過驗證確認過的。
下面是關于CTSS與NTP的關系的相關知識點:
從Oracle 11gR2 RAC開始使用Cluster Time Synchronization Service(CTSS)同步各節點的時間,當安裝程序發現NTP協議處于非活動狀態時,安裝集群時間同步服務將以活動模式(active)自動進行安裝并同步所有節點的時間。如果發現配置了NTP,則以觀察者模式(observer mode)啟動集群時間同步服務,Oracle Clusterware不會在集群中進行活動的時間同步。
在RAC中,集群的時間應該是保持同步的,否則可能導致很多問題,例如:依賴于時間的應用會造成數據的錯誤,各種日志打印的順序紊亂,這將會影響問題的診斷,嚴重的可能會導致集群宕機或者重新啟動集群時節點無法加入集群。
在Oracle 11gR2前,集群的時間是由NTP同步的,而在11gR2后,Oracle引入了CTSS組件,如果系統沒有配置NTP,則由CTSS來同步集群時間。NTP和CTSS是可以共存的,且NTP的優先級要高于CTSS,也就是說,如果系統中同時有NTP和CTSS,那么集群的時間是由NTP同步的,CTSS會處于觀望(Observer)模式,只有當集群關閉所有的NTP服務,CTSS才會處于激活(Active)模式。在一個集群中,只要有一個節點的ntp處于活動狀態,那么集群的所有節點的CTSS都會處于激活(Active)模式。需要注意的是,要讓CTSS處于激活(Active)模式,則不僅要關閉ntp服務(/sbin/service ntpd stop),還要刪除/etc/ntp.conf文件(mv /etc/ntp.conf /etc/ntp.conf.bak),否則不能啟用CTSS。
具體操作步驟如下:
- # more /etc/sysconfig/ntpd
- # Drop root to id 'ntp:ntp' by default.
- OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
修改/etc/sysconfig/ntpd的配置
修改前
- OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
修改后
- OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid -g"
RAC集群的操作系統是RHEL 6,它的服務是通過service啟動,所以通過下面命令重啟NTP服務解決問題:
- service ntpd restart
參考資料:
https://www.oracledistilled.com/grid-infrastructure/prvf-5439-ntp-daemon-does-not-have-slewing-option-%E2%80%9C-x%E2%80%9D-set-on-node/
https://www.cnblogs.com/lhrbest/p/9253449.html