星期三, 1月 06, 2016

[轉錄] 如何在各個平臺上配置NTP的微調模式

Ref:

https://blogs.oracle.com/Database4CN/entry/%E5%A6%82%E4%BD%95%E5%9C%A8%E5%90%84%E4%B8%AA%E5%B9%B3%E5%8F%B0%E4%B8%8A%E9%85%8D%E7%BD%AEntp%E7%9A%84%E5%BE%AE%E8%B0%83%E6%A8%A1%E5%BC%8F1

 

如何在各個平臺上配置NTP的微調模式

對於11.2之前的版本,很多環境的重啟原因(top5的情況)是由於NTP調整時間的步伐過大導致的,所以RAC環境中,我們建議使用者如果使用NTP,需要配置成微調模式;

 

具體重啟的原因,請大家參考Allen Gao寫的博客 :如何診斷節點重啟問題

 

 

這裡介紹幾個主流linuxunix平臺上NTP微調的配置方法:

 

 

For Linux

 

 

1.請確確認各節點的ntp包已經安裝 ,我這裡是個4.2.2的版本

 

 

[oracle@nascds10 ~]$ rpm -qa | grep ntp

 

 

ntp-4.2.2p1-9.el5_4.1

 

 

2.請編輯各個節點的ntp.conf文件

 

 

[oracle@nascds10 ~]$ su - root

 

 

Password:

 

 

[root@nascds10 ~]#  vi /etc/ntp.conf

 

 

#New ntp server added by Robinson

 

 

server  192.168.1.128 prefer  <<<<===========這裡是時鐘伺服器

 

 

restrict 192.168.7.0  mask 255.255.255.255 nomodify notrap #基於網段的限制(限制在網段192.168.7.0

 

 

broadcastdelay 0.008

 

 

[root@nascds11 ~]# vi /etc/ntp.conf

 

 

#New ntp server added by Robinson

 

 

server 192.168.7.71 prefer

 

 

broadcastdelay 0.008

 

 

3、配置ntpd的參數,我們主要強調的是要配置成"微調的模式" 也就是在options中要加入 -x的選項

 

 

[root@nascds10 ~]# vi /etc/sysconfig/ntpd

 

 

#The following item added by Robinson

 

 

#Set to 'yes' to sycn hw clock after successful ntpdate

 

 

SYNC_HWCLOCK=yes 

 

 

OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"

 

 

[root@nascds11 ~]# vi /etc/sysconfig/ntpd

 

 

The following item added by Robinson

 

 

SYNC_HWCLOCK=yes

 

 

OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"

 

 

4、自動啟動配置

 

 

[root@nascds10 ~]# chkconfig ntpd on

 

 

[root@nascds11 ~]# chkconfig ntpd on

 

 

5、重啟一下,使最新配置生效

 

 

[root@nascds10 ~]# service ntpd restart

 

 

Shutting down ntpd: [  OK  ]

 

 

ntpd: Synchronizing with time server: [  OK  ]

 

 

Syncing hardware clock to system time [  OK  ]

 

 

Starting ntpd: [  OK  ]

 

 

[root@nascds11 ~]# service ntpd restart

 

 

Shutting down ntpd: [  OK  ]

 

 

ntpd: Synchronizing with time server: [  OK  ]

 

 

Syncing hardware clock to system time [  OK  ]

 

 

Starting ntpd: [  OK  ]

 

 

6、檢查ntpd進程的狀態

 

 

[root@nascds10 ~]# ntpq -p

 

 

      remote           refid      st t when poll reach   delay   offset  jitter

 

 

==============================================================================

 

 

  LOCAL(0)        .LOCL.          10 l   40   64    1    0.000    0.000   0.001

 

 

[root@nascds11 ~]# ntpq -p

 

 

      remote           refid      st t when poll reach   delay   offset  jitter

 

 

==============================================================================

 

 

  test.oracle.com  .INIT.          16 u   60   64    0    0.000    0.000   0.000

 

 

  LOCAL(0)        .LOCL.          10 l   59   64    1    0.000    0.000   0.001

 

 

 

 

For Aix:

 

 

 

 

1. NTP的同步設置  編輯 /etc/ntp.conf, 內容如下:

 

 

----------------------------

 

 

