使用NTP将一组Linux服务器同步到一个公共时间源
我有20个左右的
Linux服务器,我想将所有时钟同步到一个NTP服务器,它与我的服务器位于同一个机架和交换机中.什么都没有虚拟化.
我们的管理员无法在同步的各种机器上获得超过500毫秒的时钟.我猜对了,this post意味着我们应该能够让linux盒子在源和对方的2毫秒内同步. 我对NTP的期望是否不合理?关于管理员应该做什么/检查的任何提示? 解决方法
我拥有一家托管公司,我们正是这样做的.以下是我们如何实现这一目标.
首先,您需要一个NTP主源.因此,您的一台Linux服务器将成为主服务器.我将创建一个名为time.example.com的DNS A记录(假设example.com是域).这样,如果你的主人移动你不需要更新其他19个服务器. 在主服务器上,您需要具有适当配置的ntp.conf文件. 这是我们的主/etc/ntp.conf文件之一.请注意,这是一个使用172.17.x.x的私有地址空间(RFC1918)的数据中心,因此您需要相应地进行调整.如果您需要多个主服务器,请创建多个具有不同IP的DNS A记录,以便在需要时获得一些容错能力. server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 server 0.north-america.pool.ntp.org server 1.north-america.pool.ntp.org server 2.north-america.pool.ntp.org server 3.north-america.pool.ntp.org # Logging & Stats statistics loopstats statsdir /var/log/ntp/ filegen peerstats file peers type day link enable filegen loopstats file loops type day link enable # 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 /etc/ntp/drift broadcastdelay 0.008 restrict default noquery nomodify restrict 0.north-america.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery restrict 1.north-america.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery restrict 2.north-america.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery restrict 3.north-america.pool.ntp.org mask 255.255.255.255 nomodify notrap noquery # Allow LAN to query us restrict 172.17.0.0 mask 255.255.0.0 nomodify notrap # Trust ourselves. :-) restrict 127.0.0.1 现在在每个客户端上,我们有一个/etc/ntp.conf文件,如下所示: server 127.127.1.0 # local clock fudge 127.127.1.0 stratum 10 server time.example.com # Drift file. Put this in a directory which the daemon can write to. # No symbolic links allowed,since the daemon updates the file # by creating a temporary in the same directory and then rename()'ing # it to the file. driftfile /etc/ntp/drift multicastclient # listen on default 224.0.1.1 broadcastdelay 0.008 # Don't serve time or stats to anyone else by default (more secure) restrict default noquery nomodify restrict time.example.com mask 255.255.255.255 nomodify notrap noquery # Allow LAN to query us restrict 172.17.0.0 mask 255.255.0.0 nomodify notrap # Trust ourselves. :-) restrict 127.0.0.1 使用ntpq命令查看与其同步的服务器. 同样在我们的客户端节点上,我们有一个rc脚本(/etc/rc.d/rc.local),它在启动NTPD守护进程之前同步时钟.以下是重要部分……它们依赖于订单. 将客户端的时钟与主时间源同步 启动NTPD守护程序,允许在启动期间进行大量时间调整. 最后,根据您的设置,您需要打开防火墙规则以允许time.example.com主服务器通过UDP端口访问公共Internet.这是一个典型且适当放置的IPTables规则 iptables -t nat -A POSTROUTING -o $PUB_IF -p udp –dport 123 -j MASQUERADE PUB_IF是公共接口(eth0,eth1,等等) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |