免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2400 | 回复: 0
打印 上一主题 下一主题

NTP server [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-12-22 08:39 |只看该作者 |倒序浏览

鸟哥的ntp


http://linux.vbird.org/linux_server/0440ntp.php

现在的网络由于各种原因 对于时间同步要求很高——比如银行,某些网站论坛。
配置ntp就是他们要面对的一个问题,在NTP中有Ntp,xntp等各种软件。我们选用Rad Hat中标配的NTP。
首先让大家了解下NTP:
使用端口123
协议 UDP
用处 同步网络时钟
首先到下载ntp-4.1.1-1.i386.rpm
(
ftp://rpmfind.net/linux/redhat/7.3/en/....1.1-1.i386.rpm
)
不下载最新的,因为高版本可能你的linux版本(AS 3.1)不支持,并且不要选4.0.9版本(有溢出漏洞)
如果链接失效推荐一个不错的搜索引擎(
http://rpmfind.net/linux/rpm2html/search.php

#wget
ftp://rpmfind.net/linux/redhat/7.3/en/....1.1-1.i386.rpm
#rpm -ivh ntp-4.1.1-1.i386.rpm //默认安装即可
接下来编辑 /etc/ntp.conf
首先你可以去ntp.org上找到哪些ntp服务器离你较近
ntp.conf
#############################################################################################
server clock.tl.fukuoka-u.ac.jp #校对服务器1
server clock.uregina.ca
server swisstime.ethz.ch
server ntp0.fau.de # 比较多的服务器可以防止因为网络故障导致无法校对时间
server 127.127.1.1 #这行可删除
fudge 127.127.1.1 stratum 10 #同上
driftfile /etc/ntp/drift #/etc/ntp/drift 可能是ntp.drift 这无所谓,看你的版本号
restrict clock.tl.fukuoka-u.ac.jp
restrict clock.cuhk.edu.hk
restrict swisstime.ethz.ch
restrict ntp0.fau.de
restrict 127.0.0.1
restrict 192.168.x.y #x.y为自己的IP
restrict 192.168.x.x mask 255.255.255.0 nomodify #让x网段的机器都能访问自己,进行时间校对
#restrict default ignore #这行删除或注释都可以
#############################################################################################
#/sbin/service ntpd start //启动ntpd 参数可为restart start stop
#/sbin/chkconfig --add ntpd
#/sbin/chkconfig --level 234 ntpd on //配置在开机时运行
接下来在客户端安装NTP
安装过程同上
接下来编辑 /etc/ntp.conf
ntp.conf
#############################################################################################
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
server stdtime.gov.hk # A stratum 1 server at server.org
server 192.168.x.y #x.y为你前面所装机器在局域网里的IP
driftfile /etc/ntp/drift
broadcastdelay 0.008
authenticate no
keys /etc/ntp/keys
restrict 192.168.x.0 mask 255.255.255.0 notrust nomodify notrap//x.0为你所在局域网段
restrict 127.0.0.1
restrict 192.168.x.y #x.y为你前面所装机器在局域网里的IP
#restrict default ignore
#############################################################################################
同时配置
#/sbin/service ntpd start //启动ntpd 参数可为restart start stop
#/sbin/chkconfig --add ntpd
#/sbin/chkconfig --level 234 ntpd on //配置在开机时运行
如何检查?
#netstat -unl | grep 123 //查看123端口
#ndptrace 192.168.x.y //看校对时间过程,出现offset即为正常 否则为time out
# ntpq -p
如果出现 jitter的值 为4000则是防火墙或者网络问题
正常为
remote refid st t when poll reach delay offset jitter
==============================================================================
*clock.nc.fukuok .GPS. 1 u 43 64 37 19.067 -6.884 10.339
+clock.tl.fukuok .GPS. 1 u 36 64 35 19.670 -3.259 2.341
LOCAL(0) LOCAL(0) 5 l 45 64 37 0.000 0.000 0.001
几点注意:
1.虽然ntp溢出问题较少 ,但建议配置大型网罗的时候,不要装在重要数据库服务器或者Web主机上(Ntp是root权限)
2.在遇到问题之前,先看看ntp自带的文档
3.防火墙问题的话,送一句配置
$TMP -t filter -A INPUT -p udp --destination-port 123 -j ACCEPT
也就是123 udp in 全部接受




               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/108430/showart_2127539.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP