Configuration
如何啟用 NTP 模組 CentOS 7?
我有一台執行 CentOS 7 的伺服器
要安裝 ntp 模組,我按照以下步驟操作:
yum install -y ntp systemctl start ntpd systemctl enable ntpd systemctl status ntpd timedatectl set-timezone America/Mexico_City
服務正在執行,我沒有收到任何錯誤,
systemctl status ntpd ● ntpd.service - Network Time Service Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled) Active: active (running) since Sat 2018-04-07 12:43:43 CDT; 50min left Process: 2652 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 2653 (ntpd) CGroup: /system.slice/ntpd.service └─2653 /usr/sbin/ntpd -u ntp:ntp -g Apr 07 12:43:43 i7box ntpd[2653]: Listen normally on 6 enp3s0 fe80::1cfd:83c7:5a71:977c UDP 123 Apr 07 12:43:43 i7box ntpd[2653]: Listen normally on 7 lo ::1 UDP 123 Apr 07 12:43:43 i7box ntpd[2653]: Listening on routing socket on fd #24 for interface updates Apr 07 12:43:43 i7box systemd[1]: Started Network Time Service
但是當我輸入
timedatectl
timedatectl Local time: Sat 2018-04-07 12:43:45 CDT Universal time: Sat 2018-04-07 17:43:45 UTC RTC time: Sat 2018-04-07 17:43:45 Time zone: America/Mexico_City (CDT, -0500) NTP enabled: no NTP synchronized: yes RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2018-04-01 01:59:59 CST Sun 2018-04-01 03:00:00 CDT Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2018-10-28 01:59:59 CDT Sun 2018-10-28 01:00:00 CST
NTP 顯示為
NTP enabled: no
,我已經打開了 123/udp 埠是否缺少步驟?
如果這確實是問題所在,那麼缺少的步驟
NTP enabled: yes
是:timedatectl set-ntp true
但是,
ntpd
即使沒有:您可以使用 來查看更多詳細資訊
ntpd -q
。它將列出用於同步的伺服器及其狀態。這些伺服器已配置/etc/ntp.conf
,您可以更改預設值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
使用您附近的池伺服器。目前
mx.pool.ntp.org
沒有足夠的伺服器(您可以加入池):該區域伺服器不足,建議您使用北美區域(
north-america.pool.ntp.org
):server 0.north-america.pool.ntp.org server 1.north-america.pool.ntp.org server 2.north-america.pool.ntp.org server 3.north-america.pool.ntp.org