ubuntu同步Centos7的chrony

设置了2台ubuntu18-server同步Centos7的chrony,记录,备查。

Centos7服务端

1. $yum -y install chrony

2. $systemctl start chronyd

3. $systemctl enable chronyd

4. $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.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     //用#号注释原来的源,共4行

server ntp.aliyun.com iburst                //添加新的NTP时间源,iburst参数可以实现立即同步

server ntp.fudan.edu.cn  iburst 

# Allow NTP client access from local network.

allow 20.0.46.0/24     //允许20.0.46.0网段的客户端请求同步本机的时间

5. 开启网络时间同步:timedatectl set-ntp true

6. 查看NTP是否已经启用:$ timedatectl

      Local time: 二 2021-01-05 11:44:03 CST

  Universal time: 二 2021-01-05 03:44:03 UTC

        RTC time: 二 2021-01-05 03:44:03

       Time zone: Asia/Shanghai (CST, +0800)

     NTP enabled: yes      //这里显示yes,代表NTP已启用

NTP synchronized: yes

 RTC in local TZ: no

      DST active: n/a

7. 查看chrony设置开机自启是否成功:

$ sudo systemctl is-enabled chronyd

enabled          //这里已经启用

Ubuntu客户端

1. sudo atp-get install chrony

2. $ cat /etc/chrony/chrony.conf

# Welcome to the chrony configuration file. See chrony.conf(5) for more

# See http://www.pool.ntp.org/join.html for more information.

#pool ntp.ubuntu.com        iburst maxsources 4

#pool 0.ubuntu.pool.ntp.org iburst maxsources 1

#pool 1.ubuntu.pool.ntp.org iburst maxsources 1

#pool 2.ubuntu.pool.ntp.org iburst maxsources 2

server 20.0.46.24 iburst       //向Centos服务器请求同步时间

3. $ sudo service chronyd status

4. $ sudo service chronyd start

5. $ sudo timedatectl set-ntp ture/yes

6. $ sudo timedatectl     //查看开启状态

                      Local time: Tue 2021-01-05 11:55:23 CST

                  Universal time: Tue 2021-01-05 03:55:23 UTC

                        RTC time: Tue 2021-01-05 03:55:23

                       Time zone: Asia/Shanghai (CST, +0800)

       System clock synchronized: yes

systemd-timesyncd.service active: yes

                 RTC in local TZ: no

7. 查看chrony设置开机自启是否成功:

$ sudo systemctl is-enabled chronyd

enabled          //这里已经启用

其它用法:

1.查看 ntp_servers:chronyc sources -v

2.查看 ntp_servers 状态:chronyc sourcestats -v

3.查看 ntp_servers 是否在线:chronyc activity -v

4.查看 ntp 详细信息:chronyc tracking -v

结束。