Linux时间同步服务chrony
1、简介
Chrony是一个开源的自由软件,像CentOS 7或基于RHEL 7操作系统,已经是默认服务,默认配置文件在 /etc/chrony.conf 。它能保持系统时间与时间服务器(NTP)同步,让时间始终保持同步。相对于NTP时间同步软件,占据很大优势。其用法也很简单。Chrony有两个核心组件,分别是:
chronyd:是守护进程,主要用于调整内核中运行的系统时间和时间服务器同步。它确定计算机增减时间的比率,并对此进行调整补偿。
chronyc:提供一个用户界面,用于监控性能并进行多样化的配置。它可以在chronyd实例控制的计算机上工作,也可以在一台不同的远程计算机上工作
NTP使用123/UDP端口协议
2、使用方式
1)系统默认已经安装,如未安装,请执行以下命令安装:
yum install chrony -y
2)启动并加入开机自启动
systemctl enable chronyd.service
systemctl start chronyd.service
3)查看状态
systemctl status chronyd.service
4)配置文件详解
cat /etc/chrony.conf
# 使用pool.ntp.org项目中的公共服务器。以server开始,理论上你想添加多少时间服务器都可以。
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
server 0.centos.pool.ntp.org iburst
server 1.centos.pool.ntp.org iburst
server 2.centos.pool.ntp.org iburst
server 3.centos.pool.ntp.org iburst
# 根据实际时间计算出服务器增减时间的比率,然后记录到一个文件中,在系统重启后为系统做出最佳时间补偿调整。
driftfile /var/lib/chrony/drift
# chronyd根据需求减慢或加速时间调整,
# 在某些情况下系统时钟可能漂移过快,导致时间调整用时过长。
# 该指令强制chronyd调整时期,大于某个阀值时步进调整系统时钟。
# 只有在因chronyd启动时间超过指定的限制时(可使用负值来禁用限制)没有更多时钟更新时才生效。
makestep 1.0 3
# 将启用一个内核模式,在该模式中,系统时间每11分钟会拷贝到实时时钟(RTC)。
rtcsync
# Enable hardware timestamping on all interfaces that support it.
# 通过使用hwtimestamp指令启用硬件时间戳
#hwtimestamp eth0
#hwtimestamp eth1
#hwtimestamp *
# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2
# 指定一台主机、子网,或者网络以允许或拒绝NTP连接到扮演时钟服务器的机器
#allow 192.168.0.0/16
#deny 192.168/16
# Serve time even if not synchronized to a time source.
local stratum 10
# 指定包含NTP验证密钥的文件。
#keyfile /etc/chrony.keys
# 指定日志文件的目录。
logdir /var/log/chrony
# Select which information is logged.
#log measurements statistics tracking
5)设置时区
查看当前系统时区
$ timedatectl
Local time: Fri 2018-2-29 13:31:04 CST
Universal time: Fri 2018-2-29 05:31:04 UTC
RTC time: Fri 2018-2-29 08:17:20
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
如果你当前的时区不正确,请按照以下操作设置。
查看所有可用的时区:
$ timedatectl list-timezones
筛选式查看在亚洲S开的上海可用时区:
$ timedatectl list-timezones | grep -E "Asia/S.*"
Asia/Sakhalin
Asia/Samarkand
Asia/Seoul
Asia/Shanghai
Asia/Singapore
Asia/Srednekolymsk
设置当前系统为Asia/Shanghai上海时区:
$ timedatectl set-timezone Asia/Shanghai
设置完时区后,强制同步下系统时钟:
$ chronyc -a makestep
200 OK
服务器端和客户端修改/etc/chrony.conf配置文件,添加
server xxxx.xx.xx.xx iburst
6)在客户端执行
chronyc sources //刷新一下同步情况
chronyc sources -v //查看时间同步源的状态
netstat -antpul | grep chron //查看该服务端口,并开通相应端口
Linux时间同步服务chrony的更多相关文章
- Linux 时间同步 05 chrony时间同步
Linux 时间同步 05 chrony时间同步 目录 Linux 时间同步 05 chrony时间同步 chrony 的优势: chrony包介绍 安装chrony 配置与外部时间服务器进行时间同步 ...
- 网络时间同步服务和chrony
时间同步和chrony 时间同步:多主机协作工作时,各个主机时间同步很重要,时间不一致会造成很多重要应用的故障,如:加密协议,日志,集群等, 利用NTP(Network Time Protocol) ...
- centos7搭建ntp时间同步服务器chrony服务
centos7搭建ntp时间同步服务器chrony服务 前言: 在centos6的时候我们基本使用的是ntp服务用来做时间同步,但是在centos7后推荐是chrony作为时间同步器的服务端使用, ...
- chrony时间同步 服务端 客户端 安装配置
chrony时间同步 服务端 客户端 安装配置 原创内容http://www.cnblogs.com/elvi/p/7658021.html #!/bin/sh #运行环境 centos7 #chro ...
- 关于linux下ntp时间同步服务的安装与配置
1.安装ntp服务,要使用时间同步.那么服务端与客户端都需要使用如下命令安装NTP软件包 [root@ ~]# yum install ntp -y 2.如果只是作为客户端的话,配置则可以非常简单,编 ...
- centos 8.x系统配置chrony时间同步服务
redhat/centos 7.x默认使用的时间同步服务为ntp服务,但是从redhat/centos 8开始在官方的仓库中移除了ntp软件,换成默认的chrony进行时间同步的服务,虽然也可以通过添 ...
- Chrony时间同步服务
概: 网络时间协议(Network Time Protocol,NTP)是用于网络时间同步的协议.提供NTP时间同步服务的软件有很多,这里采用Chrony软件来实现时间同步 chrony 的优势: ...
- Linux 时间同步 01 简介
Linux 时间同步 01 简介 目录 Linux 时间同步 01 简介 时间同步 公共NTP服务器地址及IP 系统时间相关文件 时间同步 大数据产生与处理系统是各种计算设备集群的,计算设备将统一.同 ...
- Linux 常用服务总结
使用linux有一段时间了,把自己在身边经常听到,使用linux经常遇到的linux常见服务总结出来,这样遇到问题会有更多的解决问题的办法,听别人摆这些专业术语时,才不会不知所云. 服务: 1.NFS ...
随机推荐
- 艺术鬼才,Unicode 字符还能这么玩?
上周的时候,朋友圈的直升飞机不知道为什么就火了,很多朋友开着各种花式飞机带着起飞. 还没来得及了解咋回事来着,这个直升飞机就到的微博热搜. 后面越来越多人开来他们的直升飞机,盘旋在朋友圈上方.于是很多 ...
- gitlab的还原
源服务器: ip: 192.168.0.199 系统:CentOS7.2 内核: 3.10.0-327 gitlab版本: gitlab-ce-8.0.5 新服务器: ip: 192.168.0.19 ...
- MyBatis----resultMap的使用
- Fortify Audit Workbench Cookie Security: Cookie not Sent Over SSL
Abstract 所创建的 cookie 的 secure 标记没有设置为 true. Explanation 现今的 Web 浏览器支持每个 cookie 的 secure 标记. 如果设置了该标记 ...
- MacOS工具
原文是"池建强"的微信文章,公众号为"MacTalk" 1. Alfred 2. iTerm2 一些基本功能如下: 分窗口操作:shift+command+d( ...
- Django学习路26_转换字符串大小写 upper,lower
在 urls 中注册 url(r'getstr',views.getstr) 在 views.py 中添加函数 def getstr(request): string = 'abc' string_2 ...
- 一款功能简约到可怜的SQL 客户端
你有一个思想,我有一个思想,我们交换后,一个人就有两个思想 If you can NOT explain it simply, you do NOT understand it well enough ...
- PHP strftime() 函数
------------恢复内容开始------------ 实例 根据区域设置格式化本地日期和时间: <?php echo(strftime("%B %d %Y, %X %Z&quo ...
- 6.6 省选模拟赛 线段 二维数点问题 树套树 CDQ分治
LINK:线段 还是太菜了 没看出这道题真正的模型 我真是一个典型的没脑子选手. 考虑如何查询答案. 每次在一个线段x的状态被更改后 可以发现有影响的是 和x相连那段极长连续1子段. 设这个子段左端点 ...
- SpringBoot2 整合 Swagger2文档 使用BootstrapUI页面
SpringBoot2 整合 Swagger2 SpringBoot整合三板斧 第一步.引入pom <dependency> <groupId>com.spring4all&l ...