#broadcastclient

 

 

server 192.168.5.2

 

 

driftfile /etc/ntp.drift

 

 

tracefile /etc/ntp.trace

 

 

slewalways yes

 

 

----------------------------

 

 

我們這裡還是要強調微調slewalways  ,這個值的默認設置是no,也就是說如果您不設置,NTP最大可一次調整1000. 根據IBM的官方說明,如果我們不指定slewthreshold  那麼預設值是 0.128 seconds. 如果想特別設置,請指定slewthreshold 的值,注意單位是second

 

 

 

 

2.NTP用戶端啟動xntpd守護進程

 

 

# startsrc -s xntpd

 

 

 

3. 查詢xntpd的狀態

 

 

system peer 不為 'insane' , 表明用戶端已與伺服器端成功地進行了同步.

 

 

# lssrc -ls xntpd

 

 

Program name: --/usr/sbin/xntpd

 

 

Version: -------3

 

 

Leap indicator: 00 (No leap second today.) Sys peer: ------192.168.5.2 ...

 

 

 

 

關於更多的關於IBM的平臺上NTP的設置,可以參考IBM的官方文檔解釋:

 

 

http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.files/doc/aixfiles/ntp.conf.htm

 

 

 

For HP  UX:

 

 

 

NTPHP上的配置,是比較省心的,不容易導致RAC重啟的,因為HP上的NTP默認的就是微調的模式

 

 

1、首先我們還是要編輯ntp的設定檔 /etc/rc.config.d/netdaemons,把 XNTPD 設定為1表示啟動

 

 

   export XNTPD=1

 

 

2、編輯設定檔 /etc/ntp.conf ,配置好時間同步伺服器

 

 

   server 192.168.5.2      #  第一個位址是主要伺服器

 

 

   server 192.168.5.3      #  第二個地址是備用伺服器

 

 

3、啟動ntp的進程

 

 

   # /sbin/init.d/xntpd start

 

 

4、檢查NTP的狀態

 

 

   # /usr/sbin/ntpq -p

 

 

  這個命令您會看到同步的位址

 

 

  如果出現的結果是No association ID's returned 那麼表示您失敗了

 

 

關於HP主機上NTP的模式,有3種如下,在HP 平臺的man page中有詳細的說明:

 

 

模式1offset below 128 milliseconds

 

This is the normal operating regime of NTP. A properly configured NTP hierarchy (with reasonable networking) can operate for years without ever approaching the 128 millisecond upper limit. All time adjustments are small and smooth (known as slewing), and nobody even notices the slew adjustments unless they have a cesium clock or a GPS clock and expensive instrumentation to make sophisticated measurements (HP/Agilent makes the instruments).

 

模式2offset above 128 milliseconds

 

This regime is often encountered at power-on because, those battery-backed real-time clocks they put in computers are not too great. Because NTP is quite capable of keeping the offset below one millisecond all the time it is running, many users want to get into the normal regime quickly when an offset above 128 millisecond is encountered at startup. So in this situation NTP will (fairly quickly) make a single step change, and is usually successful in getting the offset well below 128 millisecond so there will be no more of the disruptive step changes.

 

 

模式3offset above 1000 seconds

 

 

This is so far out of the normal operating range that NTP decides something is terribly wrong and human intervention is required. The daemon shuts down.

 

 

For Solars:

 

 

我這沒有測試的平臺,不過在KM (How to Configure NTP or Windows Time for Oracle Clusterware (Doc ID 1056693.1))裡找到了配置的辦法,這裡還有Windows的配置方式

 

 

檢查配置:

 

 

/usr/bin/svcs ntp

 

 

STATE          STIME    FMRI

 

 

online          7:39:29 svc:/network/ntp:default

 

 

ps -ef|grep ntp

 

 

root 21212     1   0   Feb 02 ?           0:33 /usr/lib/inet/xntpd

 

 

 

配置/etc/inet/ntp.conf 啟用slewalaways

 

 

grep 'slewalways|pll' /etc/inet/ntp.conf

 

 

slewalways yes

 

 

disable pll

 

 

啟動:

 

 

/usr/sbin/svcadm enable ntp

 

沒有留言:

LinkWithin-相關文件

Related Posts Plugin for WordPress, Blogger...