Linux教程

linux ntpd时间同步

本文主要是介绍linux ntpd时间同步,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

主:

# yum install -y ntp ntpdate
# cat /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
server ntp1.aliyun.com iburst
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
# systemctl start ntpd
# ntpq -p
# timedatectl

从:

# yum install -y ntp ntpdate
# cat /etc/ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery
restrict 127.0.0.1
restrict ::1
server 主IP iburst
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor
# systemctl start ntpd
# ntpq -p
# timedatectl

同步没成功:

# timedatectl status
      Local time: Tue 2022-04-26 21:46:24 CST
  Universal time: Tue 2022-04-26 13:46:24 UTC
        RTC time: Tue 2022-04-26 13:45:13
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

解决:

# systemctl stop ntpd
# ntpd -gq
ntpd: time slew +0.000041s
# systemctl start ntpd
等待一会儿后,NTP synchronized恢复成yes:
# timedatectl

 

这篇关于linux ntpd时间同步的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!