CentOS8 同步时间chrony ntpdate已无法使用

CentOS8系统中,原有的时间同步服务 ntp/ntpdate服务已经无法使用,使用yum安装,提示已不存在。

[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 8.1.1911 (Core) 
[root@localhost ~]# yum install ntp
上次元数据过期检查:-1 day, 16:29:03 前,执行于 2020年08月03日 星期一 19时00分30秒。
未找到匹配的参数: ntp
错误:没有任何匹配: ntp

在CentOS8中,已使用chrony替代ntp,首先安装chrony

#使用dnf安装
dnf install -y chrony
# 也可以用yum安装
yum install -y chrony

安装chrony成功,修改chrony服务的配置文件

1、临时同步时间方法:chronyd -q 'server ntp.ntsc.ac.cn iburst'

[root@localhost ~]# chronyd -q 'server ntp.ntsc.ac.cn iburst'
2020-08-03T03:36:59Z chronyd version 3.5 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
2020-08-03T03:37:03Z System clock wrong by 0.021681 seconds (step)
2020-08-03T03:37:03Z chronyd exiting
[root@localhost ~]# date
2020年 08月 03日 星期一 11:37:05 CST

2、永久设置同步时间服务器(修改配置文件)

root@localhost ~]# vim /etc/chrony.conf 

3、注释掉第三行原有的时间服务器地址,设置为阿里云的时间服务地址

4、重启网络时间服务chrony,并设置服务后台运行。

#重启时间服务
[root@localhost ~]# systemctl restart chronyd.service
#设置时间同步服务开机启动
[root@localhost ~]# systemctl enable chronyd.service

5、时间就会自动同步。

猜你喜欢

转载自blog.csdn.net/weixin_42350212/article/details/107783051
今日推荐