Linuk离线安装安装ntp服务和ntpdate

发布时间 2023-12-25 15:39:44作者: 全琪俊

手动同步ntpdate
设置时区:
查看是否存在:timedatectl list-timezones |grep Asia/Sahnghai
设置:timedatectl set-timezones |grep Asia/Sahnghai

查看时区
date -R +0800

ntpdate ip 同步时区

相关安装包:

https://pan.baidu.com/s/1oiXWqfrZ7xQCxCe7fDX0CQ
提取码:SMZH

还可以在下载:
https://pkgs.org/download/ntp

ntp自动同步
安装ntpq服务
1.查询主机Linux系统版本

cat /etc/redhat-release
1
安装这个包

rpm -ivh ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm
1
提示缺少依赖 :

libedit.so.25
ntpdate-4.2.6p5-29.el7.centos.2.x86_64
1
2
安装这个包(libedit.so.25)

rpm -ivh autogen-libopts-5.18-5.el7.x86_64.rpm
1
安装这个包(ntpdate),安装前需要检查服务是否存在

rpm -qa | grep ntpdate(存在删掉即可)
1
删除:

yum remove ntpdate -y
1
在安装

rpm -ivh ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm
1
最后执行安装ntp

rpm -ivh ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm
1
配置 NTP时间同步源
vi /etc/ntp.conf
1
注释原有的

#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 172.17.100.8 #指定NTP服务器地址
1
2
3
4
5
6
7
重启

systemctl restart ntpd
1
查看服务是否运行

ps -ef |grep ntpd
1
测试是否成功

ntpstat
1
出现失败,需要等待大约2-3分钟左右

unsynchronised
time server re-starting
polling server every 8 s
1
2
3
再执行ntpstat出现成功

synchronised to NTP server (172.17.100.8) at stratum 7
time correct to within 951 ms
polling server every 64 s
————————————————
版权声明:本文为CSDN博主「微小的xx」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_20025777/article/details/132289712