Linux上执行ntpdate cn.pool.ntp.org命令实现同步操作系统时间时出现的问题,
执行命令后,过段时间查看还是不准,手动执行ntpdate命令时还报错了~
报错信息如下:
[root@hadoop101 ~]# ntpdate time.nuri.net
27 May 13:31:21 ntpdate[37725]: the NTP socket is in use, exiting
分析:可能是NTP服务被占用导致的
解决:停止NTP服务,执行ntpdate同步命令 => 同步成功
具体步骤如下:
- 停止ntp服务
[root@hadoop101 ~]# service ntpd stop
关闭 ntpd: [确定]
- 关闭ntp服务的开机自启:
[root@hadoop101 ~]# chkconfig ntpd off
- 再次执行ntpdate同步命令(同步完成!!!)
注:一定要在root账户下执行该命令
[root@hadoop101 ~]# /usr/sbin/ntpdate cn.pool.ntp.org
28 May 19:35:58 ntpdate[37762]: step time server 203.107.6.88 offset 108152.003980 sec
- 查看时间
[root@hadoop101 ~]# date
2019年 05月 28日 星期二 19:36:04 CST
- 最后启动前边关闭的服务
[root@hadoop101 ~]# chkconfig ntpd on
[root@hadoop101 ~]# service ntpd start
正在启动 ntpd: [确定]
以下是centOS7版本命令:
-
NTP服务开启and关闭:
systemctl start ntpd.service
systemctl stop ntpd.service -
开启and关闭ntp服务的开机自启
systemctl enable ntpd.service
systemctl disable ntpd.service