NTP是在数据网络潜伏时间可变的计算机系统之间通过分组交换进行时钟同步的一个网络协议,位于OSI模型的应用层。

服务端:
1、安装ntp服务
yum install ntp ntpdate -y
2、查找当前地区,最适合的时间服务器
步骤一:打开网站:http://www.pool.ntp.org/zone/asia 步骤二:复制自动推荐的最合适的同步服务器

3、编辑 /etc/ntp.conf
vim /etc/ntp.conf 复制上述查到的时间服务器,保存
4、启动ntp服务
cd /usr/lib/systemd/system
systemctl start ntpd #启动
systemctl enable ntpd.service #设置开机启动服务
5、同步远程时间服务(下面两个是第2步查询到的前两个ntp)
ntpdate -q 0.asia.pool.ntp.org 1.asia.pool.ntp.org
6、验证服务:ntpq -p
查看当前时间:date -R
打开百度,搜索“时间”,对比时间是否一致
7、建立Job,每天定时自动同步远程服务
crontab -e
00 01 * * * root /usr/sbin/ntpdate -q 0.asia.pool.ntp.org 1.asia.pool.ntp.org
客户端:
1、安装ntp服务
yum install ntp ntpdate -y
2、启动ntp服务
cd /usr/lib/systemd/system
systemctl start ntpd #启动
systemctl enable ntpd.service #设置开机启动服务
3、修改硬件时间,保持和软件NTP时间同步
hwclock -w
4、测试服务器同步
ntpdate -d -b 192.168.85.20
5、如果正常,即可建立Job,自动运行
00 01 * * * root /usr/sbin/ntpdate -q 192.168.85.20
以上就是良许教程网为各位朋友分享的Linux系统相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多干货等着你 !
