chrony时间同步软件介绍
本文分享自天翼云开发者社区《chrony时间同步软件介绍》,作者:刘****苏
chrony是网络时间协议NTP的通用实现,它可以将系统时钟和`NTP服务器同步。它支持在各种条件下包括间歇性的网络连接、严重阻塞的网络、不断变化的温度以及支持不连续的运行并且可以运行于虚机上。
本文介绍chrony工具的安装和使用,包括两个节点:一个作为时间服务器,另一个作为客户端。
执行如下命令来安装chrony:
[root@kvm ~]# yum install chrony
[root@kvm ~]# rpm -ql chrony
/etc/NetworkManager/dispatcher.d/20-chrony-dhcp
/etc/NetworkManager/dispatcher.d/20-chrony-onoffline
/etc/chrony.conf
/etc/chrony.keys
/etc/dhcp/dhclient.d/chrony.sh
/etc/logrotate.d/chrony
/etc/sysconfig/chronyd
/usr/bin/chronyc
/usr/lib/.build-id
/usr/lib/.build-id/38
/usr/lib/.build-id/38/1d3a324ce66865ba879dfa43d49e0e0c1e2c41
/usr/lib/.build-id/43
/usr/lib/.build-id/43/444c816fcf0802c43011f282afaf9feded4c56
/usr/lib/systemd/ntp-units.d/50-chronyd.list
/usr/lib/systemd/system/chrony-dnssrv@.service
/usr/lib/systemd/system/chrony-dnssrv@.timer
/usr/lib/systemd/system/chrony-wait.service
/usr/lib/systemd/system/chronyd.service
/usr/libexec/chrony-helper
/usr/sbin/chronyd
/usr/share/doc/chrony
/usr/share/doc/chrony/FAQ
/usr/share/doc/chrony/NEWS
/usr/share/doc/chrony/README
/usr/share/doc/chrony/ntp2chrony.py
/usr/share/licenses/chrony
/usr/share/licenses/chrony/COPYING
/usr/share/man/man1/chronyc.1.gz
/usr/share/man/man5/chrony.conf.5.gz
/usr/share/man/man8/chronyd.8.gz
/var/lib/chrony
/var/lib/chrony/drift
/var/lib/chrony/rtc
/var/log/chrony
如下所示为配置文件:
[root@kvm ~]# cat /etc/chrony.conf
pool 2.centos.pool.ntp.org iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
allow 0/0
# Serve time even if not synchronized to a time source.
local stratum 10
# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys
# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
其中:
pool:为外部时钟源地址
rtcsync:开启硬件时钟的同步机制,linux内核每11分钟同步一次系统时钟到硬件时钟
local stratum 10:当外部时钟源不可用的时候,以本机时钟为准继续提供服务
allow 0/0:允许的客户端的cidr
启动服务后查看状态:
[root@kvm ~]# systemctl start chronyd
[root@kvm ~]#
[root@kvm ~]#
[root@kvm ~]# systemctl status chronyd
● chronyd.service - NTP client/server
Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2023-09-08 19:02:50 CST; 2min 43s left
Docs: man:chronyd(8)
man:chrony.conf(5)
Process: 11542 ExecStopPost=/usr/libexec/chrony-helper remove-daemon-state (code=exited, status=0/SUCCESS)
Process: 11552 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
Process: 11547 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
Main PID: 11550 (chronyd)
Tasks: 1 (limit: 52427)
Memory: 924.0K
CGroup: /system.slice/chronyd.service
└─11550 /usr/sbin/chronyd
Sep 08 19:02:50 kvm chronyd[11550]: chronyd version 4.2 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +NTS +SECHASH +IPV6 +DEBUG)
Sep 08 19:02:50 kvm chronyd[11550]: Frequency 1.633 +/- 0.046 ppm read from /var/lib/chrony/drift
Sep 08 19:02:50 kvm chronyd[11550]: Using right/UTC timezone to obtain leap second data
Sep 08 19:02:50 kvm systemd[1]: Started NTP client/server.
Sep 08 19:02:55 kvm chronyd[11550]: Selected source 36.110.233.85 (2.centos.pool.ntp.org)
Sep 08 19:02:55 kvm chronyd[11550]: System clock wrong by -791.549636 seconds
Sep 08 18:49:44 kvm chronyd[11550]: System clock was stepped by -791.549636 seconds
Sep 08 18:49:44 kvm chronyd[11550]: System clock TAI offset set to 37 seconds
Sep 08 18:50:49 kvm chronyd[11550]: Selected source 119.28.206.193 (2.centos.pool.ntp.org)
Sep 08 18:54:07 kvm chronyd[11550]: Source 81.16.177.123 replaced with 78.46.102.180 (2.centos.pool.ntp.org)
[root@kvm ~]#
[root@kvm ~]# netstat -tunlp |grep chrony
udp 0 0 0.0.0.0:123 0.0.0.0:* 11550/chronyd
udp 0 0 127.0.0.1:323 0.0.0.0:* 11550/chronyd
udp6 0 0 ::1:323 :::* 11550/chronyd
[root@kvm ~]#
[root@kvm ~]# chronyc sources -v
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current best, '+' = combined, '-' = not combined,
| / 'x' = may be in error, '~' = too variable, '?' = unusable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^- 79.133.44.136 1 6 377 56 -10ms[ -10ms] +/- 138ms
^- electrode.felixc.at 2 6 33 55 +17ms[ +17ms] +/- 119ms
^* 119.28.206.193 2 6 377 60 +1706us[+2327us] +/- 40ms
^+ 36.110.233.85 2 6 377 58 -1324us[-1324us] +/- 68ms
chrony守护进程监听在udp协议的123和323端口。
客户端节点上安装好chrony后,修改配置文件如下所示:
[root@node1 ~]# cat /etc/chrony.conf
server 172.24.21.221 iburst
# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift
# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 3600 3
# Enable kernel synchronization of the real-time clock (RTC).
rtcsync
# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# Allow NTP client access from local network.
#allow 192.168.0.0/16
# Serve time even if not synchronized to a time source.
#local stratum 10
# Specify file containing keys for NTP authentication.
#keyfile /etc/chrony.keys
# Specify directory for log files.
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
查看状态:
[root@node1 ~]# chronyc sources -v
210 Number of sources = 1
.-- Source mode '^' = server, '=' = peer, '#' = local clock.
/ .- Source state '*' = current synced, '+' = combined , '-' = not combined,
| / '?' = unreachable, 'x' = time may be in error, '~' = time too variable.
|| .- xxxx [ yyyy ] +/- zzzz
|| Reachability register (octal) -. | xxxx = adjusted offset,
|| Log2(Polling interval) --. | | yyyy = measured offset,
|| \ | | zzzz = estimated error.
|| | | \
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* 172.24.21.221 3 6 377 37 -7753ns[ +140us] +/- 29ms
chrony默认是采用连续同步的方式来同步时钟的,并非采用跳变的方式。
chrony时间同步软件介绍的更多相关文章
- CentOS7.4 chrony时间同步服务器部署(替代NTPD)
Chrony是一个开源的自由软件,它能保持系统时钟与时钟服务器(NTP)同步,让时间保持精确. 它由两个程序组成:chronyd和chronyc. chronyd是一个后台运行的守护进程,用于调整内核 ...
- Linux 时间同步 05 chrony时间同步
Linux 时间同步 05 chrony时间同步 目录 Linux 时间同步 05 chrony时间同步 chrony 的优势: chrony包介绍 安装chrony 配置与外部时间服务器进行时间同步 ...
- Chrony时间同步服务
概: 网络时间协议(Network Time Protocol,NTP)是用于网络时间同步的协议.提供NTP时间同步服务的软件有很多,这里采用Chrony软件来实现时间同步 chrony 的优势: ...
- 软件介绍(apache lighttpd nginx)
一.软件介绍(apache lighttpd nginx) 1. lighttpd Lighttpd是一个具有非常低的内存开销,cpu占用率低,效能好,以及丰富的模块等特点.lighttpd是众多 ...
- Visual paradigm软件介绍
Visual paradigm软件介绍 说起Visual Paradigm你可能并不陌生,因为此前有一款功能强大的UML软件叫Visual Paradigm for UML,在这款软件在v11.1的时 ...
- chrony时间同步 服务端 客户端 安装配置
chrony时间同步 服务端 客户端 安装配置 原创内容http://www.cnblogs.com/elvi/p/7658021.html #!/bin/sh #运行环境 centos7 #chro ...
- sumatrapdf 软件介绍
sumatrapdf 软件介绍 介绍 支持PDF, ePub, Mobi, XPS, DjVu, CHM, CBZ 和 CBR格式的电子文件 仅支持Windows,原因见官网论坛 绿色版,小巧,于此 ...
- 一.软件介绍(apache lighttpd nginx)
一.软件介绍(apache lighttpd nginx) 1. lighttpd Lighttpd是一个具有非常低的内存开销,cpu占用率低,效能好,以及丰富的模块等特点.lighttpd是众多 ...
- Linux基础学习-chrony时间同步服务
Chrony时间同步 NTP(Network Time Protocol,网络时间协议)是用来使网络中的各个计算机时间同步的一种协议.它的用于是把计算机的时钟同步到世界协调时UTC,其精度在局域网内可 ...
- Java机器学习软件介绍
Java机器学习软件介绍 编写程序是最好的学习机器学习的方法.你可以从头开始编写算法,但是如果你要取得更多的进展,建议你采用现有的开源库.在这篇文章中你会发现有关Java中机器学习的主要平台和开放源码 ...
随机推荐
- 输入输出-python
输入输出-python 输入输出 输入 Python提供了input()函数用于从控制台输入数据. name = input("请输入您的姓名:") print("您输入 ...
- 深入解析 Spring AI 系列:解析请求参数处理
大家在使用Spring AI项目开发Agent时,可能会发现,尽管外层的接口设计和调用逻辑比较统一,但实际上每个第三方接口在实现时都会有一些微妙的差异.这些差异可能体现在请求参数的构造.数据格式的处理 ...
- NFS v3及v4协议区别
本文分享自天翼云开发者社区<NFS v3及v4协议区别>,作者:章****凯 NFS v4相比v3,有部分功能的增强,如果应用需要实现如下功能,则必须使用NFS v4(建议和应用侧确实是否 ...
- [业界方案] Yarn的业界解决方案和未来方向
[业界方案] Yarn的业界解决方案和未来方向 目录 [业界方案] Yarn的业界解决方案和未来方向 0x00 摘要 0x01 Yarn 1.1 参考文章 0x02 分析 2.1 综述 2.1.1 y ...
- mac spark+hive+hadoop 数据分析环境搭建(单机简版)
apache产品下载地址: http://archive.apache.org/dist/ mysql5.6 brew方式安装配置: Icon mysql做为元数据存储使用. brew searc ...
- jenkins+gitee+tomcat
1.Jenkins [系统配置]添加gitee服务 2.项目配置 General 配置之前配置的gitee服务连接 3.源码配置 4.构建配置 5.构建触发器配置 最重要的是: 6.在gitee中配置 ...
- 计算机基础知识问答:C/C++篇
讲解一下C语言内存空间的模型: 代码区:它是用来存放程序执行代码的一块内存区域.通常,这部分区域是只读的,防止程序意外地修改了它的指令. 常量区:数据段包含了程序中已初始化的全局变量和静态变量.而BS ...
- Thymeleaf 在页面中直接显示内容
Thymeleaf 在页面中直接显示内容 一般情况下 Thymeleaf 模板要输出变量需要在某个标签中(如<div>.<span>)写th:text等属性来实现.但有时我 ...
- Deepseek学习随笔(6)--- API 开发与自动化
获取 API Key 要开始使用 DeepSeek 的 API,你首先需要获取 API Key: 登录 DeepSeek 控制台 . 进入 API 管理 页面,生成 API Key. API 调用示例 ...
- git安装教程以及生成git ssh key
问题 GitHub拉取代码需要SSH,总是忘记命令,现网百度.记录下来,以后靠自己的博文 第一步 安装git 地址: https://git-scm.com/download/win 安装它 第二步 ...