Cento7 ntp客户端提示unsynchronised问题

背景:集群里17是ntp的服务端,18、19、20、21、22是ntp的客户端。详见《Centos7.5下HDP集群搭建(一)》里有说明。

问题:19、20、21、22这4台设备的时间都是从17同步来的,只有18不是从17同步、而是本地时间。

19-22设备提示如下:

[root@dsj3 ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
*dsj1            202.112.29.82    3 u  585 1024  377    1.259    1.392   3.329
 LOCAL(0)        .LOCL.          10 l  23h   64    0    0.000    0.000   0.000

注意星号位置,代表所同步的ntp服务端IP

18设备提示如下:

[root@dsj2 ~]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
dsj1            202.112.29.82    3 u  585 1024  377    1.259    1.392   3.329
 *LOCAL(0)        .LOCL.          10 l  23h   64    0    0.000    0.000   0.000

定位过程:

1.查询日志:/var/log/messages 查看是否有ntp失败或者fail提示。结果没有

2.查询ntp状态:service ntpd status,如下提示,依然没有fail项:

[root@dsj2 etc]# service ntpd status
Redirecting to /bin/systemctl status ntpd.service
● ntpd.service - Network Time Service
   Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2018-08-02 17:37:53 CST; 15s ago
  Process: 6766 ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 6767 (ntpd)
   CGroup: /system.slice/ntpd.service
           └─6767 /usr/sbin/ntpd -u ntp:ntp -g

Aug 02 17:37:53 dsj2.zkhy.com ntpd[6767]: Listen and drop on 1 v6wildcard :: UDP 123
Aug 02 17:37:53 dsj2.zkhy.com ntpd[6767]: Listen normally on 2 lo 127.0.0.1 UDP 123
Aug 02 17:37:53 dsj2.zkhy.com ntpd[6767]: Listen normally on 3 eth0 172.16.172.18 UDP 123
Aug 02 17:37:53 dsj2.zkhy.com ntpd[6767]: Listen normally on 4 lo ::1 UDP 123
Aug 02 17:37:53 dsj2.zkhy.com ntpd[6767]: Listen normally on 5 eth0 fe80::de59:313d:25d6:2f40 UDP 123
Aug 02 17:37:53 dsj2.zkhy.com ntpd[6767]: Listening on routing socket on fd #22 for interface updates
Aug 02 17:37:53 dsj2.zkhy.com ntpd[6767]: 0.0.0.0 c016 06 restart
Aug 02 17:37:53 dsj2.zkhy.com ntpd[6767]: 0.0.0.0 c012 02 freq_set kernel 0.000 PPM
Aug 02 17:37:53 dsj2.zkhy.com ntpd[6767]: 0.0.0.0 c011 01 freq_not_set
Aug 02 17:37:55 dsj2.zkhy.com ntpd[6767]: 0.0.0.0 c514 04 freq_mode

 

3.查询 timedatectl:显示同步功能都是开启的

[root@dsj2~]# timedatectl
      Local time: Thu 2018-08-02 18:06:34 CST
  Universal time: Thu 2018-08-02 10:06:34 UTC
        RTC time: Thu 2018-08-02 10:06:36
       Time zone: Asia/Shanghai (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
[root@dsj1 ~]# 

4.尝试与17的网络数据通信 ntpdate -u 172.16.172.17

 

5.查询ntpstat:显示是同步的本地服务。与其他正常设备对比发现不理解stratum后面数字的含义。

[root@dsj2 log]#  ntpstat
synchronised to local server  at stratum 11
   time correct to within 127 ms
   polling server every 64 s

正常设备:

[root@dsj2 log]#  ntpstat
synchronised to NTP server (172.16.172.17) at stratum 4 
   time correct to within 127 ms
   polling server every 64 s

 

5.查询stratum的含义:

层次(strata)

层的概念

这些问题主要涉及到NTP的层(stratum)的概念,顶层是1,值为0时表示层数不明,层的值是累加的,比如NTP授时方向是A-〉B-〉C,假设A的stratum值是3,那么B从A获取到时间,B的stratum置为4,C从B获取到时间,C的值被置为5。一般只有整个NTP系统最顶层的服务器stratum才设为1。

NTP同步的方向是从stratum值较小的节点向较大的节点传播,如果某个NTP客户端接收到stratum比自己还要大,那么NTP客户端认为自己的时间比接受到的时间更为精确,不会进行时间的更新。

stratum根据上层server的层次而设定(+1)。

对于提供network time service provider的主机来说,stratum的设定要尽可能准确。

而作为局域网的time service provider,通常将stratum设置为10 (Stratum 10 is conventional for unsynchronized local clocks; it is high enough that nobody is likely to mistake it for a desirable clock to synchronize with.),如下:

server  127.127.1.0     # local clock
fudge   127.127.1.0     stratum 10
#stratum设置为其它值也是可以的,其范围为0~15

6.猜想是否是17到straum的时间较长超过11,所以本地的优先级反而高于17,所以将本地 statum尝试修改为最大值15。

重启服务后,发现问题貌似解决了。

这是今天这个问题的定位过程,后续若有问题,会再次更新。

 

  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
为在CentOS 7上安装pip,你可以按照以下步骤进行操作: 1. 首先,确保你已经安装了Python 2.7版本。你可以通过运行以下命令来验证Python的版本:`python --version`。如果你发现你的系统中没有安装Python,你可以使用以下命令来安装:`sudo yum install python`。 2. 接下来,你需要下载setuptools和pip的tar包。你可以前往清华镜像源下载这些包。你可以使用以下命令在终端中下载这些包:`wget https://pypi.tuna.tsinghua.edu.***你需要解压这些tar包。你可以使用以下命令进行解压:`tar -zxvf 包名.tar.gz`。请确保替换掉"包名"为你下载的tar包的实际文件名。 4. 解压后,你需要进入解压后的目录。你可以使用以下命令进入目录:`cd 包名`。请确保替换掉"包名"为你解压后的目录名。 5. 进入目录后,你可以使用以下命令来安装setuptools:`python setup.py install`。 6. 安装完成后,你可以继续安装pip。你可以使用以下命令来安装:`python get-pip.py`。请确保你已经将get-pip.py文件放在解压后的目录中。 7. 安装完成后,你可以验证pip的安装是否成功。你可以使用以下命令来检查pip的版本:`pip --version`。 8. 最后,你可以将pip的源切换到国内镜像源,以提高下载速度。你可以使用以下命令来切换源:`pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple`。 通过按照上述步骤,你应该能够在CentOS 7上成功安装pip并切换到国内镜像源。请注意,这些步骤是按照你在问题中提到的引用的方式给出的解决方案。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [centos7 离线安装python的pip命令(附切换镜像源)](https://blog.csdn.net/m0_51395584/article/details/125660260)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* [cento7安装kvm并通过qemu命令行安装其他虚拟机(红帽)](https://download.csdn.net/download/weixin_38654944/14054867)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值