linuxptp适配记录

前提:物理机网卡加入ptp组播源
检查物理网卡是否支持ptp硬件时钟

1.安装linuxptp包

apt install linuxptp或dpkg -i linuxptp_1.9.2-1ubuntu0.1_amd64.deb

2.安装好了后有两个服务phc2sys.service和ptp4l.service以及pmc这三个工具。其中pmc是一个客户端工具

systemctl status phc2sys.service查看状态可能是dead

ptp4l.service的配置

ptp4l主要实现了普通/边界时钟;软/硬时间戳;延迟请求-响应/对等延迟机制;IEEE 802.3(以太网)/ UDP IPv4 / UDP IPv6网络传输。

bash 复制代码
[Unit]
Description=Precision Time Protocol (PTP) service
Documentation=man:ptp4l
 
[Service]
Type=simple
ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp/ptp4l.conf -i eth0
 
[Install]
WantedBy=multi-user.target

phc2sys.service的配置

phc2sys主要同步两个时钟;当使用硬件时间戳的时候它用来调整系统时钟,软时间戳的时候不需要调整。

bash 复制代码
[Unit]
Description=Synchronize system clock or PTP hardware clock (PHC)
Documentation=man:phc2sys
After=ntpdate.service
Requires=ptp4l.service
After=ptp4l.service
 
[Service]
Type=simple
ExecStart=/usr/sbin/phc2sys -w -s eth0
 
[Install]
WantedBy=multi-user.target

pmc的作用是发送ptp管理消息到ptp节点。

3.这个时候我们需要调整配置,将/lib/systemd/system/phc2sys.service和/lib/systemd/system/ptp4l.service文件中的网卡eth0修改成已经加入了ptp组播源的网卡,systemctl daemon-reload然后重启下两个服务

4.发现ptp4l有如下错误,send sync failed

尝试调整tx_timestamp_timeout为60s、180s还是不行

做的其它尝试还有换其它版本的linuxptp(1.6,1.8,1.9,如果更高的版本就要升级libc的版本了)所以怀疑是driver bug。kern.log、syslog中除了上诉截图中的错误外,没有发现其它错误。

5.尝试在不升级的内核的情况下离线升级glibc(先用虚拟机模拟一下),如果可以则可以尝试linuxptp更高版本来进行适配

尝试失败,提示如下,看来必须要升级内核了

checking installed Linux kernel header files... missing or too old!

configure: error: GNU libc requires kernel header files from

6.升级版本后尝试,还是一样的错误,需要咨询一下厂商

咨询后,反馈那边没发现类似的问题,因为他们用的另外一个同步软件叫做ptpd

7.根据链接https://github.com/renesas/linux-ptp-driver-package,尝试编译相关驱动再做尝试.编译安装ptp相关驱动后,还是又如上的报错

8.最后实在没辙了,想了下,提示driver bug,这个ptp的使用也就两种驱动可能会影响,要么是ptp驱动要么是对应网卡的驱动。ptp驱动尝试了不行,接着尝试升级网卡驱动(驱动下载https://www.intel.com/content/www/us/en/download/14302/intel-network-adapter-driver-for-pcie-intel-10-gigabit-ethernet-network-connections-under-linux.html,内核驱动可以在当前系统中直接编译)

8.1>升级驱动

驱动已更新

8.2>再次验证ptp4l服务已经正常

当要把bond调成单网卡时,需要注意顺序。先加载新驱动,再将bond换成eno1。(如果这个顺序颠倒了会有问题)

tips:

查看网卡设备型号

先用eth -i eno1看bus-info,再lspci -knn -s 01:00.0(01:00.0为bus-info的后半部分)

相关参考文档

https://github.com/raspberrypi/linux/issues/5947

https://www.kernel.org/doc/html/v5.4/driver-api/ptp.html

https://blog.csdn.net/weixin_43129599/article/details/122026991

https://www.openil.org/files/OpenIL_User_Guide_Rev1.2.pdf

https://e2echina.ti.com/support/interface/f/interface-forum/290743/dp83640-linux-ptp

https://community.nxp.com/t5/QorIQ/ptp4l-tx-timestamp-timeout/m-p/892488

https://blog.csdn.net/yaojiawan/article/details/124601694

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/system_administrators_guide/ch-configuring_ptp_using_ptp4l

https://www.elecfans.com/d/1870476.html

关键

https://zshisite.wordpress.com/2017/10/25/sync-your-cloud-with-ptp/

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/chap-kvm_guest_timing_management

相关推荐
chenqianghqu几秒前
ubuntu 22.04环境中安装goland
linux·运维·ubuntu
gwjcloud43 分钟前
Frp内网穿透
linux·运维·服务器
MwEUwQ3Gx1 小时前
常见Linux权限提升笔记
linux·运维·笔记
ken22322 小时前
安装问题@ ubuntu 24.04 :efi 磁盘分区,挂载
linux·运维·ubuntu
数据知道2 小时前
claw-code 源码详细分析:`reference_data` JSON 快照——大型移植里「对照底稿」该怎么治理与演进?
linux·python·ubuntu·json·claude code
kvo7f2JTy2 小时前
吃透Linux/C++系统编程:文件与I/O操作从入门到避坑
java·linux·c++
Deitymoon2 小时前
linux——守护进程
linux
Vect__3 小时前
深刻理解虚拟内存机制
linux
maosheng11463 小时前
Linux的第二次作业
linux·运维·服务器
maosheng11463 小时前
Linux
linux·运维·服务器