19.6. 配置 PTP 设备
PTP Operator 将 NodePtpDevice.ptp.openshift.io 自定义资源定义(CRD)添加到 OpenShift Container Platform。
安装后,PTP Operator 会在每个节点中搜索具有 PTP 功能的网络设备。它为提供兼容 PTP 的网络设备的每个节点创建并更新 NodePtpDevice 自定义资源(CR)对象。
19.6.1. 在集群中发现具有 PTP 功能网络设备
要返回集群中具有 PTP 功能网络设备的完整列表,请运行以下命令:
$ oc get NodePtpDevice -n openshift-ptp -o yaml
输出示例
apiVersion: v1 items: - apiVersion: ptp.openshift.io/v1 kind: NodePtpDevice metadata: creationTimestamp: "2022-01-27T15:16:28Z" generation: 1 name: dev-worker-0 1 namespace: openshift-ptp resourceVersion: "6538103" uid: d42fc9ad-bcbf-4590-b6d8-b676c642781a spec: {} status: devices: 2 - name: eno1 - name: eno2 - name: eno3 - name: eno4 - name: enp5s0f0 - name: enp5s0f1 ...
19.6.2. 将 linuxptp 服务配置为 grandmaster 时钟
您可以通过创建一个配置主机 NIC 的 PtpConfig 自定义资源 (CR) 将 linuxptp 服务 (ptp4l、phc2sys、ts2phc) 配置为 grandmaster 时钟。
ts2phc 工具允许您将系统时钟与 PTP grandmaster 时钟同步,以便节点可以将精度时钟信号流传输到下游 PTP 普通时钟和边界时钟。
使用 PtpConfig CR 示例,将 linuxptp 服务配置为特定硬件和环境的 grandmaster 时钟。这个示例 CR 没有配置 PTP 快速事件。要配置 PTP 快速事件,请为 ptp4lOpts、ptp4lConf 和 ptpClockThreshold 设置适当的值。ptpClockThreshold 仅在启用事件时使用。如需更多信息,请参阅"配置 PTP 快速事件通知发布程序"。
先决条件
- 在裸机集群主机上安装 Intel Westport Channel 网络接口。
-
安装 OpenShift CLI (
oc) 。 -
以具有
cluster-admin特权的用户身份登录。 - 安装 PTP Operator。
流程
创建
PtpConfig资源。例如:将以下 YAML 保存到
grandmaster-clock-ptp-config.yaml文件中:推荐的 PTP grandmaster 时钟配置
apiVersion: ptp.openshift.io/v1 kind: PtpConfig metadata: name: grandmaster namespace: openshift-ptp spec: profile: - name: "grandmaster" ptp4lOpts: "-2 --summary_interval -4" phc2sysOpts: -r -u 0 -m -O -37 -N 8 -R 16 -s ens2f1 -n 24 ptpSchedulingPolicy: SCHED_FIFO ptpSchedulingPriority: 10 plugins: e810: enableDefaultConfig: true ts2phcOpts: " " ts2phcConf: | [nmea] ts2phc.master 1 [global] use_syslog 0 verbose 1 logging_level 7 ts2phc.pulsewidth 100000000 #GNSS module - ls /dev/gnss* -al ts2phc.nmea_serialport /dev/gnss0 leapfile /usr/share/zoneinfo/leap-seconds.list [ens2f1] ts2phc.extts_polarity rising ts2phc.extts_correction 0 ptp4lConf: | [ens2f1] masterOnly 1 [ens2f2] masterOnly 1 [ens2f3] masterOnly 1 [ens2f4] masterOnly 1 [global] # # Default Data Set # twoStepFlag 1 priority1 128 priority2 128 domainNumber 24 #utc_offset 37 clockClass 6 clockAccuracy 0x27 offsetScaledLogVariance 0xFFFF free_running 0 freq_est_interval 1 dscp_event 0 dscp_general 0 dataset_comparison G.8275.x G.8275.defaultDS.localPriority 128 # # Port Data Set # logAnnounceInterval -3 logSyncInterval -4 logMinDelayReqInterval -4 logMinPdelayReqInterval 0 announceReceiptTimeout 3 syncReceiptTimeout 0 delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 20000000 masterOnly 0 G.8275.portDS.localPriority 128 # # Run time options # assume_two_step 0 logging_level 6 path_trace_enabled 0 follow_up_info 0 hybrid_e2e 0 inhibit_multicast_service 0 net_sync_monitor 0 tc_spanning_tree 0 tx_timestamp_timeout 50 unicast_listen 0 unicast_master_table 0 unicast_req_duration 3600 use_syslog 1 verbose 0 summary_interval -4 kernel_leap 1 check_fup_sync 0 # # Servo Options # pi_proportional_const 0.0 pi_integral_const 0.0 pi_proportional_scale 0.0 pi_proportional_exponent -0.3 pi_proportional_norm_max 0.7 pi_integral_scale 0.0 pi_integral_exponent 0.4 pi_integral_norm_max 0.3 step_threshold 0.0 first_step_threshold 0.00002 clock_servo pi sanity_freq_limit 200000000 ntpshm_segment 0 # # Transport options # transportSpecific 0x0 ptp_dst_mac 01:1B:19:00:00:00 p2p_dst_mac 01:80:C2:00:00:0E udp_ttl 1 udp6_scope 0x0E uds_address /var/run/ptp4l # # Default interface options # clock_type BC network_transport L2 delay_mechanism E2E time_stamping hardware tsproc_mode filter delay_filter moving_median delay_filter_length 10 egressLatency 0 ingressLatency 0 boundary_clock_jbod 0 # # Clock description # productDescription ;; revisionData ;; manufacturerIdentity 00:00:00 userDescription ; timeSource 0x20 recommend: - profile: "grandmaster" priority: 4 match: - nodeLabel: "node-role.kubernetes.io/worker"运行以下命令来创建 CR:
$ oc create -f grandmaster-clock-ptp-config.yaml
验证
检查
PtpConfig配置集是否已应用到节点。运行以下命令,获取
openshift-ptp命名空间中的 pod 列表:$ oc get pods -n openshift-ptp -o wide
输出示例
NAME READY STATUS RESTARTS AGE IP NODE linuxptp-daemon-74m2g 3/3 Running 3 4d15h 10.16.230.7 compute-1.example.com ptp-operator-5f4f48d7c-x7zkf 1/1 Running 1 4d15h 10.128.1.145 compute-1.example.com
检查配置集是否正确。检查与
PtpConfig配置集中指定的节点对应的linuxptp守护进程的日志。运行以下命令:$ oc logs linuxptp-daemon-74m2g -n openshift-ptp -c linuxptp-daemon-container
输出示例
ts2phc[94980.334]: [ts2phc.0.config] nmea delay: 98690975 ns ts2phc[94980.334]: [ts2phc.0.config] ens3f0 extts index 0 at 1676577329.999999999 corr 0 src 1676577330.901342528 diff -1 ts2phc[94980.334]: [ts2phc.0.config] ens3f0 master offset -1 s2 freq -1 ts2phc[94980.441]: [ts2phc.0.config] nmea sentence: GNRMC,195453.00,A,4233.24427,N,07126.64420,W,0.008,,160223,,,A,V phc2sys[94980.450]: [ptp4l.0.config] CLOCK_REALTIME phc offset 943 s2 freq -89604 delay 504 phc2sys[94980.512]: [ptp4l.0.config] CLOCK_REALTIME phc offset 1000 s2 freq -89264 delay 474
其他资源
19.6.2.1. grandmaster clock PtpConfig 配置参考
以下参考信息描述了 PtpConfig 自定义资源 (CR) 的配置选项,它将 linuxptp 服务 (ptp4l、phc2sys、ts2phc) 配置为 grandmaster 时钟。
表 19.1. PTP Grandmaster 时钟的 PtpConfig 配置选项
| PtpConfig CR 字段 | 描述 |
|---|---|
|
|
指定一组
插件机制允许 PTP Operator 进行自动硬件配置。对于 Intel Westport Channel NIC,当 |
|
|
为 |
|
|
指定启动 |
|
| 指定丢弃数据前从发送方等待传输 (TX) 时间戳的最长时间。 |
|
| 指定 JBOD 边界时钟时间延迟值。这个值用于更正网络时间设备之间传递的时间值。 |
|
|
为 注意
确保此处列出的网络接口配置为 grandmaster,并在 |
|
|
为 |
|
|
当 |
|
|
可选。如果 |
|
|
设置
|
|
|
为 |
|
|
指定包括一个或多个 |
|
|
指定在 |
|
|
使用 |
|
|
使用 |
|
|
通过 |
|
|
使用 |
19.6.3. 将 linuxptp 服务配置为常规时钟
您可以通过创建 PtpConfig 自定义资源(CR)对象将 linuxptp 服务(ptp4l、phc2sys)配置为常规时钟。
使用 PtpConfig CR 示例,将 linuxptp 服务配置为特定硬件和环境的普通时钟。这个示例 CR 没有配置 PTP 快速事件。要配置 PTP 快速事件,请为 ptp4lOpts、ptp4lConf 和 ptpClockThreshold 设置适当的值。只有在启用事件时才需要 ptpClockThreshold。如需更多信息,请参阅"配置 PTP 快速事件通知发布程序"。
先决条件
-
安装 OpenShift CLI(
oc)。 -
以具有
cluster-admin特权的用户身份登录。 - 安装 PTP Operator。
流程
创建以下
PtpConfigCR,然后在ordinary-clock-ptp-config.yaml文件中保存 YAML。推荐的 PTP 普通时钟配置
apiVersion: ptp.openshift.io/v1 kind: PtpConfig metadata: name: ordinary-clock-ptp-config namespace: openshift-ptp spec: profile: - name: ordinary-clock interface: "<interface_name>" phc2sysOpts: "-a -r -n 24" ptp4lOpts: "-2 -s" ptpSchedulingPolicy: SCHED_FIFO ptpSchedulingPriority: 10 ptp4lConf: | [global] # # Default Data Set # twoStepFlag 1 slaveOnly 1 priority1 128 priority2 128 domainNumber 24 clockClass 255 clockAccuracy 0xFE offsetScaledLogVariance 0xFFFF free_running 0 freq_est_interval 1 dscp_event 0 dscp_general 0 dataset_comparison G.8275.x G.8275.defaultDS.localPriority 128 # # Port Data Set # logAnnounceInterval -3 logSyncInterval -4 logMinDelayReqInterval -4 logMinPdelayReqInterval -4 announceReceiptTimeout 3 syncReceiptTimeout 0 delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 20000000 masterOnly 0 G.8275.portDS.localPriority 128 # # Run time options # assume_two_step 0 logging_level 6 path_trace_enabled 0 follow_up_info 0 hybrid_e2e 0 inhibit_multicast_service 0 net_sync_monitor 0 tc_spanning_tree 0 tx_timestamp_timeout 50 unicast_listen 0 unicast_master_table 0 unicast_req_duration 3600 use_syslog 1 verbose 0 summary_interval 0 kernel_leap 1 check_fup_sync 0 # # Servo Options # pi_proportional_const 0.0 pi_integral_const 0.0 pi_proportional_scale 0.0 pi_proportional_exponent -0.3 pi_proportional_norm_max 0.7 pi_integral_scale 0.0 pi_integral_exponent 0.4 pi_integral_norm_max 0.3 step_threshold 2.0 first_step_threshold 0.00002 max_frequency 900000000 clock_servo pi sanity_freq_limit 200000000 ntpshm_segment 0 # # Transport options # transportSpecific 0x0 ptp_dst_mac 01:1B:19:00:00:00 p2p_dst_mac 01:80:C2:00:00:0E udp_ttl 1 udp6_scope 0x0E uds_address /var/run/ptp4l # # Default interface options # clock_type OC network_transport L2 delay_mechanism E2E time_stamping hardware tsproc_mode filter delay_filter moving_median delay_filter_length 10 egressLatency 0 ingressLatency 0 boundary_clock_jbod 0 # # Clock description # productDescription ;; revisionData ;; manufacturerIdentity 00:00:00 userDescription ; timeSource 0xA0 recommend: - profile: ordinary-clock priority: 4 match: - nodeLabel: "node-role.kubernetes.io/worker" nodeName: "<node_name>"表 19.2. PTP 普通时钟 CR 配置选项
自定义资源字段 描述 namePtpConfigCR 的名称。配置集指定包括一个或多个
profile的数组。每个配置集的名称都需要是唯一的。interface指定
ptp4l服务要使用的网络接口,如ens787f1。ptp4lOpts为
ptp4l服务指定系统配置选项,例如-2来选择 IEEE 802.3 网络传输。该选项不应包含网络接口名称-i <interface>和服务配置文件-f /etc/ptp4l.conf,因为网络接口名称和服务配置文件会被自动附加。附加--summary_interval -4来对此接口使用 PTP 快速事件。phc2sysOpts为
phc2sys服务指定系统配置选项。如果此字段为空,PTP Operator 不会启动phc2sys服务。对于 Intel Columbiaville 800 Series NIC,将phc2sysOpts选项设置为-a -r -m -n 24 -N 8 -R 16.-m将消息输出到stdout。linuxptp-daemonDaemonSet解析日志并生成 Prometheus 指标。ptp4lConf指定一个字符串,其中包含要替换默认的
/etc/ptp4l.conf文件的配置。要使用默认配置,请将字段留空。tx_timestamp_timeout对于 Intel Columbiaville 800 系列 NIC,将
tx_timestamp_timeout设置为50。boundary_clock_jbod对于 Intel Columbiaville 800 系列 NIC,将
boundary_clock_jbod设置为0。ptpSchedulingPolicyptp4l和phc2sys进程的调度策略。默认值为SCHED_OTHER。在支持 FIFO 调度的系统上使用SCHED_FIFO。ptpSchedulingPriority当
ptpSchedulingPolicy设置为SCHED_FIFO时,用于为ptp4l和phc2sys进程设置 FIFO 优先级的整数值(1 到 65)。当ptpSchedulingPolicy设置为SCHED_OTHER时,不使用ptpSchedulingPriority字段。ptpClockThreshold可选。如果没有
ptpClockThreshold,用于ptpClockThreshold字段的默认值。ptpClockThreshold配置在触发 PTP 时间前,PTP master 时钟已断开连接的时长。holdOverTimeout是在 PTP master clock 断开连接时,PTP 时钟事件状态更改为FREERUN前的时间值(以秒为单位)。maxOffsetThreshold和minOffsetThreshold设置以纳秒为单位,它们与CLOCK_REALTIME(phc2sys) 或 master 偏移 (ptp4l) 的值进行比较。当ptp4l或phc2sys偏移值超出这个范围时,PTP 时钟状态被设置为FREERUN。当偏移值在这个范围内时,PTP 时钟状态被设置为LOCKED。建议指定包括一个或多个
recommend对象的数组,该数组定义了如何将配置集应用到节点的规则。.recommend.profile指定在
profile部分定义的.recommend.profile对象名称。.recommend.priority对于普通时钟,将
.recommend.priority设置为0。.recommend.match使用
nodeLabel或nodeName指定.recommend.match规则。.recommend.match.nodeLabel通过
oc get nodes --show-labels命令,使用来自节点对象的node.Labels的key更新nodeLabel。例如:node-role.kubernetes.io/worker。.recommend.match.nodeLabel通过
oc get nodes命令,使用来自节点对象的node.Name值更新nodeName。例如:compute-0.example.com.运行以下命令来创建
PtpConfigCR:$ oc create -f ordinary-clock-ptp-config.yaml
验证
检查
PtpConfig配置集是否已应用到节点。运行以下命令,获取
openshift-ptp命名空间中的 pod 列表:$ oc get pods -n openshift-ptp -o wide
输出示例
NAME READY STATUS RESTARTS AGE IP NODE linuxptp-daemon-4xkbb 1/1 Running 0 43m 10.1.196.24 compute-0.example.com linuxptp-daemon-tdspf 1/1 Running 0 43m 10.1.196.25 compute-1.example.com ptp-operator-657bbb64c8-2f8sj 1/1 Running 0 43m 10.129.0.61 control-plane-1.example.com
检查配置集是否正确。检查与
PtpConfig配置集中指定的节点对应的linuxptp守护进程的日志。运行以下命令:$ oc logs linuxptp-daemon-4xkbb -n openshift-ptp -c linuxptp-daemon-container
输出示例
I1115 09:41:17.117596 4143292 daemon.go:107] in applyNodePTPProfile I1115 09:41:17.117604 4143292 daemon.go:109] updating NodePTPProfile to: I1115 09:41:17.117607 4143292 daemon.go:110] ------------------------------------ I1115 09:41:17.117612 4143292 daemon.go:102] Profile Name: profile1 I1115 09:41:17.117616 4143292 daemon.go:102] Interface: ens787f1 I1115 09:41:17.117620 4143292 daemon.go:102] Ptp4lOpts: -2 -s I1115 09:41:17.117623 4143292 daemon.go:102] Phc2sysOpts: -a -r -n 24 I1115 09:41:17.117626 4143292 daemon.go:116] ------------------------------------
其他资源
- 如需有关 PTP 硬件上的 FIFO 优先级调度的更多信息,请参阅为 PTP 硬件配置 FIFO 优先级调度。
- 有关配置 PTP 快速事件的更多信息,请参阅配置 PTP 快速事件通知发布程序。
19.6.4. 将 linuxptp 服务配置为边界时钟
您可以通过创建 PtpConfig 自定义资源(CR)对象将 linuxptp 服务(ptp4l、phc2sys)配置为边界时钟。
使用 PtpConfig CR 示例,将 linuxptp 服务配置为特定硬件和环境的边界时钟。这个示例 CR 没有配置 PTP 快速事件。要配置 PTP 快速事件,请为 ptp4lOpts、ptp4lConf 和 ptpClockThreshold 设置适当的值。ptpClockThreshold 仅在启用事件时使用。如需更多信息,请参阅"配置 PTP 快速事件通知发布程序"。
先决条件
-
安装 OpenShift CLI(
oc)。 -
以具有
cluster-admin特权的用户身份登录。 - 安装 PTP Operator。
流程
创建以下
PtpConfigCR,然后在boundaries-clock-ptp-config.yaml文件中保存 YAML。推荐的 PTP 边界时钟配置
--- apiVersion: ptp.openshift.io/v1 kind: PtpConfig metadata: name: boundary-clock-ptp-config namespace: openshift-ptp spec: profile: - name: boundary-clock phc2sysOpts: "-a -r -n 24" ptp4lOpts: "-2" ptpSchedulingPolicy: SCHED_FIFO ptpSchedulingPriority: 10 ptp4lConf: | [<interface_1>] masterOnly 0 [<interface_2>] masterOnly 1 [<interface_3>] masterOnly 1 [<interface_4>] masterOnly 1 [global] # # Default Data Set # twoStepFlag 1 slaveOnly 0 priority1 128 priority2 128 domainNumber 24 clockClass 248 clockAccuracy 0xFE offsetScaledLogVariance 0xFFFF free_running 0 freq_est_interval 1 dscp_event 0 dscp_general 0 dataset_comparison G.8275.x G.8275.defaultDS.localPriority 128 # # Port Data Set # logAnnounceInterval -3 logSyncInterval -4 logMinDelayReqInterval -4 logMinPdelayReqInterval -4 announceReceiptTimeout 3 syncReceiptTimeout 0 delayAsymmetry 0 fault_reset_interval 4 neighborPropDelayThresh 20000000 masterOnly 0 G.8275.portDS.localPriority 128 # # Run time options # assume_two_step 0 logging_level 6 path_trace_enabled 0 follow_up_info 0 hybrid_e2e 0 inhibit_multicast_service 0 net_sync_monitor 0 tc_spanning_tree 0 tx_timestamp_timeout 50 unicast_listen 0 unicast_master_table 0 unicast_req_duration 3600 use_syslog 1 verbose 0 summary_interval 0 kernel_leap 1 check_fup_sync 0 # # Servo Options # pi_proportional_const 0.0 pi_integral_const 0.0 pi_proportional_scale 0.0 pi_proportional_exponent -0.3 pi_proportional_norm_max 0.7 pi_integral_scale 0.0 pi_integral_exponent 0.4 pi_integral_norm_max 0.3 step_threshold 2.0 first_step_threshold 0.00002 max_frequency 900000000 clock_servo pi sanity_freq_limit 200000000 ntpshm_segment 0 # # Transport options # transportSpecific 0x0 ptp_dst_mac 01:1B:19:00:00:00 p2p_dst_mac 01:80:C2:00:00:0E udp_ttl 1 udp6_scope 0x0E uds_address /var/run/ptp4l # # Default interface options # clock_type BC network_transport L2 delay_mechanism E2E time_stamping hardware tsproc_mode filter delay_filter moving_median delay_filter_length 10 egressLatency 0 ingressLatency 0 boundary_clock_jbod 0 # # Clock description # productDescription ;; revisionData ;; manufacturerIdentity 00:00:00 userDescription ; timeSource 0xA0 recommend: - profile: boundary-clock priority: 4 match: - nodeLabel: node-role.kubernetes.io/master nodeName: <nodename>表 19.3. PTP 边界时钟 CR 配置选项
自定义资源字段 描述 namePtpConfigCR 的名称。配置集指定包括一个或多个
profile的数组。name指定唯一标识配置集对象的配置集对象的名称。
ptp4lOpts为
ptp4l服务指定系统配置选项。该选项不应包含网络接口名称-i <interface>和服务配置文件-f /etc/ptp4l.conf,因为网络接口名称和服务配置文件会被自动附加。ptp4lConf指定启动
ptp4l作为边界时钟所需的配置。例如,ens1f0同步来自 Pumaster 时钟,ens1f3同步连接的设备。<interface_1>接收同步时钟的接口。
<interface_2>发送同步时钟的接口。
tx_timestamp_timeout对于 Intel Columbiaville 800 系列 NIC,将
tx_timestamp_timeout设置为50。boundary_clock_jbod对于 Intel Columbiaville 800 系列 NIC,请确保
boundary_clock_jbod设置为0。对于 Intel Fortville X710 系列 NIC,请确保boundary_clock_jbod设置为1。phc2sysOpts为
phc2sys服务指定系统配置选项。如果此字段为空,PTP Operator 不会启动phc2sys服务。ptpSchedulingPolicyptp4l 和 phc2sys 进程的调度策略。默认值为
SCHED_OTHER。在支持 FIFO 调度的系统上使用SCHED_FIFO。ptpSchedulingPriority当
ptpSchedulingPolicy设置为SCHED_FIFO时,用于为ptp4l和phc2sys进程设置 FIFO 优先级的整数值(1 到 65)。当ptpSchedulingPolicy设置为SCHED_OTHER时,不使用ptpSchedulingPriority字段。ptpClockThreshold可选。如果没有
ptpClockThreshold,用于ptpClockThreshold字段的默认值。ptpClockThreshold配置在触发 PTP 时间前,PTP master 时钟已断开连接的时长。holdOverTimeout是在 PTP master clock 断开连接时,PTP 时钟事件状态更改为FREERUN前的时间值(以秒为单位)。maxOffsetThreshold和minOffsetThreshold设置以纳秒为单位,它们与CLOCK_REALTIME(phc2sys) 或 master 偏移 (ptp4l) 的值进行比较。当ptp4l或phc2sys偏移值超出这个范围时,PTP 时钟状态被设置为FREERUN。当偏移值在这个范围内时,PTP 时钟状态被设置为LOCKED。建议指定包括一个或多个
recommend对象的数组,该数组定义了如何将配置集应用到节点的规则。.recommend.profile指定在
profile部分定义的.recommend.profile对象名称。.recommend.priority使用
0到99之间的一个整数值指定priority。大数值的优先级较低,因此优先级99低于优先级10。如果节点可以根据match字段中定义的规则与多个配置集匹配,则优先级较高的配置集会应用到该节点。.recommend.match使用
nodeLabel或nodeName指定.recommend.match规则。.recommend.match.nodeLabel通过
oc get nodes --show-labels命令,使用来自节点对象的node.Labels的key更新nodeLabel。例如:node-role.kubernetes.io/worker。.recommend.match.nodeLabel通过
oc get nodes命令,使用来自节点对象的node.Name值更新nodeName。例如:compute-0.example.com.运行以下命令来创建 CR:
$ oc create -f boundary-clock-ptp-config.yaml
验证
检查
PtpConfig配置集是否已应用到节点。运行以下命令,获取
openshift-ptp命名空间中的 pod 列表:$ oc get pods -n openshift-ptp -o wide
输出示例
NAME READY STATUS RESTARTS AGE IP NODE linuxptp-daemon-4xkbb 1/1 Running 0 43m 10.1.196.24 compute-0.example.com linuxptp-daemon-tdspf 1/1 Running 0 43m 10.1.196.25 compute-1.example.com ptp-operator-657bbb64c8-2f8sj 1/1 Running 0 43m 10.129.0.61 control-plane-1.example.com
检查配置集是否正确。检查与
PtpConfig配置集中指定的节点对应的linuxptp守护进程的日志。运行以下命令:$ oc logs linuxptp-daemon-4xkbb -n openshift-ptp -c linuxptp-daemon-container
输出示例
I1115 09:41:17.117596 4143292 daemon.go:107] in applyNodePTPProfile I1115 09:41:17.117604 4143292 daemon.go:109] updating NodePTPProfile to: I1115 09:41:17.117607 4143292 daemon.go:110] ------------------------------------ I1115 09:41:17.117612 4143292 daemon.go:102] Profile Name: profile1 I1115 09:41:17.117616 4143292 daemon.go:102] Interface: I1115 09:41:17.117620 4143292 daemon.go:102] Ptp4lOpts: -2 I1115 09:41:17.117623 4143292 daemon.go:102] Phc2sysOpts: -a -r -n 24 I1115 09:41:17.117626 4143292 daemon.go:116] ------------------------------------
其他资源
- 如需有关 PTP 硬件上的 FIFO 优先级调度的更多信息,请参阅为 PTP 硬件配置 FIFO 优先级调度。
- 有关配置 PTP 快速事件的更多信息,请参阅配置 PTP 快速事件通知发布程序。
19.6.5. 将 linuxptp 服务配置为双 NIC 硬件边界时钟
使用配置为边界时钟的双 NIC 的精确时间协议(PTP)硬件只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围。
您可以通过为每个 NIC 创建一个 PtpConfig 自定义资源(CR)对象,将 linuxptp 服务(ptp4l、phc2sys)配置为双 NIC 硬件的边界时钟。
双 NIC 硬件允许您将每个 NIC 连接到相同的上游领导时钟,并将每个 NIC 的 ptp4l 实例连接给下游时钟。
先决条件
-
安装 OpenShift CLI(
oc)。 -
以具有
cluster-admin特权的用户身份登录。 - 安装 PTP Operator。
流程
创建两个单独的
PtpConfigCR,每个 NIC 使用 "Configuring linuxptp 服务作为边界时钟"中的引用 CR,作为每个 CR 的基础。例如:创建
boundary-clock-ptp-config-nic1.yaml,为phc2sysOpts指定值:apiVersion: ptp.openshift.io/v1 kind: PtpConfig metadata: name: boundary-clock-ptp-config-nic1 namespace: openshift-ptp spec: profile: - name: "profile1" ptp4lOpts: "-2 --summary_interval -4" ptp4lConf: | 1 [ens5f1] masterOnly 1 [ens5f0] masterOnly 0 ... phc2sysOpts: "-a -r -m -n 24 -N 8 -R 16" 2创建
boundary-clock-ptp-config-nic2.yaml,删除phc2sysOpts字段,以完全禁用第二个 NIC 的phc2sys服务:apiVersion: ptp.openshift.io/v1 kind: PtpConfig metadata: name: boundary-clock-ptp-config-nic2 namespace: openshift-ptp spec: profile: - name: "profile2" ptp4lOpts: "-2 --summary_interval -4" ptp4lConf: | 1 [ens7f1] masterOnly 1 [ens7f0] masterOnly 0 ...- 1
- 在第二个 NIC上 指定所需的接口来启动
ptp4l作为一个边境时钟。
注意您必须从第二个
PtpConfigCR 中完全删除phc2sysOpts字段,以禁用第二个 NIC 上的phc2sys服务。
运行以下命令来创建双 NIC
PtpConfigCR:创建 CR 来为第一个 NIC 配置 PTP:
$ oc create -f boundary-clock-ptp-config-nic1.yaml
创建 CR 来为第二个 NIC 配置 PTP:
$ oc create -f boundary-clock-ptp-config-nic2.yaml
验证
检查 PTP Operator 是否为两个 NIC 应用了
PtpConfigCR。检查与安装了双 NIC 硬件的节点对应的linuxptp守护进程的日志。例如,运行以下命令:$ oc logs linuxptp-daemon-cvgr6 -n openshift-ptp -c linuxptp-daemon-container
输出示例
ptp4l[80828.335]: [ptp4l.1.config] master offset 5 s2 freq -5727 path delay 519 ptp4l[80828.343]: [ptp4l.0.config] master offset -5 s2 freq -10607 path delay 533 phc2sys[80828.390]: [ptp4l.0.config] CLOCK_REALTIME phc offset 1 s2 freq -87239 delay 539
19.6.6. Intel Columbiaville E800 series NIC 作为 PTP 常规时钟参考
下表描述了您必须对引用 PTP 配置进行的更改,以便使用 Intel Columbiaville E800 系列 NIC 作为普通时钟。在应用到集群的 PtpConfig 自定义资源(CR)中进行更改。
表 19.4. Intel Columbiaville NIC 的推荐 PTP 设置
| PTP 配置 | 推荐的设置 |
|---|---|
|
|
|
|
|
|
|
|
|
对于 phc2sysOpts,-m 会将信息输出到 stdout。linuxptp-daemon DaemonSet 解析日志并生成 Prometheus 指标。
其他资源
-
有关将
linuxptp服务配置为具有 PTP 快速事件的普通时钟的完整示例 CR,请参阅将 linuxptp 服务配置为普通时钟。
19.6.7. 为 PTP 硬件配置 FIFO 优先级调度
在需要低延迟性能的电信或其他部署配置中,PTP 守护进程线程在受限制的 CPU 占用空间以及剩余的基础架构组件一起运行。默认情况下,PTP 线程使用 SCHED_OTHER 策略运行。在高负载下,这些线程可能没有获得无错操作所需的调度延迟。
要缓解潜在的调度延迟错误,您可以将 PTP Operator linuxptp 服务配置为允许线程使用 SCHED_FIFO 策略运行。如果为 PtpConfig CR 设置了 SCHED_FIFO,则 ptp4l 和 phc2sys 将在 chrt 的父容器中运行,且由 PtpConfig CR 的 ptpSchedulingPriority 字段设置。
设置 ptpSchedulingPolicy 是可选的,只有在遇到延迟错误时才需要。
流程
编辑
PtpConfigCR 配置集:$ oc edit PtpConfig -n openshift-ptp
更改
ptpSchedulingPolicy和ptpSchedulingPriority字段:apiVersion: ptp.openshift.io/v1 kind: PtpConfig metadata: name: <ptp_config_name> namespace: openshift-ptp ... spec: profile: - name: "profile1" ... ptpSchedulingPolicy: SCHED_FIFO 1 ptpSchedulingPriority: 10 2-
保存并退出,以将更改应用到
PtpConfigCR。
验证
获取
linuxptp-daemonpod 的名称以及应用PtpConfigCR 的对应节点:$ oc get pods -n openshift-ptp -o wide
输出示例
NAME READY STATUS RESTARTS AGE IP NODE linuxptp-daemon-gmv2n 3/3 Running 0 1d17h 10.1.196.24 compute-0.example.com linuxptp-daemon-lgm55 3/3 Running 0 1d17h 10.1.196.25 compute-1.example.com ptp-operator-3r4dcvf7f4-zndk7 1/1 Running 0 1d7h 10.129.0.61 control-plane-1.example.com
检查
ptp4l进程是否使用更新的chrtFIFO 运行:$ oc -n openshift-ptp logs linuxptp-daemon-lgm55 -c linuxptp-daemon-container|grep chrt
输出示例
I1216 19:24:57.091872 1600715 daemon.go:285] /bin/chrt -f 65 /usr/sbin/ptp4l -f /var/run/ptp4l.0.config -2 --summary_interval -4 -m
19.6.8. 为 linuxptp 服务配置日志过滤
linuxptp 守护进程生成可用于调试目的的日志。在具有有限存储容量的电信或其他部署配置中,这些日志可以添加到存储要求中。
要减少数量日志消息,您可以配置 PtpConfig 自定义资源 (CR) 来排除报告 master offset 值的日志消息。master offset 日志消息以纳秒为单位报告当前节点时钟和 master 时钟之间的区别。
先决条件
-
安装 OpenShift CLI(
oc)。 -
以具有
cluster-admin特权的用户身份登录。 - 安装 PTP Operator。
流程
编辑
PtpConfigCR:$ oc edit PtpConfig -n openshift-ptp
在
spec.profile中,添加ptpSettings.logReduce规格,并将值设为true:apiVersion: ptp.openshift.io/v1 kind: PtpConfig metadata: name: <ptp_config_name> namespace: openshift-ptp ... spec: profile: - name: "profile1" ... ptpSettings: logReduce: "true"注意为了进行调试,您可以将此规格恢复到
False,使其包含 master 偏移消息。-
保存并退出,以将更改应用到
PtpConfigCR。
验证
获取
linuxptp-daemonpod 的名称以及应用PtpConfigCR 的对应节点:$ oc get pods -n openshift-ptp -o wide
输出示例
NAME READY STATUS RESTARTS AGE IP NODE linuxptp-daemon-gmv2n 3/3 Running 0 1d17h 10.1.196.24 compute-0.example.com linuxptp-daemon-lgm55 3/3 Running 0 1d17h 10.1.196.25 compute-1.example.com ptp-operator-3r4dcvf7f4-zndk7 1/1 Running 0 1d7h 10.129.0.61 control-plane-1.example.com
运行以下命令,验证 master 偏移信息是否不包括在日志中:
$ oc -n openshift-ptp logs <linux_daemon_container> -c linuxptp-daemon-container | grep "master offset" 1- 1
- <linux_daemon_container> 是
linuxptp-daemonpod 的名称,如linuxptp-daemon-gmv2n。
当您配置
logReduce规格时,这个命令会在linuxptp守护进程日志中报告任何master offset实例。