在rac环境中,会要求几个节点之间的时间差不能超时。一般如果超过30秒,节点很可能会重启。我们需要配置一个ntp时钟服务器,来给rac的各个节点进行时间同步。
在这里,我们以windows机器(192.168.1.189)做ntp server,以2台虚拟机上的rac节点(192.168.1.131和192.168.1.132)作为ntp client为例,进行配置:
1.下载windows版的ntp server——ntp-424p311502-foehr-v2-o-win32-setup
安装后,配置安装目录下的ntp.conf,主要配置的是下面这2个参数:
server 127.127.1.0 prefer
fudge 127.127.1.0 stratum 10
127.127.1.0表示是采用本机的时间作为ntp服务器时间,而不是去更上级的时间服务器去同步。
如下是我的windows机器上完整的ntp.config文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# NTP Network Time Protocol # Configuration File created by Windows Binary Distribution Installer Rev.: 1.22 mbg # please check http://www.ntp.org for additional documentation and background information # Use drift file driftfile "d:\Program Files\NTP\etc\ntp.drift" # your local system clock, could be used as a backup # (this is only useful if you need to distribute time no matter how good or bad it is) #server 127.127.1.0 # but it should operate at a high stratum level to let the clients know and force them to # use any other timesource they may have. #fudge 127.127.1.0 stratum 12 server 127.127.1.0 prefer fudge 127.127.1.0 stratum 10 # End of generated ntp.conf --- Please edit this to suite your needs |
注意配置完成从重启ntp服务:开始-运行-services.msc-Network Time Protocol Daemon。
2.配置linux端的client:
2.1 在/etc/ntp.config中修改:
server 192.168.1.189
fudge 192.168.1.189 stratum 10
注:如果有多个server服务器,可以写:
server 192.168.1.189 prefer
server 111.222.3.444
server 111.222.4.444
其中prefer表示该server是master server
注释掉:
server 127.127.1.0 # local clock
以下是我的linux机器上的/etc/ntp.conf:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
[root@rac2 etc]# cat 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 nomodify notrap 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 # -- CLIENT NETWORK ------- # Permit systems on this network to synchronize with this # time service. Do not permit those systems to modify the # configuration of this service. Also, do not use those # systems as peers for synchronization. # restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap # --- OUR TIMESERVERS ----- server 192.168.1.189 # --- NTP MULTICASTCLIENT --- #multicastclient # listen on default 224.0.1.1 # restrict 224.0.1.1 mask 255.255.255.255 nomodify notrap # restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap # --- GENERAL CONFIGURATION --- # # Undisciplined Local Clock. This is a fake driver intended for backup # and when no outside source of synchronized time is available. The # default stratum is usually 3, but in this case we elect to use stratum # 0. Since the server line does not have the prefer keyword, this driver # is never used for synchronization, unless no other other # synchronization source is available. In case the local host is # controlled by some external source, such as an external oscillator or # another protocol, the prefer keyword would cause the local host to # disregard all other synchronization sources, unless the kernel # modifications are in use and declare an unsynchronized condition. # #server 127.127.1.0 # local clock fudge 192.168.1.189 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 broadcastdelay 0.008 # # Keys file. If you want to diddle your server at run time, make a # keys file (mode 600 for sure) and define the key number to be # used for making requests. # # PLEASE DO NOT USE THE DEFAULT VALUES HERE. Pick your own, or remote # systems might be able to reset your clock at will. Note also that # ntpd is started with a -A flag, disabling authentication, that # will have to be removed as well. # keys /etc/ntp/keys |
2.2 修改/etc/ntp/ntpservers文件,把里面的server IP改为自己的ntp server的IP,也就是windows机器,下面是我的/etc/ntp/ntpservers:
1 2 3 4 |
#This file contains a list of ntp servers to show in the system-config-date user interface. #It is not recommended that you modify this file by hand. 192.168.1.189 |
2.3 修改/etc/hosts文件,加入windows主机的IP和主机名。
2.4 ps -ef |grep ntp 杀掉ntp进程。然后ntpdate 192.168.1.189手工做一次同步:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@rac3 init.d]# ps -ef |grep ntp ntp 7466 1 0 17:13 ? 00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g root 7889 4976 0 17:17 pts/1 00:00:00 grep ntp [root@rac3 init.d]# [root@rac3 init.d]# [root@rac3 init.d]# kill 7466 [root@rac3 init.d]# [root@rac3 init.d]# [root@rac3 init.d]# [root@rac3 init.d]# ps -ef |grep ntp root 7954 4976 0 17:17 pts/1 00:00:00 grep ntp [root@rac3 init.d]# ntpdate 192.168.1.189 4 Jul 17:17:15 ntpdate[7955]: step time server 192.168.1.189 offset -0.656717 sec [root@rac3 init.d]# /etc/init.d/ntpd start Starting ntpd: [ OK ] [root@rac3 init.d]# |
2.5 启动ntp服务,并且加到run level 5:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@rac3 init.d]# /etc/init.d/ntpd start Starting ntpd: [ OK ] [root@rac3 init.d]# [root@rac3 init.d]# [root@rac3 init.d]# [root@rac3 init.d]# ps -ef |grep ora_ root 7470 4976 0 17:13 pts/1 00:00:00 grep ora_ [root@rac3 init.d]# ps -ef |grep ntp ntp 7466 1 0 17:13 ? 00:00:00 ntpd -u ntp:ntp -p /var/run/ntpd.pid -g root 7472 4976 0 17:13 pts/1 00:00:00 grep ntp [root@rac3 init.d]# [root@rac3 ntp]# chkconfig --level 5 ntpd on [root@rac3 ntp]# [root@rac3 ntp]# [root@rac3 ntp]# chkconfig --list |grep ntp ntpd 0:off 1:off 2:off 3:off 4:off 5:on 6:off |
注:如果偏差量大于1000秒,客户端不能自动与NTP master服务器进行同步。需要停ntpd服务后ntpdate手工同步,这也就是我们为什么在2.4步骤中先做手工同步的原因。
3条评论
文件用rar格式压缩不大好吧
貌似在client里配置fudge 192.168.1.189 stratum 10是错误的,这样是不会同步时间的;
仍应配置成fudge 127.127.1.0 stratum 10。
可以设置你的client机器时间比server机器快或慢几分钟,
然后重启client的ntp服务看时间是否会同步过来,
即可完成这个测试。
呵呵,说得不清楚
我说的是这样不会自动同步,
手动同步当然是可以的。