openEuler 22.03 (LTS-SP1)服务器用ntpd同步GPS时间服务器的案例

本文记录了openEuler 22.03 (LTS-SP1)的二级时间服务器用chronyd不能自动同步GPS时间服务器,改用ntpd同步GPS时间服务器成功的案例

一、环境简述

1、本环境中有两台GPS一级时间服务器,IP如下:

192.168.188.66

192.168.188.74

2、有一台openeuler系统的服务器拟作为网络中的二级时间服务器对全网进行授时

系统版本:

[root@localhost ~]# cat /etc/os-release 
NAME="openEuler"
VERSION="22.03 (LTS-SP1)"
ID="openEuler"
VERSION_ID="22.03"
PRETTY_NAME="openEuler 22.03 (LTS-SP1)"
ANSI_COLOR="0;31"

 IP地址:192.168.168.33

二、问题现象

1、使用chronyd进行时间服务器同步设置

配置如下:

[root@localhost ~]# egrep -v "^#|^$" /etc/chrony.conf
server 192.168.188.66 iburst
server 192.168.188.74 iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
allow 192.0.0.0/8
local stratum 10
keyfile /etc/chrony.keys
logdir /var/log/chrony
log measurements statistics tracking
2、启动服务
[root@localhost ~]# systemctl start chronyd
[root@localhost ~]# systemctl status chronyd
● chronyd.service - NTP client/server
     Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2024-06-21 20:37:38 CST; 5s ago
       Docs: man:chronyd(8)
             man:chrony.conf(5)
    Process: 392366 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
   Main PID: 392368 (chronyd)
      Tasks: 1 (limit: 2469658)
     Memory: 360.0K
     CGroup: /system.slice/chronyd.service
             └─ 392368 /usr/sbin/chronyd

Jun 21 20:37:38 irmsogg1733 systemd[1]: Starting NTP client/server...
Jun 21 20:37:38 irmsogg1733 chronyd[392368]: chronyd version 4.1 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASY>
Jun 21 20:37:38 irmsogg1733 chronyd[392368]: Initial frequency -46.668 ppm
Jun 21 20:37:38 irmsogg1733 systemd[1]: Started NTP client/server.

服务正常启动

3、检查服务器同步情况
[root@localhost ~]# chronyc sourcestats -v 
                             .- Number of sample points in measurement set.
                            /    .- Number of residual runs with same sign.
                           |    /    .- Length of measurement set (time).
                           |   |    /      .- Est. clock freq error (ppm).
                           |   |   |      /           .- Est. error in freq.
                           |   |   |     |           /         .- Est. offset.
                           |   |   |     |          |          |   On the -.
                           |   |   |     |          |          |   samples. \
                           |   |   |     |          |          |             |
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
==============================================================================
192.168.188.66               0   0     0     +0.000   2000.000     +0ns  4000ms
192.168.188.74               0   0     0     +0.000   2000.000     +0ns  4000ms
[root@localhost ~]# chronyc sources -v     

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current best, '+' = combined, '-' = not combined,
| /             'x' = may be in error, '~' = too variable, '?' = unusable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^? 192.168.188.66                 0   8     0     -     +0ns[   +0ns] +/-    0ns
^? 192.168.188.74                 0   8     0     -     +0ns[   +0ns] +/-    0ns

经长时间观察,服务器前面始终为?,发现无法完成自动同步将服务器状态转为“*”或“-”。

4、检查一级服务器授时能力
[root@localhost ~]# chronyc activity -v
200 OK
2 sources online
0 sources offline
0 sources doing burst (return to online)
0 sources doing burst (return to offline)
0 sources with unknown address
[root@localhost ~]# chronyc tracking -v
Reference ID    : 7F7F0101 ()
Stratum         : 10
Ref time (UTC)  : Fri Jun 21 11:31:11 2024
System time     : 0.000000004 seconds slow of NTP time
Last offset     : +0.000000000 seconds
RMS offset      : 0.000000000 seconds
Frequency       : 44.979 ppm slow
Residual freq   : +0.000 ppm
Skew            : 0.000 ppm
Root delay      : 0.000000000 seconds
Root dispersion : 0.000000000 seconds
Update interval : 0.0 seconds
Leap status     : Normal

 可以看到两个时间服务器源是在线的,但tracking信息不正常

5、手动同步时间测试
[root@localhost ~]# ntpdate 192.168.188.66    
21 Jun 19:19:21 ntpdate[391367]: adjust time server 192.168.188.66 offset +0.017640 sec
[root@localhost ~]# ntpdate 192.168.188.74
21 Jun 19:19:34 ntpdate[391368]: adjust time server 192.168.188.74 offset +0.012333 sec
[root@localhost ~]# chronyc -a makestep
200 OK

 手动测试一级时间服务器时间同步正常,授时端口也正常,看来chronyd与该GPS时间服务器同步存在什么问题。

