服务器之间时间同步(chrony)

发布时间 2023-06-01 14:49:25作者: 我的心儿

服务器A:192.168.2.203
服务器B:192.168.2.205
让A作为主服务器去外网同步时间,或者直接以A服务器时间为主,让其他服务器去同步

第一步:安装chrony

yum -y install chrony

其对应的文件有:rpm -ql chrony

第二步:配置chrony.conf文件

vi /etc/chrony.conf

A服务器配置:

# 配置时间服务器,以server开头,理论上添加多少时间服务器都可以。<br>server ntp.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
server ntp.aliyun.com minpoll 4 maxpoll 10 iburst
server ntp1.aliyun.com minpoll 4 maxpoll 10 iburst
server ntp1.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
server ntp10.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
server ntp11.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
server ntp12.cloud.aliyuncs.com minpoll 4 maxpoll 10 iburst
server ntp2.aliyun.com minpoll 4 maxpoll 10 iburst
server 192.168.2.203 iburst
 
rtcsync #启用内核时间与 <code>RTC</code> <a class="hl hl-1" href="https://so.csdn.net/so/search?q=%E6%97%B6%E9%97%B4%E5%90%8C%E6%AD%A5&spm=1001.2101.3001.7020" target="_blank" data-report-click="{"spm":"1001.2101.3001.7020","dest":"https://so.csdn.net/so/search?q=%E6%97%B6%E9%97%B4%E5%90%8C%E6%AD%A5&spm=1001.2101.3001.7020"}" data-tit="时间同步" data-pretit="时间同步" rel="noopener">时间同步</a> (自动写回硬件)。
 
makestep 1.0 3 #如果系统时钟的偏移量大于1秒,则允许系统时钟在前三次更新中步进。
 
allow 192.168.2.0/24  #表示允许这个网段的其他主机链接
 
local stratum 10 #即使未与时间源同步,也提供服务时间