您的位置:首页 > 运维架构 > Linux

[我的Linux技术支持生涯]运行ntpq -p出现“timed out, nothing received”错误

2012-01-31 09:50 495 查看
现象:在客户端和服务器端运行ntpq -p,均出现"timed out, nothing received",同时service ntpd status查看服务器和客户端的服务都是在正常运行。

排查:

1. 运行ntpq命令,进入交互模式,输入timeout 1000000,手动调整timeout时间,再输入peers查询,仍有 上述错误提示;

2. 查看了/etc/ntp.conf,没发现有可疑之处;

3. 在另外的两台机器中按照故障机器的/etc/ntp.conf配置ntp服务,运行ntpq -p能正确并很快得到信息;可见配置文件应该没错;

4. strace ntpq -p 查看输出的信息,发现:

connect(3, {sa_family=AF_INET, sin_port=htons(123), sin_addr=inet_addr("10.44.101.2")}, 16) = 0

而正常的机器中,这里的ip地址为127.0.0.1。

5. 查看/etc/hosts文件,客户端和服务器端的该文件,都没有"127.0.0.1 localhost.localdomain localhost"这行;

6. 在/etc/hosts添加了"127.0.0.1 localhost.localdomain localhost"这行后,运行ntpq -p能正常得到信息了。

结论:

/etc/hosts:

# Do not remove the following line, or various programs

# that require network functionality will fail.

某些人就喜欢改。

PS:使用strace可以省好多功夫。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