首页 > 其他分享 >chrony 同步阿里云

chrony 同步阿里云

时间:2022-12-01 14:26:22浏览次数:34  
标签:同步 07 NTP ntpdate chrony 阿里 2021 time CST

1. 安装chrony

yum install chrony -y
vim /etc/chrony.conf
修改chrony配置文件(替换默认的centos)
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
server ntp3.aliyun.com iburst
server ntp4.aliyun.com iburst

allow 192.168.0.0/16 #允许NTP客户同步ip段  NTP同步时需要配置 

2. 启动chronyd服务,并加入开机自启

[root@localhost ~]# systemctl restart chronyd
[root@localhost ~]# systemctl enable chronyd

3. 验证效果

[root@localhost ~]# timedatectl 
      Local time: Tue 2021-05-18 16:51:25 CST
  Universal time: Tue 2021-05-18 08:51:25 UTC
        RTC time: Tue 2021-05-18 08:51:25
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a

出现双YES就代表同步成功

配置多台可以重复配置chronyd服务也可以配置ntpdate客户端实时同步,多台情况下建议使用ntpdata客户端

4. NTP客户端同步

安装ntpdate命令
yum install ntpdate -y
同步指定NTP服务器时间
[root@es_node1 elasticsearch-7.6.2]# timedatectl 
      Local time: Tue 2021-05-18 02:23:09 CST
  Universal time: Mon 2021-05-17 18:23:09 UTC
        RTC time: Wed 2021-06-02 07:06:48
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a
[root@es_node1 elasticsearch-7.6.2]# ntpdate 192.168.24.46
 2 Jun 15:07:14 ntpdate[27888]: step time server 192.168.24.46 offset 1341819.732624 sec
[root@es_node1 elasticsearch-7.6.2]# timedatectl 
      Local time: Wed 2021-06-02 15:07:32 CST
  Universal time: Wed 2021-06-02 07:07:32 UTC
        RTC time: Wed 2021-06-02 07:07:32
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: n/a
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a
将NTP同步加入计划任务
*/5 * * * * /usr/sbin/ntpdate 192.168.24.46 &>/dev/null 2>&1

    标签:同步,07,NTP,ntpdate,chrony,阿里,2021,time,CST
    From: https://www.cnblogs.com/Lqdream/p/16941274.html

    相关文章