三、问题处理

1、卸载chronyd

考虑到一级GPS时间服务器又能正常授时,chronyd无法完成与一级GPS时间服务器的自动同步,于是卸载chronyd,改用ntpd进行尝试(ntpd和chronyd都能启动ntp时间服务器,是有冲突的,最好只保留一个)。

[root@localhost ~]# yum remove chrony        
Dependencies resolved.
=======================================================================================================================================
 Package                     Architecture             Version                             Repository                              Size
=======================================================================================================================================
Removing:
 chrony                      x86_64                   4.1-3.oe2203sp1                     @openEuler2203SP1LTS                   435 k
Removing unused dependencies:
 libedit                     x86_64                   3.1-29.oe2203sp1                    @openEuler2203SP1LTS                   232 k
 timedatex                   x86_64                   0.6-3.oe2203sp1                     @openEuler2203SP1LTS                    52 k

Transaction Summary
=======================================================================================================================================
Remove  3 Packages

Freed space: 718 k
Is this ok [y/N]: y
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                               1/1 
  Running scriptlet: chrony-4.1-3.oe2203sp1.x86_64                                                                                 1/1 
  Running scriptlet: chrony-4.1-3.oe2203sp1.x86_64                                                                                 1/3 
Removed /etc/systemd/system/multi-user.target.wants/chronyd.service.

  Erasing          : chrony-4.1-3.oe2203sp1.x86_64                                                                                 1/3 
warning: /etc/chrony.conf saved as /etc/chrony.conf.rpmsave

  Running scriptlet: chrony-4.1-3.oe2203sp1.x86_64                                                                                 1/3 
  Erasing          : libedit-3.1-29.oe2203sp1.x86_64                                                                               2/3 
  Running scriptlet: timedatex-0.6-3.oe2203sp1.x86_64                                                                              3/3 
Unit /etc/systemd/system/timedatex.service is masked, ignoring.

  Erasing          : timedatex-0.6-3.oe2203sp1.x86_64                                                                              3/3 
  Running scriptlet: timedatex-0.6-3.oe2203sp1.x86_64                                                                              3/3 
  Verifying        : chrony-4.1-3.oe2203sp1.x86_64                                                                                 1/3 
  Verifying        : libedit-3.1-29.oe2203sp1.x86_64                                                                               2/3 
  Verifying        : timedatex-0.6-3.oe2203sp1.x86_64                                                                              3/3 

Removed:
  chrony-4.1-3.oe2203sp1.x86_64              libedit-3.1-29.oe2203sp1.x86_64              timedatex-0.6-3.oe2203sp1.x86_64             

Complete!
2、安装ntpd
[root@localhost ~] # yum install ntp
Last metadata expiration check: 0:51:16 ago on Fri 21 Jun 2024 07:47:25 PM CST.
Dependencies resolved.
=======================================================================================================================================
 Package                    Architecture            Version                                 Repository                            Size
=======================================================================================================================================
Installing:
 ntp                        x86_64                  4.2.8p15-7.oe2203sp1                    openEuler2203SP1LTS                  619 k
Installing dependencies:
 autogen                    x86_64                  5.18.16-3.oe2203sp1                     openEuler2203SP1LTS                  469 k
 libedit                    x86_64                  3.1-29.oe2203sp1                        openEuler2203SP1LTS                   92 k
 ntp-help                   noarch                  4.2.8p15-7.oe2203sp1                    openEuler2203SP1LTS                  1.3 M
Installing weak dependencies:
 ntpstat                    noarch                  0.6-4.oe2203sp1                         openEuler2203SP1LTS                   11 k
 timedatex                  x86_64                  0.6-3.oe2203sp1                         openEuler2203SP1LTS                   29 k

Transaction Summary
=======================================================================================================================================
Install  6 Packages

