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

相关推荐
feng_you_ying_li1 分钟前
linux之网络层
linux·运维·网络
未来之窗软件服务9 分钟前
Linux 运维日志删除的多种方式—东方仙盟
linux·运维·服务器·仙盟创梦ide·东方仙盟
小雉系统22 分钟前
BcoreOS实战:用一个升级包,让Rocky Linux跑进Debian服务器
linux·运维·服务器·debian
thethefighter23 分钟前
快速预览Word、WPS秒开,支持空格弹窗
linux·word·wps·快速预览·空格弹窗·nhdeepview
用户8351414049491 小时前
把日志和寄存器值喂给AI做故障定位,我的实际问法
linux·ubuntu
Ruiery1 小时前
Linux 6.6内核内存管理深度解析(十七):vmalloc — 内核要“虚拟连续“就够:物理页逐个凑,页表来连
linux·运维·服务器
Escalating_xu1 小时前
【Linux 网络编程】ARP 的具体过程与 ARP 欺骗:一条 IP → MAC 映射,怎样改变数据的去向?
linux·网络·tcp/ip
坚定的共产主义生产设备永不宕机2 小时前
服务器从裸机开始搭建ESXI虚拟机
linux·服务器·网络
刚入门的大一新生2 小时前
Linux-线程封装
linux·运维·服务器
god_cvz2 小时前
实践:Linux环境构建CTB工具(cesium-terrain-builder)
linux·gis·ctb