设为首页 收藏本站
查看: 710|回复: 0

[经验分享] 浅谈ntp server搭建

[复制链接]

尚未签到

发表于 2018-10-21 12:34:12 | 显示全部楼层 |阅读模式
1)配置/etc/ntp.conf  
[root@localhost ~]# vim /etc/ntp.conf
  
1 # For more information about this file, see the man pages
  
2 # ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
  
3
  
4 driftfile /var/lib/ntp/drift
  
5
  
6 # Permit time synchronization with our time source, but do not
  
7 # permit the source to query or modify the service on this system.
  
8 restrict default kod nomodify notrap nopeer noquery
  
9 restrict -6 default kod nomodify notrap nopeer noquery
  
10
  
11 # Permit all access over the loopback interface. This could
  
12 # be tightened as well, but to do so would effect some of
  
13 # the administrative functions.
  
14 restrict 127.0.0.1
  
15 restrict -6 ::1
  
16
  
17 # Hosts on local network are less restricted.
  
18 #restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
  
19 restrict 192.168.6.0 mask 255.255.252.0 nomodify
  
20
  
21 # Use public servers from the pool.ntp.org project.
  
22 # Please consider joining the pool (http://www.pool.ntp.org/join.html).
  
23 #server 0.centos.pool.ntp.org iburst
  
24 #server 1.centos.pool.ntp.org iburst
  
25 #server 2.centos.pool.ntp.org iburst
  
26 #server 3.centos.pool.ntp.org iburst
  
27 server asia.pool.ntp.org prefer
  
28 server 0.asia.pool.ntp.org
  
29 server 1.asia.pool.ntp.org
  
30 server 2.asia.pool.ntp.org
  
31 server time.nist.gov
  
32
  
33 #broadcast 192.168.1.255 autokey # broadcast server
  
...
  

  
2)NTP启动与端口检查:
  
[root@localhost ~]# service ntpd start
  
Starting ntpd:
  
[root@localhost ~]# chkconfig ntpd on
  
[root@localhost ~]# chkconfig --list | grep ntp
  
ntpd 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
  
ntpdate 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
  
[root@localhost ~]# netstat -nutlp | grep ntp
  
udp 0 0 192.168.2.213:123 0.0.0.0:* 21798/ntpd
  
udp 0 0 192.168.6.213:123 0.0.0.0:* 21798/ntpd
  
udp 0 0 127.0.0.1:123 0.0.0.0:* 21798/ntpd
  
udp 0 0 0.0.0.0:123 0.0.0.0:* 21798/ntpd
  
udp 0 0 fe80::221:f6ff:fed4:d502:123 :::* 21798/ntpd
  
udp 0 0 fe80::221:f6ff:fed4:d501:123 :::* 21798/ntpd
  
udp 0 0 ::1:123 :::* 21798/ntpd
  
udp 0 0 :::123 :::* 21798/ntpd
  

  
3)ntp server与上联是否同步
  
#查看server与上联是否同步,时间校正约8279ms,每64s轮循更新一次。
  
[root@localhost ~]# ntpstat
  
synchronised to NTP server (62.201.225.9) at stratum 3 #==>上层ntp
  
time correct to within 8279 ms #==>校正时间差
  
polling server every 64 s #==>下次同步时间
  

  
#查看server与上联的状态
  
[root@localhost ~]# ntpq -p
  
remote       refid       st t when poll reach delay offset jitter
  
==============================================================================
  
*time.iqnet.com  62.201.214.162   2  u 146  64  124 393.411 -101.29 40.435
  
-220.231.122.105  123.204.45.116   4  u 20    64  377 341.475 58.745   47.945
  
+vps.jre655.com  10.84.87.146   2  u 24    64  377 211.095 0.177   38.002
  
web10.hnshostin  158.43.128.33   2  u 17    64  177 392.506 -134.76 39.146
  
+24.56.178.140   .ACTS.      1  u 27    64  377 282.739 -59.521 42.959
  

  
参数说明:
  
reomte server上联的ntp主机名或ip;
  
注意最左端符号;*表示当前正使用的上层ntp;+代表与本机server也有连接,作为侯选ntp
  
refid    给上层ntp提供时间校对的服务器
  
st      上层ntp stratum级别
  
when      上一次与上层ntp同步的时间,单位为秒。
  
poll     同步时间间隔
  
reach    已经同上层ntp同步更新的次数
  
delay    网络传输过程中的延迟时间,单位为10^(-6)s
  
offset    时间补偿,单位为10^(-3)s
  
jitter    系统时间与bios硬件时间差,单位为10^(-6)s



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-624492-1-1.html 上篇帖子: 数据库性能调优——sql语句优化(转载及整理) 下篇帖子: Apache - AH00526 – server.crt
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表