1.NTP简介
NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议。它的用途是把计算机的时钟同步到世界协调时UTC,其精度在局域网内可达0.1ms,在互联网上绝大多数的地方其精度可以达到1-50ms。还可介由加密确认的方式来防止恶毒的协议攻击。时间按NTP服务器的等级传播。按照离外部UTC源的远近把所有服务器归入不同的Stratum(层)中。NTP服务器就是利用NTP协议提供时间同步服务的。
2. NTP服务器安装
#一般服务器都会自带ntp服务
[root@nfs01 ~] rpm -qa|grep ntp
ntp-4.2.6p5-10.el6.centos.2.x86_64
ntpdate-4.2.6p5-10.el6.centos.2.x86_64
如果没有,直接利用yum进行安装
[root@nfs01 ~] yum install -y ntp
3. 配置NTP服务
在配置文件vim /etc/ntp.conf中修改参数
[root@nfs01 ~] vim /etc/ntp.conf
# restrict default kod nomodify notrap nopeer noquery
restrict default nomodify
# nomodify客户端可以同步
# 将默认时间同步源注释改用可用源
# server 0.centos.pool.ntp.org iburst
# server 1.centos.pool.ntp.org iburst
# server 2.centos.pool.ntp.org iburst
# server 3.centos.pool.ntp.org iburst
#在文章末端加入下列命令
server ntp1.aliyun.com
server time.nist.gov
4. 启动NTP服务器
#如果计划任务有时间同步,先注释,两种用法会冲突。
#如果没有则进行下一步
1.[root@nfs01 ~] crontab -e
no crontab for root - using an empty one
#启动ntp服务
2.[root@nfs01 ~] /etc/init.d/ntpd start
Starting ntpd: [ OK ]
3.[root@nfs01 ~] ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
120.25.115.20 10.137.53.7 2 u 51 64 3 37.536 1742252 0.498
time-a-wwv.nist .NIST. 1 u 49 64 3 203.111 1742252 11.005
4.[root@nfs01 ~] ntpstat
unsynchronised
polling server every 64 s
#测试ntp服务
5.[root@nfs01 ~]# ntpdate 172.16.1.31
11 Oct 19:12:04 ntpdate[2072]: the NTP socket is in use, exiting
5. 客户端时间同步
客户机要等10分钟左右再与新启动的ntp服务器进行时间同步,否则会报错no server suitable for synchronization found。
[root@backup ~]# ntpdate 172.16.1.32
21 Sep 15:46:00 ntpdate[2011]: no server suitable for synchronization found
过10分钟左右后,客户端开始与ntp服务端进行时间同步后结果;
[root@backup ~]# ntpdate 172.16.1.31
11 Oct 19:42:35 ntpdate[2349]: step time server 172.16.1.31 offset 1740585.341828 sec
更多资讯:更多资讯
本站发布的【Linux时间同步服务器】内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场
如果涉及侵权请尽快告知,我们将会在第一时间立刻删除涉嫌侵权内容,本站原创内容未经允许不得转载,或转载时需注明出处。
Copyright © 2009-2024 56dr.com. All Rights Reserved. 特网科技 版权所有 珠海市特网科技有限公司 粤ICP备16109289号
域名注册服务机构:阿里云计算有限公司(万网) 域名服务机构:烟台帝思普网络科技有限公司(DNSPod) CDN服务:阿里云计算有限公司 百度云 中国互联网举报中心 增值电信业务经营许可证B2
建议您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流浏览器浏览本网站