author:skate
time:2010-05-06
在rac环境中,会要求各个节点之间的时间差不能超时。一般如果超过30秒,节点很可能会重启。
所以要同步各节点的时间。例如,我们需要配置一个ntp时钟服务器,来给rac的各个节点进行时
间同步。或者让节点之间进行时间同步,保证各节点的时间同步,但无法保证rac数据库的时间的准确性。
目录:
一. 节点间的时间同步方法:
方法一:建立ntp时钟服务器,各节点与ntp server同步时间
方法二:利用定时任务,让节点间时间同步(用rdate或ntpdate)
二. ntp相关错误及解决方法
三. ntp原理
--------------------------------------------------------------------------
一. 节点间的时间同步方法
环境:ntp server是wxp
client是centos5
在这里,我以windows机器(192.168.2.29)做ntp server,以1台linux为clent客户端(192.168.2.245)来说明时间同步方法。
方法一:
1.ntp服务端配置
首先下载安装windows版的ntp server —— ntp-424p311502-foehr-v2-o-win32-setup
安装很简单,直接运行exe文件即可,安装后修改ntp.conf配置文件,添加如下两行内容:
server 127.127.1.0 prefer
fudge 127.127.1.0 stratum 10
说明:
127.127.1.0 : 该IP为NTP定义的server自己的IP
prefer :这个参数表示该server是master server
fudge:这个参数表示该IP为NTPserver,
stratum:表示该系统所在的NTP层级.
我的windows ntpserver的"C:/Program Files/NTP/etc/ntp.conf"文件如下:
# 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 "C:/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
#skate add
server 127.127.1.0 prefer
fudge 127.127.1.0 stratum 10
#skate add
# End of generated ntp.conf --- Please edit this to suite your needs
配置完成后,重新启动ntp
重启方法:开始-》运行-》services.msc-》Network Time Protocol Daemon。
2.配置client的linux
A.修改客户端linux的配置文件 /etc/ntp.conf,添加如下一行
server 192.168.2.29 prefer
如果是多个time server服务器的话,可以按如下的方式:
server 192.168.2.29 prefer ---prefer表示该server是master server
server 192.168.3.29
server 192.168.4.29
server 192.168.5.29
注释掉如下一行
server 127.127.1.0 # local clock
在这里要另外说一下,网上的有朋友说要把
“fudge 127.127.1.0 stratum 10” 改成 “fudge 192.168.2.29 stratum 10”
但经过我的测试发现,如果这样修改的的话,就不能自动同步时间了。
我的客户端的linux的 /etc/ntp.conf 内容如下:
[root@localhost ~]# more /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 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 -----
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org
server 1.centos.pool.ntp.org
server 2.centos.pool.ntp.org
# --- 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 loc