centos离线安装chrony

环境

CentOS Linux release 7.9.2009 (Core)

工具

chrony-2.2.1.tar.gz 下载地址:https://download.tuxfamily.org/chrony/

安装步骤

删除原chrony

yum remove -y chrony

如果之前是编译安装的可以选择不删除,在安装时把旧版本覆盖掉。

如果没有,可以直接跳过。

安装chrony

#解压
[root@localhost ~]# tar zxvf chrony-2.2.1.tar.gz
[root@localhost ~]# cd chrony-2.2.1
#编译安装
[root@localhost chrony-2.2.1]# ./configure --prefix=/usr
[root@localhost chrony-2.2.1]# make
[root@localhost chrony-2.2.1]# make install
#查看版本
[root@localhost chrony-2.2.1]# chronyd -v
chronyd (chrony) version 2.2.1 (+CMDMON +NTP +REFCLOCK +RTC -PRIVDROP -SCFILTER +SECHASH +ASYNCDNS +IPV6 -DEBUG)
#部署配置文件和服务控制脚本
[root@localhost chrony-2.2.1]# cp examples/chrony.conf.example2 /etc/chrony.conf
[root@localhost chrony-2.2.1]# cp examples/chrony*.service /usr/lib/systemd/system/
[root@localhost chrony-2.2.1]# ls /usr/lib/systemd/system/chrony*.service
/usr/lib/systemd/system/chronyd.service  /usr/lib/systemd/system/chrony-wait.service
#启动服务
[root@localhost chrony-2.2.1]# systemctl start chronyd.service
#加入开机自启
[root@localhost chrony-2.2.1]# systemctl enable chronyd.service
#检查服务状态
[root@localhost chrony-2.2.1]# systemctl status chronyd.service

配置chrony

[root@localhost chrony-2.2.1]# vim /etc/chrony.conf
#编辑该行,设置ntp服务器地址,pool.ntp.org 替换为ntp服务器地址,注:保留1个即可,其他NTP服务器地址注销
pool pool.ntp.org iburst
#重启chrony
[root@localhost chrony-2.2.1]# systemctl restart chronyd.service

查看状态

重启后等几分钟,让系统识别到时间服务器,期间可多次执行chronyc sourceschronyc sources -v查询状态

[root@localhost chrony-2.2.1]# chronyc sources 
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* 192.168.6.202                 2   6    37    60    -50us[ +603us] +/- 1329us

^*表示当前同步的服务器

 end.

posted @ 2023-03-16 14:40  xjournal  阅读(2341)  评论(0编辑  收藏  举报