Total download size: 2.4 M
Installed size: 5.3 M
Is this ok [y/N]: y
Downloading Packages:
(1/6): libedit-3.1-29.oe2203sp1.x86_64.rpm                                                              19 MB/s |  92 kB     00:00    
(2/6): autogen-5.18.16-3.oe2203sp1.x86_64.rpm                                                           29 MB/s | 469 kB     00:00    
(3/6): ntpstat-0.6-4.oe2203sp1.noarch.rpm                                                              9.3 MB/s |  11 kB     00:00    
(4/6): ntp-4.2.8p15-7.oe2203sp1.x86_64.rpm                                                              24 MB/s | 619 kB     00:00    
(5/6): timedatex-0.6-3.oe2203sp1.x86_64.rpm                                                            3.7 MB/s |  29 kB     00:00    
(6/6): ntp-help-4.2.8p15-7.oe2203sp1.noarch.rpm                                                         42 MB/s | 1.3 MB     00:00    
---------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                   63 MB/s | 2.4 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                               1/1 
  Running scriptlet: timedatex-0.6-3.oe2203sp1.x86_64                                                                              1/6 
  Installing       : timedatex-0.6-3.oe2203sp1.x86_64                                                                              1/6 
  Running scriptlet: timedatex-0.6-3.oe2203sp1.x86_64                                                                              1/6 
Unit /etc/systemd/system/timedatex.service is masked, ignoring.

  Installing       : ntp-help-4.2.8p15-7.oe2203sp1.noarch                                                                          2/6 
  Installing       : libedit-3.1-29.oe2203sp1.x86_64                                                                               3/6 
  Installing       : autogen-5.18.16-3.oe2203sp1.x86_64                                                                            4/6 
  Installing       : ntpstat-0.6-4.oe2203sp1.noarch                                                                                5/6 
  Running scriptlet: ntp-4.2.8p15-7.oe2203sp1.x86_64                                                                               6/6 
  Installing       : ntp-4.2.8p15-7.oe2203sp1.x86_64                                                                               6/6 
  Running scriptlet: ntp-4.2.8p15-7.oe2203sp1.x86_64                                                                               6/6 
  Verifying        : autogen-5.18.16-3.oe2203sp1.x86_64                                                                            1/6 
  Verifying        : libedit-3.1-29.oe2203sp1.x86_64                                                                               2/6 
  Verifying        : ntp-4.2.8p15-7.oe2203sp1.x86_64                                                                               3/6 
  Verifying        : ntp-help-4.2.8p15-7.oe2203sp1.noarch                                                                          4/6 
  Verifying        : ntpstat-0.6-4.oe2203sp1.noarch                                                                                5/6 
  Verifying        : timedatex-0.6-3.oe2203sp1.x86_64                                                                              6/6 

Installed:
  autogen-5.18.16-3.oe2203sp1.x86_64             libedit-3.1-29.oe2203sp1.x86_64           ntp-4.2.8p15-7.oe2203sp1.x86_64           
  ntp-help-4.2.8p15-7.oe2203sp1.noarch           ntpstat-0.6-4.oe2203sp1.noarch            timedatex-0.6-3.oe2203sp1.x86_64          

Complete!
3、配置ntpd
[root@localhost chrony]# egrep -v "^#|^$" /etc/ntp.conf   
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noepeer noquery
restrict source nomodify notrap noepeer noquery
restrict 127.0.0.1 
restrict ::1
server 192.168.188.66 iburst
server 192.168.188.74 iburst
tos maxclock 5
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
 4、启动ntpd
[root@localhost chrony]# systemctl start ntpd
5、查看服务状态
[root@localhost chrony]# systemctl status ntpd
● ntpd.service - Network Time Service
     Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled; vendor preset: disabled)
     Active: active (running) since Fri 2024-06-21 20:40:16 CST; 2min 38s ago
   Main PID: 392489 (ntpd)
      Tasks: 2 (limit: 2469658)
     Memory: 1.6M
     CGroup: /system.slice/ntpd.service
             └─ 392489 /usr/sbin/ntpd -u ntp:ntp -g

Jun 21 20:40:16 localhost ntpd[392489]: Listen and drop on 1 v4wildcard 0.0.0.0:123
Jun 21 20:40:16 localhost ntpd[392489]: Listen normally on 2 lo 127.0.0.1:123
Jun 21 20:40:16 localhost ntpd[392489]: Listen normally on 3 bond0 192.168.168.33:123
Jun 21 20:40:16 localhost ntpd[392489]: Listen normally on 4 lo [::1]:123
Jun 21 20:40:16 localhost ntpd[392489]: Listening on routing socket on fd #23 for interface updates
Jun 21 20:40:16 localhost ntpd[392489]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized
Jun 21 20:40:16 localhost ntpd[392489]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized
Jun 21 20:40:16 localhost systemd[1]: Started Network Time Service.
 6、检查时间同步情况
[root@localhost chrony]# ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+192.168.188.66   .GPS.            1 u   11   64   77    1.705  +15.730  12.199
*192.168.188.74   .GPS.            1 u    8   64   77    1.670  +16.038  12.284

 发现ntpd能够正常跟踪一级GPS时间服务器,相关数据显示正常。

