linux 技能包【5】:时间同步 chrony
文章目录
- 一、简述
- 二、服务端配置
- 三、客户端配置
- 四、操作命令
一、简述
chrony 是网络时间协议(NTP)的通用实现。
chrony 包含两个程序:
chronyd 是一个可以在启动时启动的守护程序。
chronyc 是一个命令行界面程序,用于监视 chronyd 的性能并在运行时更改各种操作参数。
二、服务端配置
$ yum -y install chrony
$ systemctl enable chronyd
$ systemctl start chronyd$ vim /etc/chrony.conf
# 使用 pool.ntp.org 项目中的公共服务器。以server开,理论上想添加多少时间服务器都可以。
server ntp1.aliyun.com iburst# 指定 NTP 客户端地址,以允许或拒绝连接到扮演时钟服务器的机器
allow 10.0.0.0/24# 指定包含 NTP 身份验证密钥的文件。
# keyfile /etc/chrony.keys# 指定日志文件的目录。
logdir /var/log/chrony# 选择日志文件要记录的信息。
#log measurements statistics tracking$ systemctl restart chronyd
三、客户端配置
$ vim /etc/chrony.conf
server 10.0.0.11(服务端地址) iburst
# 如果在前 3 次校时中时间差大于 1.0s 允许跳跃式校时
makestep 1.0 3$ systemctl restart chronyd
四、操作命令
1)查看日期时间、时区及 NTP 状态
[root@Controller ~]# timedatectl statusLocal time: 三 2021-02-17 19:24:52 CSTUniversal time: 三 2021-02-17 11:24:52 UTCRTC time: 三 2021-02-17 11:24:53Time zone: Asia/Shanghai (CST, +0800)NTP enabled: yes
NTP synchronized: yesRTC in local TZ: noDST active: n/a
- NTP enabled 是否启动 NTP 。
- NTP synchronized 服务启动后是否完成过一次 NTP 同步。
2)启停 NTP 服务
$ timedatectl set-ntp yes|no
3)查看 NTP 服务器
[root@Compute1 ~]# 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
===============================================================================
^* Controller 3 6 17 9 -67us[ -87us] +/- 22ms* 表示chronyd当前同步到的源。+ 表示可接受的信号源,与选定的信号源组合在一起。- 表示被合并算法排除的可接受源。? 指示已失去连接性或其数据包未通过所有测试的源。它也显示在启动时,直到从中至少收集了3个样本为止。x 表示chronyd认为是虚假行情的时钟(即,其时间与大多数其他来源不一致)。〜 表示时间似乎具有太多可变性的来源。
4)查看 NTP 服务器状态
[root@Compute1 ~]# chronyc sourcestats -v
210 Number of sources = 1.- Number of sample points in measurement set./ .- Number of residual runs with same sign.| / .- Length of measurement set (time).| | / .- Est. clock freq error (ppm).| | | / .- Est. error in freq.| | | | / .- Est. offset.| | | | | | On the -.| | | | | | samples. \| | | | | | |
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
==============================================================================
Controller 4 3 6 -7.288 158.265 -307us 18us
5)查看 NTP 服务器是否在线
[root@Compute1 ~]# chronyc activity -v
200 OK
1 sources online
0 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address
6)查看 NTP 详细信息
[root@Compute1 ~]# chronyc tracking -v
Reference ID : 0A00000B (Controller)
Stratum : 4
Ref time (UTC) : Wed Feb 17 11:47:45 2021
System time : 0.000001013 seconds fast of NTP time
Last offset : -0.000308169 seconds
RMS offset : 0.000118546 seconds
Frequency : 20.207 ppm fast
Residual freq : -0.013 ppm
Skew : 1.339 ppm
Root delay : 0.038539626 seconds
Root dispersion : 0.003320527 seconds
Update interval : 65.0 seconds
Leap status : Normal
7)查看时区列表
$ timedatectl list-timezones
8) 修改时区
$ timedatectl set-timezone Asia/Shanghai
9)修改日期时间(可以只修改其中一个)
$ timedatectl set-time "2019-09-19 15:50:20"
linux 技能包【5】:时间同步 chrony相关推荐
- Linux下NTP时间同步服务器搭建
NTP介绍 NTP 服务器是用于局域网服务器时间同步使用的,可以保证局域网所有的服 务器与时间服务器的时间保持一致,某些应用对时间实时性要求高的必须统一时 间. 互联网的时间服务器也有很多,例如 nt ...
- Linux下ntpdate时间同步
Linux下ntpdate时间同步 Ntp服务器配置 时间同步方法 同步命令 # ntpdate ntp服务器域名或IP 例:# ntpdate 192 ...
- linux使用ntp时间同步
linux使用ntp时间同步 1.安装ntp [root@hadoop01 ~]# yum –y install ntp 2.设置ntp服务开机启动 [root@hadoop01 ~]# chkcon ...
- Linux配置自动时间同步
Linux配置自动时间同步 时间同步命令:ntpdate -s time.windows.com 自动时间同步:让linux从time.windows.com自动同步时间 vi /etc/cronta ...
- linux如果时间等于22点,Linux下ntpdate时间同步
1 简介 Linux的时间分为System Clock(系统时间)和Real Time Clock (硬件时间,简称RTC). 系统时间:指当前Linux Kernel中的时间. 硬件时间:主板上有电 ...
- linux 技能包【2】:什么是Mbps、Kbps、bps、kb、mb及其换算和区别?
linux 技能包[2]:什么是Mbps.Kbps.bps.kb.mb及其换算和区别? 文章目录 一.Mbps.kbps.bps.bit.b 二.MB.KB.B 三.区分速率与存储单位 一.Mbps. ...
- windows做时间服务器,linux和windows时间同步
windows做时间服务器,linux和windows时间同步 在Windows上设置NTP 英文版:http://www.satsignal.eu/ntp/setup.html#local Mein ...
- Linux配置ntp时间同步服务
Linux配置ntp时间同步服务 1.首先检查系统中是否安装ntp包: rpm -q ntp 2.执行命令在线安装ntp: yum -y install ntp 3.使用命令查看ntp是否设置为开启启 ...
- Linux服务器时间同步chrony详解+案例
前言 在实际项目部署中,时间同步很重要,必须确保服务器集群时间一致,不然会导致很多问题出现. NTP(Network Time Protocol)网络时间协议基于UDP,用于网络时间同步的协议,使网络 ...
最新文章
- ❤️Spark的关键技术回顾,持续更新!【推荐收藏加关注】❤️
- 四轴飞行器1.4 姿态解算和Matlab实时姿态显示
- BZOJ3832 [Poi2014]Rally 【拓扑序 + 堆】
- Linux repo 文件学习;
- Matlab之switch-case语句
- PHP伪静态与防注入
- 单机环境RocketMQ的安装
- 如何将Twitter消息导入到SAP CRM和Cloud for Customer去
- win10键盘失灵一键修复方法
- 强化学习评估-Doubly robust
- 机器学习-2.Python机器学习软件包Scikit-Learn的学习与运用
- ELK学习遇到的问题3--ERROR	pipeline/output.go:100	Failed to connect to backoff(elasticsearch..
- 如何写一个优质的网站标题title?
- 缠论三大套利技术模型
- Unity2018新功能之2D Animation2D动画
- oracle存储超长文本
- 3dvary灯光材质为什么不亮_为什么老司机都不把卤素车灯升级?听老司机说完,后悔升级了...
- SQL-常用SQL语句
- mac版Mysql可视化工具 - Sequel Pro
- 锐捷网络普教中小学“绿色校园网”解决方案