验证: 1. 获取列出的每个节点上的 NTP 服务器列表: 命令: # getrackinfo -r | grep NTP 示例: admin@node1:~> getrackinfo -r | grep NTP NTPServer = xxx.xxx.xxx.xxx 2. 对于步骤 1 中列出的每个 NTPServer,测试它是否能够同步时间。 命令: # sudo ntpdate -p 2 -d 或 # sudo ntpdate -p 2 -d `getrackinfo -r | grep NTP |grep -oP "(?:[0-9]{1,3}\.){3}[0-9]{1,3}"` 示例:(能够同步时间) admin@node1:~> sudo ntpdate -p 2 -d xxx.xxx.xxx.xxx 22 Feb 13:47:48 ntpdate[110901]: ntpdate 4.2.8p11@1.3728-o Thu Jun 14 09:26:52 UTC 2018 (1) Looking for host and service ntp reversed to host found : transmit( ) receive( ) transmit( ) receive( ) server , port 123 stratum 2, precision -24, leap 00, trust 000 refid [ ], delay 0.02615, dispersion 0.00003 transmitted 2, in filter 2 reference time: e01a7b0d.af9e6616 Fri, Feb 22 2019 13:43:41.686 originate timestamp: e01a7c06.748e0c65 Fri, Feb 22 2019 13:47:50.455 transmit timestamp: e01a7c06.7478b000 Fri, Feb 22 2019 13:47:50.454 filter delay: 0.02635 0.02615 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 filter offset: 0.000043 -0.00002 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 delay 0.02615, dispersion 0.00003 offset -0.000022 22 Feb 13:47:50 ntpdate[110901]: adjust time server offset -0.000022 sec 示例:(无法同步时间时的输出) admin@node1:~> sudo ntpdate -p 2 -d xxx.xxx.xxx.xxx 22 Feb 13:47:48 ntpdate[110901]: ntpdate 4.2.8p11@1.3728-o Thu Jun 14 09:26:52 UTC 2018 (1) Looking for host and service ntp reversed to host found : transmit( ) transmit( ) transmit( ) server , port 123 stratum 2, precision -24, leap 00, trust 000 refid [ ], delay 0.02615, dispersion 0.00003 transmitted 2, in filter 2 reference time: e01a7b0d.af9e6616 Fri, Feb 22 2019 13:43:41.686 originate timestamp: e01a7c06.748e0c65 Fri, Feb 22 2019 13:47:50.455 transmit timestamp: e01a7c06.7478b000 Fri, Feb 22 2019 13:47:50.454 filter delay: 0.02635 0.02615 0.00000 0.00000 0.00000 0.00000 0.00000 0.00000 filter offset: 0.000043 -0.00002 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 delay 0.02615, dispersion 0.00003 offset -0.000022 22 Feb 13:47:50 ntpdate[112232]: no server suitable for synchronization found 3. 在 getrackinfo -r 结果中,将 FQDN 添加到 NTP 部分。 命令: # sudo setrackinfo -a NTPServer < NTP FQDN > 示例: admin@node1:~> sudo setrackinfo -a NTPServer xxx.xxx.xxx.xxx 4. 检查客户是否采用网络分离和静态路由,因为 NTP 是通过基于策略的路由从管理接口发送出来,可能是产生问题的原因。 命令: # getrackinfo -n;getrackinfo -t 示例: admin@node1:~>getrackinfo -n;getrackinfo -t Named networks ============== Node ID Network Ip Address Netmask Gateway VLAN Interface Static route list ================= Node ID Network Netmask Gateway Interface 5. 确认 NTP 服务器是否在其环境中进行侦听,通常有阻止端口的防火墙。 命令: # sudo ntpq -c as 示例:(在下面您将看到一台 NTP 服务器无法访问,另一台可能由于 ACL 而阻止) admin@node1:~> sudo ntpq -c as ind assid status conf reach auth condition last_event cnt =========================================================== 1 56633 8011 yes no none reject mobilize 1 6. 检查 NTP 中是否存在日期漂移。 命令: # viprexec "date +%s" 2>&1 | grep "^15" 示例: admin@node1:~>viprexec "date +%s" 2>&1 | grep "^15" 1554470147 1554470111 1554470096 1554470142 1554470144 1554470109 1554470124 1554470140 admin@ecsnode1:~> 7. 检查 ntpd 服务状态,然后重新启动服务。(即使状态是已启动并正在运行,仍然继续重新启动)。 注意:ntpd.service 是一种不会产生影响的服务。 命令: # viprexec systemctl status ntpd.service | grep Active: 示例: admin@node1:~> viprexec systemctl status ntpd.service | grep Active: Active: active (running) since Tue 2019-08-06 02:49:06 UTC; 1 day 18h ago Active: active (running) since Tue 2019-08-06 02:49:07 UTC; 1 day 18h ago Active: active (running) since Wed 2019-08-07 20:13:27 UTC; 58min ago Active: active (running) since Tue 2019-08-06 02:49:06 UTC; 1 day 18h ago Active: active (running) since Tue 2019-08-06 02:49:07 UTC; 1 day 18h ago Active: active (running) since Tue 2019-08-06 02:49:07 UTC; 1 day 18h ago Active: active (running) since Tue 2019-08-06 02:49:07 UTC; 1 day 18h ago Active: active (running) since Tue 2019-08-06 02:49:07 UTC; 1 day 18h ago 命令: # viprexec systemctl restart ntpd.service 示例: admin@node1:~> viprexec systemctl restart ntpd.service Output from host : 192.168.219.8 Output from host : 192.168.219.7 Output from host : 192.168.219.6 Output from host : 192.168.219.4 Output from host : 192.168.219.3 Output from host : 192.168.219.2 Output from host : 192.168.219.5 Output from host : 192.168.219.1 8. 验证所有节点上的 md5sum ntp.conf 文件。 命令: # viprexec "sudo md5sum /etc/ntp.conf" 示例: admin@node1:~> viprexec "sudo md5sum /etc/ntp.conf" Output from host : 192.168.219.2 741f0abb12ac82a21f150004bd407334 /etc/ntp.conf Output from host : 192.168.219.5 741f0abb12ac82a21f150004bd407334 /etc/ntp.conf Output from host : 192.168.219.4 741f0abb12ac82a21f150004bd407334 /etc/ntp.conf Output from host : 192.168.219.1 7da6eb8009abc18ed1875f1f15ade72a /etc/ntp.conf Output from host : 192.168.219.3 741f0abb12ac82a21f150004bd407334 /etc/ntp.conf Output from host : 192.168.219.8 741f0abb12ac82a21f150004bd407334 /etc/ntp.conf Output from host : 192.168.219.6 741f0abb12ac82a21f150004bd407334 /etc/ntp.conf Output from host : 192.168.219.7 741f0abb12ac82a21f150004bd407334 /etc/ntp.conf 注意:这可能是因为具有公共和管理接口,并且节点全部根据所提供的最后一个配置而配置为不公开。通常在较早版本的 ECS 上,如果 1 个节点有效,而其余节点似乎位于防火墙后面,则 PBR 可能会卡住。 9. 在 getrackinfo -r 结果中将 123 添加到 ns_mgmt,然后检查 NTP 是否已开始传输和接收。 命令: # sudo setrackinfo -a ns_mgmt 123 示例: admin@node1:~>sudo setrackinfo -a ns_mgmt 123 如果错误仍然存在,则将端口 123 放回到公共接口,然后再次检查同步。 命令: # sudo setrackinfo -d ns_mgmt 123 示例: admin@node1:~> sudo setrackinfo -d ns_mgmt 123 执行以上每个步骤之后,检查 NTP 同步的状态。 |