7、使能ntpd让其开机启动
[root@localhost chrony]# systemctl enable ntpd
Created symlink /etc/systemd/system/multi-user.target.wants/ntpd.service → /usr/lib/systemd/system/ntpd.service.
8、通过网内其它主机进行时间同步测试

其它主机chronyd将时间服务器设置为二级服务器192.168.168.33进行同步测试

[root@localhost2 ~]# chronyc sources -v

  .-- Source mode  '^' = server, '=' = peer, '#' = local clock.
 / .- Source state '*' = current best, '+' = combined, '-' = not combined,
| /             'x' = may be in error, '~' = too variable, '?' = unusable.
||                                                 .- xxxx [ yyyy ] +/- zzzz
||      Reachability register (octal) -.           |  xxxx = adjusted offset,
||      Log2(Polling interval) --.      |          |  yyyy = measured offset,
||                                \     |          |  zzzz = estimated error.
||                                 |    |           \
MS Name/IP address         Stratum Poll Reach LastRx Last sample               
===============================================================================
^* 192.168.168.33                  2   6   377    17  -4658us[-7129us] +/-   11ms

可以看到,能正确获取到时间,且显示二级服务器192.168.168.33处于第二层。

9、检查时间获取情况
[root@localhost2 ~]#  chronyc tracking -v
Reference ID    : 0AE31121 (192.168.168.33)
Stratum         : 3
Ref time (UTC)  : Fri Jun 21 14:13:29 2024
System time     : 0.000004623 seconds fast of NTP time
Last offset     : +0.000003086 seconds
RMS offset      : 0.000103144 seconds
Frequency       : 16.338 ppm slow
Residual freq   : +0.001 ppm
Skew            : 0.072 ppm
Root delay      : 0.001930163 seconds
Root dispersion : 0.007009792 seconds
Update interval : 64.7 seconds
Leap status     : Normal
10、用时间同步检查工具检查

可以看到 二级服务器192.168.168.33是从一级时间服务器192.168.188.74获取的时间,与“ntpq -p”检查结果一致,确认二级时间服务器自动同步GPS时间服务器并进行分发的配置ok,运行完成正常。

附:本文中相关配置详解见《ntpd和chronyd时间服务器配置样例及详解》

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/731158.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

交易中的特殊存在

在交易的广袤天空中,有一群特殊的存在——他们,是Eagle Trader。 他们以鹰眼般的洞察力,捕捉市场的微妙变化,每一次决策都如同猎食者般精准;他们运用策略,如同雄鹰在风中翱翔,利用风向&#xf…

3dsMax怎样让渲染效果更逼真出色?三套低中高参数设置

渲染是将精心构建的3D模型转化为逼真图像的关键步骤。但要获得令人惊叹的渲染效果,仅仅依赖默认设置是不够的。 实现在追求极致画面效果的同时,兼顾渲染速度和时间还需要进行一些调节设置,如何让渲染效果更加逼真? 一、全局照明与…

AI播客下载:The Gradient-AI前沿见解

The Gradient 是一个致力于让更多人轻松了解人工智能,并促进人工智能社区内讨论的组织。我们目前开展的项目包括 The Gradient 杂志、The Gradient 播客、The Update 通讯以及 Mastodon 实例 Sigmoid Social。 我们是一个由来自不同机构和公司的研究生、研究人员及…

【Ubuntu下 qmqtt6.2编译及使用】

