网站运营
位置:首页>> 网站运营>> centos7安装chronyd服务方式

centos7安装chronyd服务方式

作者:奈小奈  发布时间:2022-06-17 15:04:19 

标签:centos7,安装,chronyd服务

centos7安装chronyd服务

一、双节点部署:

ip主机名
192.168.100.10controller
192.168.100.20compute

二、配置时间同步

1、双节点安装chrony服务(这里是使用本地的软件包进行yum安装)

[root@controller ~]# yum install -y chrony
[root@compute ~]# yum install -y chrony

2、controller修改chrony服务配置文件(在/etc/chrony.conf目录下)

[root@controller ~]# vi /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# 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          //添加#号
server controller 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 all                              //去掉#号
# 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

3、compute 修改chrony配置文件

[root@compute ~]# vi /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# 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
server 192.168.100.10 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 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

4、双节点重启服务,并设置开机自启

[root@controller ~]# systemctl restart chronyd && systemctl enable chronyd
[root@compute ~]# systemctl restart chronyd && systemctl enable chronyd

5、controller开启ntp同步

[root@controller ~]# timedatectl set-ntp true

6、双节点执行chronyc sources命令,结果中存在以^*开头的行,则同步成功

[root@controller ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample              
===============================================================================
^* controller                   10   6   377    27   +186ns[-8404ns] +/-   17us
[root@compute ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample              
===============================================================================
^* controller                   10   6    17    34  -4280ns[  -13us] +/-  328us

Centos7使用chronyd进行时钟同步

最近要做阿里云迁移 IDC 机房,整理下 Linux 运维基线,简单记录,以备后用~

安装

# 默认已经安装
$ yum install -y chrony

配置文件

$ cat /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
# 国家服务器
server 0.cn.pool.ntp.org
server 1.cn.pool.ntp.org
server 2.cn.pool.ntp.org
server 3.cn.pool.ntp.org
# 阿里
server ntp.aliyun.com
# 腾讯
server time1.cloud.tencent.com
server time2.cloud.tencent.com
server time3.cloud.tencent.com
server time4.cloud.tencent.com
server time5.cloud.tencent.com
# 苹果
server time.asia.apple.com
# 微软
server time.windows.com
# 其他
server cn.ntp.org.cn
# 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 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

启动服务及时区设置

# 启动服务
$ systemctl start chronyd
# 开机启动
$ systemctl enable chronyd
# 查看当前状态
$ systemctl status chronyd
# 查看亚洲时区
$ timedatectl list-timezones | grep Asia
# 设置时区
$ timedatectl set-timezone Asia/Shanghai

验证服务

# 查看现有的时间服务器
$ chronyc sources -v
# 查看时间服务器状态
$ chronyc sourcestats -v
# 显示时钟同步相关参数
$ chronyc tracking
# 查看当前时区及时间
$ timedatectl 

手动同步时间

# 使用 ntpdate 同步时间
$ ntpdate ntp.aliyun.com
# chronyd 未启动时,如下命令同步时间
$ chronyd -q 'server pool.ntp.org iburst'
# chronyd 启动时,使用如下命令同步时间
$ chronyc -a 'burst 4/4' && sleep 10 && chronyc -a makestep

手动设置时间

# date 设置时间
$ date -s '2021-06-03 19:00:00'
# 关闭 ntp 同步后,才可以使用 timedatectl 进行时间设置
$ timedatectl set-ntp false
# 设置日期和时间
$ timedatectl set-time '2021-06-03 19:00:00'
# 设置日期
$ timedatectl set-time '2021-06-03'
# 设置时间
$ timedatectl set-time '19:00:00'
# 设置完成后,再开启
$ timedatectl set-ntp true

来源:https://blog.csdn.net/weixin_45849657/article/details/109286138

0
投稿

猜你喜欢

  • 每个站长在建站之初,都很明确自己网站的定位及网站的目标客户群,那么,在具体的推广工作中,我们该如何寻找自己的目标客户,以便更有针对性的推广自
  • 我们都知道关键词分析在算法中起着承上启下的作用。百度在还没调整算法之前所用的关键词分析是最大匹配法:正向匹配法,逆向匹配法和双向匹配法。比如
  • WordPress将其所有信息片段(包括文章、页面、评论、博客链接、插件设置等)存储在MySQL数据库中。 虽然WordPress用户可以通
  • 在百度C2C产品“百度有啊”即将上线的时候,淘宝网站曾经屏蔽百度搜索爬虫,禁止百度搜索引擎抓取淘宝网站的网页内容,淘宝官方的解释是“杜绝不良
  • 网页内容是写给谁看得?这个问题不是客户问我的,而是我提出的。对这个问题的理解和把握,可以看出你对SEO的认识程度。或许很多网站设计者会毫不犹
  • 在前面的“细说 AdSense 政策”系列中,我们陆续介绍了一些常见的政策问题。今天,我们再向大家介绍一下另一个非常常见的政策问题 – 版权
  • 这个架构是目前我个人觉得比较稳妥并且最方便的架构,易于多数人接受:  前端的lvs和squid,按照安装方法,把epol
  • 6月4日至6月10日,短短5个交易日内,腾讯控股累积重挫15%,放量击穿年线,而同期香港恒生指数基本保持持平。拥有同时在线人数超过 1亿的Q
  • windows2003server标准服务当中需要停止的服务,作为IIS网络服务器,以上服务务必要停止,如果需要SSL证书服务,则设置方法不
  • 又读了一遍这个 PPT: Federation at Flickr: Doing Billions of Queries Per Day ,
  • 本文介绍了CentOS下MySQL的彻底卸载的几种方法,分享给大家,具体如下:1:查看MySQL是否安装:方式1:[root@localho
  • Godaddy主机管理域名看起来是项很庞大的工作,要做很多的工作,其实也没那么难,下面这个手册将帮助你简化域名管理,并一步步帮助Godadd
  • 核心提示:综述P2P流量识别端口识别法、应用层特征识别法、流量模式识别法以及连接模式识别,概述P2P流量识别技术,并对发展进行展望&
  • 2001年到2003年,亚洲交友中心的免费会员女2美金男1美金,各类的点击冲浪邮件等赚钱联盟数不胜数,那时候可以说就是个拣美金的时代。03年
  • 最近的一份调查报告显示,有相当一部分用户将会采用新的服务器操作系统,并且持这种意向的人越来越多。由于新的服务器系统和Vista类似,有着与V
  • 很奇怪,最近自建的FTP,Serv-U域总是一开机就自动离线,重新填写域IP,应用之后,就正常了。但是重启之后,又挂掉,造成FTP连接不上。
  • Google Adsense的西联汇款支付虽然已经准备了很长的时间,但是在相关配套的支持上还是有很多欠缺,所以发布者会有诸多疑问,这里有大部
  • 在第一部分( 搜索引擎中图像优化漫谈(一)),我们讨论了优化用于网站或是博客图片和图像的一些基本方法。按照SEO的要求,把重要的东西放在第一
  • 我也把我的方法做了一下实验,使用serv-u做的,有一点错误,不过终归做了出来,下面总结一下:PASV服务器放在ISA后面,其实就是要解决两
  • 建立样本网络,需要对命名进行如下规范:服务器将建立在名为ASPDomain.com的假想域中。每台服务器拥有惟一的内部域名.AspHosti
手机版 网站运营 asp之家 www.aspxhome.com