搭建NTP服务器实现时钟同步

在公司内部有时候需要使用一台内部服务器来实现时钟同步功能,来保证内部服务器的时间一致。搭建NTP服务器总体来讲还是比较简单的,这里介绍下。
    1. 安装NTP软件

1.yum -y install ntp  2.or 3.tar zxvf ntp-4.2.6p5.tar.gz  4.cd ntp-4.2.6p5  5../configure --prefix=/usr/local/ntp --enable-all-clocks --enable-parse-clocks  6.make && make install  7.cd ..      2. 同步NTP服务器时间

1.[root@ ntp-4.2.6p5]# ntpdate ntp.api.bz  2.13 Apr 16:22:00 ntpdate[26620]: adjust time server 219.239.93.23 offset 0.004556 sec     3. 自动与权威NTP服务器同步时间

1.[root@ ntp-4.2.6p5]# crontab -l  2.*/5 * * * * /usr/sbin/ntpdate ntp.api.bz     4. 编辑ntp.conf配置文件

1.# kod是指kiss o'death的意思  2.# 现在越来越多的主机都指向了同一台NTP服务器, 从而造成每秒有大量的NTP Request信息  3.# 即client访问server时, server会告诉client不要来找我, 之后client会询问另一台server, 或等一段时间再询问server  4.# nomodify: client不能修改NTP服务器的时间参数  5.# notrap: client不能通过trap远程登录  6.# nopeer: 不清楚, 有知道的朋友跟帖回复  7.# noquery: client不能通过ntpq, ntpc等查询NTP服务器信息  8.# -4 Force DNS resolution of following host names to the IPv4 namespace.  9.# -6 Force DNS resolution of following host names to the IPv6 namespace.  10.restrict default kod nomodify notrap nopeer noquery  11.# restrict -6 default kod nomodify notrap nopeer noquery  12. 13.# restrict ntp.api.bz  14.# restrict 210.72.145.44  15.restrict 127.0.0.1  16.restrict 172.31.11.0 mask 255.255.255.0  17. 18.# Hosts on local network are less restricted.  19.#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap  20. 21.server ntp.api.bz prefer  22.server 210.72.145.44  23. 24.server 127.127.1.0 # local clock  25.fudge  127.127.1.0 stratum 10  26. 27.driftfile /var/lib/ntp/drift  28. 29.keys /etc/ntp/keys  30. 31.# Specify the key identifiers which are trusted.  32.#trustedkey 4 8 42  33. 34.# Specify the key identifier to use with the ntpdc utility.  35.#requestkey 8  36. 37.# Specify the key identifier to use with the ntpq utility.  38.#controlkey 8  39. 40.logfile /var/log/ntp.log    # 日志信息  41.broadcastdelay 0.008        # 广播延迟时间  42. 43.SYNC_HWCLOCK=yes            # BIOS时间同步     5. 开启NTP服务器

1.[root@ ntp-4.2.6p5]# service ntpd start  2.Starting ntpd:                                             [  OK  ]  3.or 4.[root@ ntp-4.2.6p5]# /usr/local/ntp/bin/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid  5.[root@ ntp-4.2.6p5]# ps -ef | grep ntp  6.root     27562     1  0 16:56 ?        00:00:00 /usr/local/ntp/bin/ntpd -c /etc/ntp.conf -p /tmp/ntpd.pid     6.  查看NTP服务器与权威NTP服务器的关系

1.[root@ ntp-4.2.6p5]# ntptrace -n ntp.api.bz  2.ntp.api.bz: stratum 3, offset -0.001246, synch distance 0.115837  3.218.75.4.130: stratum 2, offset 0.002165, synch distance 0.105875  4.66.220.9.122: stratum 1, offset -0.000004, synch distance 0.000447, refid 'CDMA'     7. 查看NTP服务器与权威NTP服务器的状态

1.[root@ ntp-4.2.6p5]# ntpq -p  2.     remote           refid      st t when poll reach   delay   offset  jitter  3.==============================================================================  4.*219.239.93.23   218.75.4.130     3 u  128  128  377    4.239   40.777   8.788  5.+210.72.145.44   .ACTS.           1 u    9   64  163   27.135   36.602  25.212  6. LOCAL(0)        .LOCL.          10 l  800   64    0    0.000    0.000   0.000

本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2012-04/58594.htm

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值