这里写自定义目录标题 一、编译二、使用 背景:最近用QT编写简单的HMI软件,mqtt通信,记录下编译过程,供参考。 一、编译 QT6.5.3 qmqtt6.2(源码地址:https://github.com/qt/qtmqtt/tree/6.5.3) …

E84-晶圆载具交接自动化

E84是一种通讯协议,它的核心作用在于为通讯传感器/设备的开发提供基础架构。 E84协议详细阐述了晶圆载具(如FOUP/POD等)在工厂自动化物料搬运系统(AMHS)与机台装载端口(LP)之间,如何…

c++ 里构造函数的形参与数据成员的同名问题

如题,这时,或许在 java 里,会报语法错误。但在 c vs2019 开了 c20语法规范。这不再是错误。这样的好处是解决了咱们的起变量名的麻烦:重名现在已不是错误,编译器可以解决了。测试如下: 我们看看 c 编译器是…

Android studio中如何下载sdk

打开 file -> settings 这个页面, 在要下载的 SDK 前面勾上, 然后点 apply 在 platforms 中就可以看到下载好的 SDK: 如果sdk下载失败是不是硬盘没有权限,管理员权限从启android studio运行下载sdk

鸿蒙开发:【组件启动规则(FA模型)】

组件启动规则(FA模型) 启动组件是指一切启动或连接应用组件的行为: 启动PageAbility、ServiceAbility,如使用startAbility()等相关接口。连接ServiceAbility、DataAbility,如使用connectAbility()、acquireDataAbili…

程序猿大战Python——面向对象——对象属性

什么是属性 目标:了解什么是属性? 在现实生活中,属性就表示固有特征,比如:一辆小轿车的属性有轮胎数、颜色、品牌等。 仔细观察后会发现,属性可以简单理解为与生俱来的特征,比如一个人的姓名、年…

ArcGIS消除碎图斑

​ 点击下方全系列课程学习 点击学习—>ArcGIS全系列实战视频教程——9个单一课程组合系列直播回放 点击学习——>遥感影像综合处理4大遥感软件ArcGISENVIErdaseCognition 这次是上次 我们经常在相交、标识、更新等操作后或者是栅格转矢量可能存在很多的细碎图斑&#…

RGB彩色模型理解与编程实例

一、引言 RGB彩色模型中的R、G和B为三原色,通常R、G和B分别用8位表示,因此24位的RGB 真彩色图像能表示16777216种颜色。在如右图所示RGB彩色立方体可知,任意两种原色混合可以合成一种新的颜色。红(1,0,0&a…

【算法训练记录——Day32】

Day32——贪心算法Ⅱ 1.leetcode122买卖股票的最佳时机II2.leetcode55跳跃游戏3.leetcode45跳跃游戏II4.eetcode1005K次取反后最大化的数组和 目标: leetcode122买卖股票的最佳时机IIleetcode55跳跃游戏leetcode45跳跃游戏IIleetcode1005K次取反后最大化的数组和 1…

AI音乐:创新引擎还是创意终结者?

✨作者主页: Mr.Zwq✔️个人简介:一个正在努力学技术的Python领域创作者,擅长爬虫,逆向,全栈方向,专注基础和实战分享,欢迎咨询! 您的点赞、关注、收藏、评论,是对我最大…

玄机平台流量特征分析-蚁剑流量分析

前言 蚁剑的流量特征 (1)每个请求体都存在ini_set(“display_errors”, “0”);set_time_limit(0)开头。并且后面存在base64等字符 (2)响应包的结果返回格式为: 随机数 响应内容 随机数 看一下题目要求 步骤1.1 这里要求我们找到木马的连接密码,…

aws的eks(k8s)ingress+elb部署实践

eks(k8s)版本1.29 ingress 版本1.10.0 负载均衡elb 1. 创建Ingress-Nginx服务 部署项目地址【点我跳转】推荐自定义部署 可绑定acm证书什么的自己属性 这里就是aws上面Certificate Manager产品上面创建证书 导入 创建都行 对应集群版本推荐阵列GitH…

springboot宠物领养系统-计算机毕业设计源码07863

摘 要 21世纪的今天,随着社会的不断发展与进步,人们对于信息科学化的认识,已由低层次向高层次发展,由原来的感性认识向理性认识提高,管理工作的重要性已逐渐被人们所认识,科学化的管理,使信息存…

MySQL之复制(九)

复制 复制管理和维护 确定主备是否一致 在理想情况下,备库和主库的数据应该是完全一样的。但事实上备库可能发生错误并导致数据不一致。即使没有明显的错误,备库同样可能因为MySQL自身的特性导致数据不一致,例如MySQL的Bug、网络中断、服务…

Spring Cache使用

一、概述 Spring Cache 并不是一种Cache实现的技术,Spring Cache是一种缓存实现的通用技术,是基于 Spring提供的Cache框架,让开发者更容易将缓存的实现快速的键入自己的项目中,简化了代码中对缓存的操作。 Spring从3.1开始定义…

我理解的文本表示模型

词袋模型与N-grams模型 1 词袋模型 (Bag of Words)1.1 one-hot 取值 (Binary)1.2 Term Frequency 取值 (TF)普通频数 r a w t f raw_{tf} rawtf​频率范数归一化对数频数 1.3 Inverse document frequency (IDF)1.4 TF-IDF scores 取值 N-Gram 最简单的文本建模场景&#xff1a…

openh264 宏块级码率控制源码分析

openh264 宏块级码率控制函数关系 宏块级核心函数分析 WelsRcMbInitGom函数 功能:openh264 码率控制框架中宏块级码率控制函数,根据是否启用GOM QP来决定如何设置宏块的QP值,以控制编码的质量和比特率。原理过程: 函数参数&…