CentOS 8 x86_64 預設 chronyd 為 NTP 服務,請參考 – https://benjr.tw/102661
測試作業系統 CentOS 7 x86_64 (虛擬機)
Linux 可以透過 NTP ( Network Time Protocol ) 來矯正時間.
[root@localhost ~]# yum -y install ntp
啟動服務.
[root@localhost ~]# systemctl enable ntpd Created symlink from /etc/systemd/system/multi-user.target.wants/ntpd.service to /usr/lib/systemd/system/ntpd.service. [root@localhost ~]# systemctl start ntpd [root@localhost ~]# systemctl status ntpd ● ntpd.service - Network Time Service Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled) Active: active (running) since 二 2021-02-09 23:11:34 CST; 6s ago Process: 2453 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 2455 (ntpd) Tasks: 1 CGroup: /system.slice/ntpd.service └─2455 /usr/sbin/ntpd -u ntp:ntp -g 2月 09 23:11:34 localhost.localdomain ntpd[2455]: Listen normally on 3 ens33 192.168.111.13 UDP 123 2月 09 23:11:34 localhost.localdomain ntpd[2455]: Listen normally on 4 virbr0 192.168.122.1 UDP 123 2月 09 23:11:34 localhost.localdomain ntpd[2455]: Listen normally on 5 lo ::1 UDP 123 2月 09 23:11:34 localhost.localdomain ntpd[2455]: Listen normally on 6 ens33 fe80::cddd:a1cd:13e:ca24 UDP 123 2月 09 23:11:34 localhost.localdomain ntpd[2455]: Listen normally on 7 ens33 fd15:4ba5:5a2b:1008:bb5:c54... 123 2月 09 23:11:34 localhost.localdomain ntpd[2455]: Listening on routing socket on fd #24 for interface updates 2月 09 23:11:34 localhost.localdomain systemd[1]: Started Network Time Service. 2月 09 23:11:36 localhost.localdomain ntpd[2455]: 0.0.0.0 c016 06 restart 2月 09 23:11:36 localhost.localdomain ntpd[2455]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM 2月 09 23:11:36 localhost.localdomain ntpd[2455]: 0.0.0.0 c011 01 freq_not_set Hint: Some lines were ellipsized, use -l to show in full.
架設好 NTP 可以跟其他台 NTP 同步時間,也可以當成別人的 NTP 服務.
如果你的 NTP Server 是在內部無法對外,這樣還能當 NTP Server 嗎? 找了一下資料 https://serverfault.com/questions/806274/how-to-set-up-local-ntp-server-without-internet-access-on-ubuntu 設定如下.
[root@localhost ~]# cat /etc/ntp.conf # Record the rate at which the system clock gains/losses time. driftfile /var/lib/chrony/drift # Serve time even if not synchronized to a time source. server 127.127.1.0 fudge 127.127.1.0 stratum 10
說明:
- driftfile /var/lib/chrony/drift
儲存本地端主機與上層 NTP Server 的誤差 (單位 : PPM – Parts Per Million , 1 PPM (Part Per Million) -> 1 microsecond per second -> 1*60*60/1000 (m) = 3.6ms per hour -> 3.6ms*24= 86.4ms per day) - server 127.127.1.0
使用虛擬(Pseudo) IP address 127.127.1.0 就會使用 local system clock. - fudge 127.127.1.0 stratum 10
NTP是階層架構 (stratum) ,把服務設定在 local 階層架構 (stratum) 10 .
沒有解決問題,試試搜尋本站其他內容