服务器间时间同步

由于上海服务器时间不统一可能造成发布警告及其他问题,使用以下方案尝试解决该问题

一.时间服务器的设定

1.选定172.26.166.114作为时间服务器,对NTP配置文件/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

restrict 172.26.166.0 mask 255.255.255.0 nomodify 

# Hosts on local network are less restricted.

#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

…………

2.设定NPT服务重启动

service ntpd restart

3.设定NPT服务在系统引导时启动

chkconfig ntpd on    

二.客户端设定

1.在需同步的服务器上使用Crontab定时更新,目前定为1天更新一次

##################################################

#time syn

##################################################

* */24 * * * root /usr/sbin/ntpdate 172.26.176.214;/sbin/hwclock -w

2.设定系统启动时同步时间,在/etc/init.d/下新建脚本文件(sysServerDate)

#!/bin/ksh

# chkconfig: 345 63 37

# description: update date to 172.26.176.214

/usr/sbin/ntpdate 172.26.176.214;/sbin/hwclock -w

3.设定同步脚本在系统引导时启动

chmod 755 sysServerDate

chkconfig sysServerDate on

猜你喜欢

转载自shenling258-hotmail-com.iteye.com/blog/1457578