一、集群环境:

  系统: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. Visual Studio Code调试electron主进程

    Visual Studio Code调试electron主进程 作者: jekkay 分类: electron 发布时间: 2017-06-11 14:56  一·概述 此文原出自[水滴石]: htt ...

  2. idea maven 依赖问题

    今天发现,原来idea引用maven依赖的时候,优先依赖的是本地.但是有个问题,如果我删除了一个packet,如果刚刚好本地另外一个项目里面也有这个对于的packet,idea的智能提示 是 将其导入 ...

  3. SQL日期转换

    SQL 语句日期用法及函数 --DAY().MONTH().YEAR()——返回指定日期的天数.月数.年数: select day(cl_s_time) as '日' from class  --返回 ...

  4. 新鲜出炉的Java开发者中心,约起来!

    入门教程.SDK 和工具推荐下载.操作方法指导.API 参考,Java 开发者需要的,这里应有尽有. ▼ 话说现在 Java 开发者在云端进行开发非常火热啊,「云+Java」就好比才子配佳人,真是难以 ...

  5. Linux ->> VMWare Workstation虚拟机里的UBuntu系统安装VMWare-tools

    1) mkdir创建一个临时目录 2)复制gz压缩包到临时目录下 3)解压到当前目录 4)运行.pl文件安装 root@ubuntu:/# root@ubuntu:/# cd /tmp/ root@u ...

  6. GCC the GNU

         GCC简单使用 -v/-v/--version 查看gcc版本号 python@ubuntu:~$ gcc -v -I 指定头文件目录,注意-I和之间没有空格 1 #include<s ...

  7. (转)C++ 自由存储区是否等价于堆?

      “free store” VS “heap” 当我问你C++的内存布局时,你大概会回答: “在C++中,内存区分为5个区,分别是堆.栈.自由存储区.全局/静态存储区.常量存储区”. 如果我接着问你 ...

  8. 转 delete 和 delete []的真正区别

    c++中对new申请的内存的释放方式有delete和delete[两种方式,到底这两者有什么区别呢? 1.我们通常从教科书上看到这样的说明:delete 释放new分配的单个对象指针指向的内存dele ...

  9. 【[USACO13NOV]没有找零No Change】

    其实我是点单调队列的标签进来的,之后看着题就懵逼了 于是就去题解里一翻,发现楼上楼下的题解说的都好有道理, f[j]表示一个再使用一个硬币就能到达i的某个之前状态,b[now]表示使用那个能使状态j变 ...

  10. 2019.1.2 Spring管理事务的方式

    Spring管理事务的方式 1.编码式 1.将核心事务管理器配置到Spring容器 2.配置TransactionTemplate模版 3.将事务模版注入service 4.在Service中调用模版 ...