Linuk离线安装安装ntp服务和ntpdate
手动同步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
安装这个包
rpm -ivh ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm
提示缺少依赖 :
libedit.so.25
ntpdate-4.2.6p5-29.el7.centos.2.x86_64
安装这个包(libedit.so.25)
rpm -ivh autogen-libopts-5.18-5.el7.x86_64.rpm
安装这个包(ntpdate),安装前需要检查服务是否存在
rpm -qa | grep ntpdate(存在删掉即可)
删除:
yum remove ntpdate -y
在安装
rpm -ivh ntpdate-4.2.6p5-29.el7.centos.2.x86_64.rpm
最后执行安装ntp
rpm -ivh ntp-4.2.6p5-29.el7.centos.2.x86_64.rpm
配置 NTP时间同步源
vi /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 iburst
添加
server 172.17.100.8 #指定NTP服务器地址
重启
systemctl restart ntpd
查看服务是否运行
ps -ef |grep ntpd
测试是否成功
ntpstat
出现失败,需要等待大约2-3分钟左右
unsynchronised
time server re-starting
polling server every 8 s
再执行ntpstat出现成功
synchronised to NTP server (172.17.100.8) at stratum 7
time correct to within 951 ms
polling server every 64 s