Oracle RAC两个节点,配置NTP使得两个节点时间同步
1)节点1和节点2都启动NTP服务,节点2(客户端)向节点1(服务器端)同步
如果测试用,可修改节点2的时间不同于节点1的时间,date -s "2013-12-20 12:00:00"
节点1(服务器端)的配置:
[root@node1 ~]# vi /etc/ntp.conf
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
#restrict default kod nomodify notrap nopeer noquery
#restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# Hosts on local network are less restricted.
restrict 192.168.3.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org
#broadcast 192.168.1.255 key 42 # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 key 42 # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 key 42 # manycast client
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# Specify the key identifiers which are trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the ntpdc utility.
#requestkey 8
# Specify the key identifier to use with the ntpq utility.
#controlkey 8
重启NTP服务:/etc/init.d/ntpd restart
[root@node1 ~]# ntpstat --节点1与自己同步成功
synchronised to local net at stratum 11
time correct to within 10 ms
polling server every 128 s
[root@node1 ~]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
dns2.synet.edu. 202.118.1.46 2 u 196 64 370 27.720 5867038 509323.
ntp.glnet.edu.c 202.112.10.60 2 u 1 64 335 28.515 5815055 1289295
*LOCAL(0) .LOCL. 10 l 6 64 377 0.000 0.000 0.001
--LOCAL就表示与本机同步,前面带*的表示已经同步成功
节点2(客户端)配置:
[root@node2 log]# vi /etc/ntp.conf
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.rhel.pool.ntp.org
#server 1.rhel.pool.ntp.org
#server 2.rhel.pool.ntp.org
#broadcast 192.168.1.255 key 42 # broadcast server
#broadcastclient # broadcast client
#broadcast 224.0.1.1 key 42 # multicast server
#multicastclient 224.0.1.1 # multicast client
#manycastserver 239.255.254.254 # manycast server
#manycastclient 239.255.254.254 key 42 # manycast client
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 192.168.3.201 prefer # local clock
# Drift file. Put this in a directory which the daemon can write to.
# No symbolic links allowed, either, since the daemon updates the file
# by creating a temporary in the same directory and then rename()'ing
# it to the file.
driftfile /var/lib/ntp/drift
# Key file containing the keys and key identifiers used when operating
# with symmetric key cryptography.
keys /etc/ntp/keys
# Specify the key identifiers which are trusted.
#trustedkey 4 8 42
# Specify the key identifier to use with the ntpdc utility.
#requestkey 8
# Specify the key identifier to use with the ntpq utility.
#controlkey 8
----192.168.3.201是节点1的IP地址
重启NTP服务:/etc/init.d/ntpd restart
[root@node2 log]# ntpstat ---提示不能同步
unsynchronised
time server re-starting
polling server every 64 s
cd /var/log
[root@node2 log]# tail -n 100 messages
Dec 20 12:03:16 node2 ntpd[25815]: ntpd exiting on signal 15
Dec 20 12:03:16 node2 ntpd[27096]: ntpd 4.2.2p1@1.1570-o Tue Dec 8 20:30:29 UTC 2009 (1)
Dec 20 12:03:16 node2 ntpd[27097]: precision = 9.000 usec
Dec 20 12:03:16 node2 ntpd[27097]: Listening on interface wildcard, 0.0.0.0#123 Disabled
Dec 20 12:03:16 node2 ntpd[27097]: Listening on interface lo, 127.0.0.1#123 Enabled
Dec 20 12:03:16 node2 ntpd[27097]: Listening on interface eth0, 192.168.3.202#123 Enabled
Dec 20 12:03:16 node2 ntpd[27097]: Listening on interface eth1, 10.10.17.202#123 Enabled
Dec 20 12:03:16 node2 ntpd[27097]: kernel time sync status 0040
Dec 20 12:03:16 node2 ntpd[27097]: getaddrinfo: "::1" invalid host address, ignored
Dec 20 12:03:16 node2 ntpd[27097]: frequency initialized 0.000 PPM from /var/lib/ntp/drift
----感觉NTP服务应该没问题的
[root@node2 log]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
node1 .INIT. 16 u 56 64 0 0.000 0.000 0.000
[root@node2 log]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
node1 LOCAL(0) 11 u 43 64 1 0.135 -509970 0.008
[root@node2 log]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
node1 LOCAL(0) 11 u 14 64 3 0.135 -509970 3146.38
[root@node2 log]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
node1 LOCAL(0) 11 u 2 64 7 0.130 -510033 4976.97
[root@node2 log]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
node1 LOCAL(0) 11 u 58 64 37 0.024 -510094 8518.21
--reach值一直在增加,这应该是正在同步的节奏吧,但是我等了好几个小时,还没见他同步完成,
[oracle@node1 ~]$ date; ssh node2 date
Thu Dec 19 22:58:23 CST 2013
Thu Dec 19 22:42:51 CST 2013
节点1和节点2的时间一直没同步,网上搜了很多,也无解,这个问题先放放,采用第2种方法使两个节点时间同步
2)节点1启动NTP服务,节点2关闭NTP服务,节点2(客户端)使用ntpdate和crond向节点1(服务器端)同步
节点1的配置同第1种方法
节点2需要关闭NTP服务,否则报错如下:
ntpdate[3556]: the NTP socket is in use, exiting
[root@node2 ~]# vi /etc/crontab
加这样一句话:
*/2 * * * * root ntpdate 192.168.3.201
--表示每隔2分钟在节点2以root身份执行ntpdate 192.168.3.201
重启crond服务:
[root@node2 ~]# /etc/init.d/crond restart
Stopping crond: [ OK ]
Starting crond: [ OK ]
观察cron的日志:
[root@node2 log]# pwd
/var/log
[root@node2 log]# tail -f cron
Dec 18 11:40:01 node2 crond[5209]: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 18 14:50:42 node2 crond[6762]: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 18 15:00:01 node2 crond[7274]: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 18 15:01:01 node2 crond[7658]: (root) CMD (run-parts /etc/cron.hourly)
Dec 18 15:10:01 node2 crond[20182]: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 19 04:35:10 node2 crond[2637]: (CRON) STARTUP (V5.0)
Dec 19 04:40:01 node2 crond[9143]: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 19 04:46:00 node2 crond[2637]: (CRON) STARTUP (V5.0)
Dec 19 04:50:01 node2 crond[7985]: (root) CMD (/usr/lib/sa/sa1 1 1)
Dec 19 04:56:41 node2 crond[18037]: (CRON) STARTUP (V5.0)
Dec 19 04:58:01 node2 crond[27769]: (root) CMD (ntpdate 192.168.3.201)
Dec 19 03:32:51 node2 crond[32458]: (root) CMD (ntpdate 192.168.3.201)
Dec 19 03:34:01 node2 crond[18884]: (root) CMD (ntpdate 192.168.3.201)
两个节点之间已实现同步
参考资料:http://blog.163.com/william_djj@126/blog/static/35166501201301432546711/
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26524307/viewspace-1063924/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26524307/viewspace-1063924/