本文共 1735 字,大约阅读时间需要 5 分钟。
NTP( Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协
议。它的用途是把计算机的时钟同步到世界协调时 UTC,其精度在局域网内可达 0.1ms,在互联
网上绝大多数的地方其精度可以达到 1-50ms。
NTP 服务器就是利用 NTP 协议提供时间同步服务的。
在实际工作中,不可能所有的服务器都通互联网,毕竟互联网鱼龙混杂还是有风险的!
1)找一台机器 (作为时间服务器)
2)所有的机器与这台机器的时间进行同步(比如,每次10分钟同步一次)
系统:centos7
服务端:192.168.59.3
客户端:192.168.59.4
[root@192 ~]# yum -y install ntp
[root@192 ~]# vim /etc/ntp.conf#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 iburstserver 127.127.1.0 iburst
[root@192 ~]# systemctl start ntpd[root@192 ~]# systemctl enable ntpd[root@192 ~]# ntpq -p remote refid st t when poll reach delay offset jitter==============================================================================*LOCAL(0) .LOCL. 5 l 5 64 1 0.000 0.000 0.000
[root@192 ~]# yum -y install ntp[root@192 ~]# systemctl start ntpd[root@192 ~]# systemctl enable ntpd
[root@192 ~]# vim /etc/ntp.conf #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 iburstserver 192.168.59.3restrict 192.168.59.3 nomodify notrap nuquery[root@192 ~]# restart start ntpd
[root@192 ~]# date -s 2017-1-12017年 01月 01日 星期日 00:00:00 CST[root@192 ~]# date2017年 01月 01日 星期日 00:00:02 CST[root@192 ~]# ntpdate -u 192.168.59.3 2 Jul 08:49:15 ntpdate[12260]: step time server 192.168.59.3 offset 110450935.086109 sec[root@192 ~]# date2020年 07月 02日 星期四 08:49:22 CST
offset 110450935.086109 sec
[root@192 ~]# date 2020年 07月 02日 星期四 08:49:22 CST好了,到此已经完成了,后期有需要的可以添加定时任务。
转载地址:http://blcef.baihongyu.com/