zoukankan      html  css  js  c++  java
  • chrony时间服务器

    chrony有着比ntp服务器更好的优势来同步服务,在集群架构中,采用此种服务来同步时间也是最好的方式。

    在集群环境中,一般都是一个服务器,然后上百个客户端来同步服务端的时间,接下来我们看看如何配置。

    1、环境

    时间服务器:172.16.0.51

    允许本网段172.16.0.0/16同步时间

    2、配置服务端,在172.16.0.51上配置

    首先是下载yum install -y chrony

    ]# cd /etc/
    etc]# cp chrony.conf{,.bak}
    etc]# vim chrony.conf
        ...
        #  iburst为固定格式,记住就可以,没有深究。
        server cn.pool.ntp.org iburst
        server tw.pool.ntp.org iburst
        ...
        # 允许指定网络的主机同步时间,不指定就是允许所有,默认不开启。
        allow 172.16.0.51/16
        ...
        # 还有一个默认不开启的选项,意思是,即使服务端没有同步到精确的网络时间,也允许向客户端同步不精确的时间。可以视情况而定。
        # Serve time even if not synchronized to any NTP server.
        #local stratum 10
    ~]# systemctl start chronyd.service
    ~]# systemctl enable chronyd.service

    3、客户端同步

    配置所有的客户端

    etc]# vim chrony.conf
        ...
        server 172.16.0.1 iburst
        ...
    ~]# systemctl start chronyd.service
    ~]# systemctl enable chronyd.service 
    
    进入chronyc客户端交互式模式:
    ~]# chronyc
    
    查看现有的时间服务器
        chronyc> sources
            210 Number of sources = 1
            MS Name/IP address         Stratum Poll Reach LastRx Last sample
            ===============================================================================
            ^* 172.16.0.1               10   6   377    53  -4546ns[-5000ns] +/-  234us
    
    查看时间服务器状态
        chronyc> sourcestats
            210 Number of sources = 1
            Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
            ==============================================================================
            172.16.0.1             10   6   584     +0.001      0.828    +35ns    74us
    
        chronyc>exit

    chrony的配置文件讲解:

      程序环境:

        配置文件:/etc/chrony.conf

        主程序文件:chronyd

        工具程序:chronyc

        unit file:chronyd.service

      配置文件:/etc/chrony.conf

        server:指明时间服务器地址

        allow NETADD/NETMASK

        allow all:允许所有客户端主机

        deny NETADDR/NETMASK

        deny all:拒绝所有客户端

        bindcmdaddress:命令管理接口监听的地址

        local stratum 10:及时自己未能通过网络时间服务器同步到时间,也允许将本地时间作为标准时间授时给其他客户端。

  • 相关阅读:
    Java异常处理和设计
    一次qps测试实践
    Alternate Task UVA
    Just Another Problem UVA
    Lattice Point or Not UVA
    Play with Floor and Ceil UVA
    Exploring Pyramids UVALive
    Cheerleaders UVA
    Triangle Counting UVA
    Square Numbers UVA
  • 原文地址:https://www.cnblogs.com/FengGeBlog/p/10513936.html
Copyright © 2011-2022 走看看