一、集群环境:

  系统:CentOS7-minimal

  集群中的两台主机ip:10.132.226.103/24  10.132.226.104/24

二、CentOS7中时间相关命令timedatectl例子介绍:

  1.查看主机中的时间信息:timedatectl

 [root@controller ~]# timedatectl
Local time: Tue -- :: CST
Universal time: Mon -- :: UTC
RTC time: Tue -- ::
Time zone: Asia/Shanghai (CST, +)
NTP enabled: yes
NTP synchronized: yes //NTP时间同步开启
RTC in local TZ: yes
DST active: n/a

  2.查看可获取的时区:timedatectl list-timezones

 [root@controller ~]# timedatectl list-timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
........

  3.设置本地时区:timedatectl set-timezone Asia/Shanghai

 # timedatectl set-timezone Asia/Shanghai

  4.设置时间日期等:

 [root@controller ~]# timedatectl set-time "2018-07-19 18:08:08"
[root@controller ~]# timedatectl set-time "2018-07-19"
[root@controller ~]# timedatectl set-time "18:08:08"

  5.将硬件时钟设置为本地时区:

 [root@controller ~]# timedatectl set-local-rtc 1

  6.将硬件时钟设置为协调世界时(UTC):

[root@controller ~]# timedatectl set-local-rtc 

三、安装配置chrony

  1.主节点安装:

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

    2.主节点配置:编辑 /etc/chrony.conf文件

[root@controller ~]# vim /etc/chrony.conf

# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#以下0.centos.pool.ntp.org等为远程时间同步服务器可自行更改
server .centos.pool.ntp.org iburst
server .centos.pool.ntp.org iburst
server .centos.pool.ntp.org iburst
server .centos.pool.ntp.org iburst
#~~~~~~~~~~~省略若干~~~~~~~~#
# Allow NTP client access from local network.
#allow 192.168.0.0/
#修改!!!
#此处添加子节点的IP
allow 10.132.226.104/
#~~~~~~~~~~~省略若干~~~~~~~~#

  3.主节点重启NTP服务

 [root@controller ~]# systemctl enable chronyd.service
[root@controller ~]# systemctl start chronyd.service

  4.子节点安装:

 [root@compute1 ~]# yum install -y chrony

  5.子节点配置:编辑 /etc/chrony.conf文件

 [root@compute1 etc]# vim /etc/chrony.conf

 # Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#修改 把其他远程同步节点全部注释,并添加主节点ip或者hosts
#server .centos.pool.ntp.org iburst
#server .centos.pool.ntp.org iburst
#server .centos.pool.ntp.org iburst
#server .centos.pool.ntp.org iburst
server controller iburst

四、验证同步服务是否搭建成功:

  1.使用命令 chronyc sources

 [root@compute1 etc]# chronyc sources
Number of sources =
MS Name/IP address Stratum Poll Reach LastRx Last sample
===============================================================================
^* controller -5232us[-6125us] +/- 47ms

    注意:如果controller前为^? 可能是主节点防火墙开启,导致子节点无法进行时间同步。

  可以也可以通过timedatectl命令查看:

 [root@compute1 etc]# timedatectl
Local time: Mon -- :: CST
Universal time: Mon -- :: UTC
RTC time: Mon -- ::
Time zone: Asia/Shanghai (CST, +)
NTP enabled: yes
NTP synchronized: yes //此处如果为no说明NTP时钟为开启
RTC in local TZ: yes
DST active: n/a

  解决方法:关闭主节点防火墙

