CentOS之——时间同步出现ntpdate[1788]: the NTP socket is in use, exiting错误

问题:

校准CentOS服务器的时间时报错,如下所示。

[root@binghe ~]# ntpdate ntp.api.bz
2019-11-24 19:22:23 ntpdate[2701]: the NTP socket is in use, exiting

原因:

由于 xntpd 已经绑定到了该 Socket。运行 ntpdate 时,它会首先进行广播,然后侦听端口 123。如果 xntpd 正在运行,而有一个进程已经在侦听该端口了,则会使 ntpdate 无法在上面运行

解决方案:

运行下列命令,即可找出 xntpd 的 PID

ps -ef|grep xntpd

如果没有找出xntpd的PID,则使用命令查看监听123端口的进程,如下所示。

[root@binghe ~]$ lsof -i:123
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
ntpd 15004 ntp 16u IPv4 10940 UDP *:ntp
ntpd 15004 ntp 17u IPv6 10941 UDP *:ntp
ntpd 15004 ntp 18u IPv6 10942 UDP localhost6.localdomain6:ntp
ntpd 15004 ntp 19u IPv4 10943 UDP localhost:ntp
ntpd 15004 ntp 20u IPv4 10944 UDP 220.181.128.182:ntp
ntpd 15004 ntp 21u IPv4 10945 UDP localhost:ntp

接下来杀死进程号为15004的进程

[root@binghe ~]$ kill -9 15004

再次使用lsof命令查看监听123端口的进程

[root@binghe ~]$ lsof -i:123

此时,就没有进程监听123端口了。

此时再次运行 ntpdate ntp.api.bz命令同步时间即可。
其他服务器时间校准地址如下
time.nist.gov
time.nuri.net
asia.pool.ntp.org

发布了1303 篇原创文章 · 获赞 1993 · 访问量 512万+

猜你喜欢

转载自blog.csdn.net/l1028386804/article/details/103227468
今日推荐