Linux公共服务组件之时间同步chrony

Linux公共服务组件之时间同步chrony

浏览次数:
信息来源: 用户投稿
更新日期: 2026-05-15
文章简介

定义:chrony是网络时间协议(NTP)的通用实现。 chrony包含两个程序:chronyd是一个可以在启动时启动的守护程序。chronyc是一个命令行界面程序,用于监视chronyd的性能并在

2025阿里云双十一服务器活动

定义:chrony是网络时间协议(NTP)的通用实现。

chrony包含两个程序:chronyd是一个可以在启动时启动的守护程序。chronyc是一个命令行界面程序,用于监视chronyd的性能并在运行时更改各种操作参数。

时间概念:

UTC(UniversalTimeCoordinated):世界标准时间,属于世界统一世界

GMT(GreenwichMeanTime):英国伦敦郊区的皇家格林尼治天文台的标准时间,因为本初子午线被定义在通过那里的经线。(UTC与GMT时间基本相同,因此不做区分)

CST(ChinaStandardTime):中国标准时间,CMT+8=UTC+8=CST

DST(DaylightSavingTime):夏令时指在夏天太阳升起的比较早时,将时间拨快一小时,以提早日光的使用。

IP

备注

120.10.10.10

Chrony服务端

120.10.10.11

Chrony客户端

服务端和客户端均安装软件包:

yum-yinstallchronysystemctlenablechronydsystemctlstartchronyd

服务端配置,注意两个改动:

建议添加ping较低的公网服务器地址Usepublicserversfromthepool.ntp.orgproject.#Pleaseconsiderjoiningthepool(http://www.pool.ntp.org/join.html).serverntp.aliyun.comiburstservertime.asia.apple.comiburstservertime.windows.comiburstservercn.pool.ntp.orgiburst

Recordtherateatwhichthesystemclockgains/lossestime.driftfile/var/lib/chrony/drift

Allowthesystemclocktobesteppedinthefirstthreeupdatesifitsoffsetislargerthan1second.makestep1.03

Enablekernelsynchronizationofthereal-timeclock(RTC).rtcsync

Enablehardwaretimestampingonallinterfacesthatsupportit.#hwtimestamp*

指定NTP客户端地址或网段,以允许或拒绝连接到扮演时钟服务器的机器#AllowNTPclientaccessfromlocalnetwork.allow120.10.10.0/24

SpecifyfilecontainingkeysforNTPauthentication.#keyfile/etc/chrony.keys

Specifydirectoryforlogfiles.logdir/var/log/chrony

Selectwhichinformationislogged.#logmeasurementsstatisticstracking

Linux公共服务组件之时间同步chrony

systemctlenablechronydsystemctlrestartchronyd

开启网络时间同步timedatectlset-ntptrue

客户端配置,也注意两个改动:

Usepublicserversfromthepool.ntp.orgproject.改动1server120.10.10.10iburst

Recordtherateatwhichthesystemclockgains/lossestime.driftfile/var/lib/chrony/drift

Allowthesystemclocktobesteppedinthefirstthreeupdatesifitsoffsetislargerthan1second.makestep1.03

Enablekernelsynchronizationofthereal-timeclock(RTC).rtcsync

Enablehardwaretimestampingonallinterfacesthatsupportit.#hwtimestamp*

AllowNTPclientaccessfromlocalnetwork.#改动2allow120.10.10.10

SpecifyfilecontainingkeysforNTPauthentication.#keyfile/etc/chrony.keys

Specifydirectoryforlogfiles.logdir/var/log/chrony

Selectwhichinformationislogged.#logmeasurementsstatisticstracking

修改时区或日期时间(首先配置):

#查看日期时间、时区及NTP状态timedatectl

#查看时区列表timedatectllist-timezonestimedatectllist-timezones|?grep?-E"Asia/S.*"

#修改时区timedatectlset-timezoneAsia/Shanghai

#修改日期时间(可以只修改其中一个)timedatectlset-time"2019-09-1915:50:20"

#开启NTP,true表示开启timedatectlset-ntptrue/flase

#查看日期时间、时区及NTP状态timedatectl

#查看时区列表timedatectllist-timezonestimedatectllist-timezones|?grep?-E"Asia/S.*"

#修改时区timedatectlset-timezoneAsia/Shanghai

#修改日期时间(可以只修改其中一个)timedatectlset-time"2019-09-1915:50:20"

#开启NTP,true表示开启timedatectlset-ntptrue/flase

#查看ntp_serverschronycsources-v

#查看ntp_servers状态chronycsourcestats-v

#查看ntp_servers是否在线chronycactivity-v

#查看ntp详细信息chronyctracking-v

标签:
不断增长的全球数据中心运营(全球数据中心市场规模)
« 上一篇
返回列表
下一篇 »

如本文对您有帮助,就请抽根烟吧!