CentOS7 使用chrony搭建集群中的时间同步服务的更多相关文章

  1. 如何使用Istio 1.6管理多集群中的微服务?

    假如你正在一家典型的企业里工作,需要与多个团队一起工作,并为客户提供一个独立的软件,组成一个应用程序.你的团队遵循微服务架构,并拥有由多个Kubernetes集群组成的广泛基础设施. 由于微服务分布在 ...

  2. Linux集群配置ntp时间同步服务

    集群中时间不同步有可能会让大数据的应用程序运行混乱,造成不可预知的问题,比如Hbase,当时间差别过大时就会挂掉,所以在大数据集群中,ntp服务,应该作为一种基础的服务,以下在演示在CentOS 7. ...

  3. 使用Cloudrea Manager在CDH集群中添加kafka服务节点,更改borker.id配置后无法启动

    需要保证meta.properties文件中的broker.id和cloudrea manager的web页面上kafka配置的broker.id一致,最好让server.properties中的br ...

  4. Redis 实战篇之搭建集群

    Redis 集群简介# Redis Cluster 即 Redis 集群,是 Redis 官方在 3.0 版本推出的一套分布式存储方案.完全去中心化,由多个节点组成,所有节点彼此互联.Redis 客户 ...

  5. k8s集群中安装rook-ceph

    容器的持久化存储 容器的持久化存储是保存容器存储状态的重要手段,存储插件会在容器里挂载一个基于网络或者其他机制的远程数据卷,使得在容器里创建的文件,实际上是保存在远程存储服务器上,或者以分布式的方式保 ...

  6. 实操教程丨如何在K8S集群中部署Traefik Ingress Controller

    注:本文使用的Traefik为1.x的版本 在生产环境中,我们常常需要控制来自互联网的外部进入集群中,而这恰巧是Ingress的职责. Ingress的主要目的是将HTTP和HTTPS从集群外部暴露给 ...

  7. Centos7环境下etcd集群的搭建

    Centos7环境下etcd集群的搭建 一.简介 "A highly-available key value store for shared configuration and servi ...

  8. centos7搭建集群必知:centos7已经无iptables,只有firewall

    1.防火墙概述 centos7搭建集群,发现没有iptables,需要安装.防火墙为firewalle CentOS7默认的防火墙不是iptables,而是firewalle. CentOS 7.0默 ...

  9. (4)ElasticSearch在linux环境中搭建集群

    1.概述 一个运行中的Elasticsearch实例称为一个节点(node),而集群是由一个或者多个拥有相同cluster.name配置的节点组成,它们共同承担数据和负载的压力.当有节点加入集群中或者 ...

随机推荐

  1. HTML DOM insertBefore() 方法 问题

    写即时通讯时,每次新增的回话插到原有子节点的前面. 但是出现了以下报错的情况 如图: MDC: var insertedElement = parentElement.insertBefore(new ...

  2. oracle数据库基本命令

    数据库字符集: SQL> select * from nls_database_parameters where parameter='NLS_CHARACTERSET'; PARAMETER ...

  3. VC添加文件到工程出错问题--FileTool.dll

    原文:http://blog.csdn.net/bingdianlanxin/article/details/45112737 在我们的软件开发中,经常需要导入其他文件到我们的工程. 一般,我们会选择 ...

  4. 异步nodejs代码的同步样子写法样例

    异步nodejs代码的同步样子写法样例 js的异步嵌套太深代码将不好看.尤其在用node的时候这种情况会大量出现. 这里用node连接redis,做一个用户注册的简单例子来说明.例如用redis做存储 ...

  5. 微信小程序——组件(一)

    接着之前讲解的基础内容,应该对小程序有了一点了解.想深入了解的话,需要自己实际操作一遍比较好.首先了解官方给的组件,API等这样等顺序来比较好一些.下面贴两张demo图,demo的项目结构是设置的两个 ...

  6. GIT团队合作探讨之三--使用分支

    这篇文章是一个作为对git branch的综合介绍.首先,我们会看看创建branch,这有点像是请求一个新的项目历史.然后,我们看看git checkout是如何能够被用来选择一个branch,最后看 ...

  7. 两步让你的mobile traffic通过fiddler代理传送

    mobile app运行时由于调试网络相关的内容非常不便,所以如果能够让iphone通过桌面主机来跑traffic,那么在pc上就能非常清楚地检查mobile app和后端之间有什么问题了. 幸运的是 ...

  8. 绘制播放音乐时的音波图形的View

    绘制播放音乐时的音波图形的View 这个效果类似于这个哦: 效果如下: 源码: MusicView.h 与 MusicView.m // // MusicView.h // Music // // C ...

  9. 使用DIDatepicker

    使用DIDatepicker https://github.com/noxt/DIDatepicker 效果: #import "DIViewController.h" #impo ...

  10. shell脚本需求

    需求一:写一个脚本 1.设定变量FILE的值为/etc/passwd 2.依次向/etc/passwd中的每个用户问好,并且说出对方的ID是什么 形如:(提示:LINE=`wc -l /etc/pas ...