18.5. 配置 PTP 设备

PTP Operator 将 NodePtpDevice.ptp.openshift.io 自定义资源定义(CRD)添加到 OpenShift Container Platform。

安装后,PTP Operator 会在每个节点中搜索具有 PTP 功能的网络设备。它为提供兼容 PTP 的网络设备的每个节点创建并更新 NodePtpDevice 自定义资源(CR)对象。

18.5.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
    ...

    1
    name 参数的值与父节点的名称相同。
    2
    devices 集合包含 PTP Operator 发现节点的 PTP 功能设备列表。

18.5.2. 将 linuxptp 服务配置为 grandmaster 时钟

您可以通过创建一个配置主机 NIC 的 PtpConfig 自定义资源 (CR) 将 linuxptp 服务 (ptp4lphc2systs2phc) 配置为 grandmaster 时钟。

ts2phc 工具允许您将系统时钟与 PTP grandmaster 时钟同步,以便节点可以将精度时钟信号流传输到下游 PTP 普通时钟和边界时钟。

注意

使用 PtpConfig CR 示例,将 linuxptp 服务配置为特定硬件和环境的 grandmaster 时钟。这个示例 CR 没有配置 PTP 快速事件。要配置 PTP 快速事件,请为 ptp4lOptsptp4lConfptpClockThreshold 设置适当的值。ptpClockThreshold 仅在启用事件时使用。如需更多信息,请参阅"配置 PTP 快速事件通知发布程序"。

先决条件

  • 在裸机集群主机上安装 Intel Westport Channel 网络接口。
  • 安装 OpenShift CLI (oc) 。
  • 以具有 cluster-admin 特权的用户身份登录。
  • 安装 PTP Operator。

流程

  1. 创建 PtpConfig 资源。例如:

    1. 将以下 YAML 保存到 grandmaster-clock-ptp-config.yaml 文件中:

      PTP grandmaster 时钟配置示例

      apiVersion: ptp.openshift.io/v1
      kind: PtpConfig
      metadata:
        name: grandmaster-clock
        namespace: openshift-ptp
        annotations: {}
      spec:
        profile:
          - name: grandmaster-clock
            # The interface name is hardware-specific
            interface: $interface
            ptp4lOpts: "-2"
            phc2sysOpts: "-a -r -r -n 24"
            ptpSchedulingPolicy: SCHED_FIFO
            ptpSchedulingPriority: 10
            ptpSettings:
              logReduce: "true"
            ptp4lConf: |
              [global]
              #
              # Default Data Set
              #
              twoStepFlag 1
              slaveOnly 0
              priority1 128
              priority2 128
              domainNumber 24
              #utc_offset 37
              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
              clock_class_threshold 7
              #
              # 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: grandmaster-clock
            priority: 4
            match:
              - nodeLabel: "node-role.kubernetes.io/$mcp"

    2. 运行以下命令来创建 CR:

      $ oc create -f grandmaster-clock-ptp-config.yaml

验证

  1. 检查 PtpConfig 配置集是否已应用到节点。

    1. 运行以下命令,获取 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

    2. 检查配置集是否正确。检查与 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

18.5.3. 将 linuxptp 服务配置为常规时钟

您可以通过创建 PtpConfig 自定义资源(CR)对象将 linuxptp 服务(ptp4lphc2sys)配置为常规时钟。

注意

使用 PtpConfig CR 示例,将 linuxptp 服务配置为特定硬件和环境的普通时钟。这个示例 CR 没有配置 PTP 快速事件。要配置 PTP 快速事件,请为 ptp4lOptsptp4lConfptpClockThreshold 设置适当的值。只有在启用事件时才需要 ptpClockThreshold。如需更多信息,请参阅"配置 PTP 快速事件通知发布程序"。

先决条件

  • 安装 OpenShift CLI(oc)。
  • 以具有 cluster-admin 特权的用户身份登录。
  • 安装 PTP Operator。

流程

  1. 创建以下 PtpConfig CR,然后在 ordinary-clock-ptp-config.yaml 文件中保存 YAML。

    PTP 普通时钟配置示例

    apiVersion: ptp.openshift.io/v1
    kind: PtpConfig
    metadata:
      name: ordinary-clock
      namespace: openshift-ptp
      annotations: {}
    spec:
      profile:
        - name: ordinary-clock
          # The interface name is hardware-specific
          interface: $interface
          ptp4lOpts: "-2 -s"
          phc2sysOpts: "-a -r -n 24"
          ptpSchedulingPolicy: SCHED_FIFO
          ptpSchedulingPriority: 10
          ptpSettings:
            logReduce: "true"
          ptp4lConf: |
            [global]
            #
            # Default Data Set
            #
            twoStepFlag 1
            slaveOnly 1
            priority1 128
            priority2 128
            domainNumber 24
            #utc_offset 37
            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
            clock_class_threshold 7
            #
            # 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/$mcp"

    表 18.1. PTP 普通时钟 CR 配置选项

    自定义资源字段描述

    name

    PtpConfig CR 的名称。

    配置集

    指定包括一个或多个 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 将消息输出到 stdoutlinuxptp-daemon DaemonSet 解析日志并生成 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。

    ptpSchedulingPolicy

    ptp4lphc2sys 进程的调度策略。默认值为 SCHED_OTHER。在支持 FIFO 调度的系统上使用 SCHED_FIFO

    ptpSchedulingPriority

    ptpSchedulingPolicy 设置为 SCHED_FIFO 时,用于为 ptp4lphc2sys 进程设置 FIFO 优先级的整数值(1 到 65)。当 ptpSchedulingPolicy 设置为 SCHED_OTHER 时,不使用 ptpSchedulingPriority 字段。

    ptpClockThreshold

    可选。如果没有 ptpClockThreshold,用于 ptpClockThreshold 字段的默认值。ptpClockThreshold 配置在触发 PTP 时间前,PTP master 时钟已断开连接的时长。holdOverTimeout 是在 PTP master clock 断开连接时,PTP 时钟事件状态更改为 FREERUN 前的时间值(以秒为单位)。maxOffsetThresholdminOffsetThreshold 设置以纳秒为单位,它们与 CLOCK_REALTIME (phc2sys) 或 master 偏移 (ptp4l) 的值进行比较。当 ptp4lphc2sys 偏移值超出这个范围时,PTP 时钟状态被设置为 FREERUN。当偏移值在这个范围内时,PTP 时钟状态被设置为 LOCKED

    建议

    指定包括一个或多个 recommend 对象的数组,该数组定义了如何将配置集应用到节点的规则。

    .recommend.profile

    指定在 profile 部分定义的 .recommend.profile 对象名称。

    .recommend.priority

    对于普通时钟,将 .recommend.priority 设置为 0。

    .recommend.match

    使用 nodeLabelnodeName 值指定 .recommend.match 规则。

    .recommend.match.nodeLabel

    通过 oc get nodes --show-labels 命令,使用来自节点对象的 node.Labelskey 设置 nodeLabel。例如,node-role.kubernetes.io/worker

    .recommend.match.nodeName

    使用 oc get nodes 命令,将 nodeName 设置为来自节点对象的 node.Name 值。例如,compute-1.example.com

  2. 运行以下命令来创建 PtpConfig CR:

    $ oc create -f ordinary-clock-ptp-config.yaml

验证

  1. 检查 PtpConfig 配置集是否已应用到节点。

    1. 运行以下命令,获取 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

    2. 检查配置集是否正确。检查与 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] ------------------------------------

其他资源

18.5.4. 将 linuxptp 服务配置为边界时钟

您可以通过创建 PtpConfig 自定义资源(CR)对象将 linuxptp 服务(ptp4lphc2sys)配置为边界时钟。

注意

使用 PtpConfig CR 示例,将 linuxptp 服务配置为特定硬件和环境的边界时钟。这个示例 CR 没有配置 PTP 快速事件。要配置 PTP 快速事件,请为 ptp4lOptsptp4lConfptpClockThreshold 设置适当的值。ptpClockThreshold 仅在启用事件时使用。如需更多信息,请参阅"配置 PTP 快速事件通知发布程序"。

先决条件

  • 安装 OpenShift CLI(oc)。
  • 以具有 cluster-admin 特权的用户身份登录。
  • 安装 PTP Operator。

流程

  1. 创建以下 PtpConfig CR,然后在 boundaries-clock-ptp-config.yaml 文件中保存 YAML。

    PTP 边界时钟配置示例

    apiVersion: ptp.openshift.io/v1
    kind: PtpConfig
    metadata:
      name: boundary-clock
      namespace: openshift-ptp
      annotations: {}
    spec:
      profile:
        - name: boundary-clock
          ptp4lOpts: "-2"
          phc2sysOpts: "-a -r -n 24"
          ptpSchedulingPolicy: SCHED_FIFO
          ptpSchedulingPriority: 10
          ptpSettings:
            logReduce: "true"
          ptp4lConf: |
            # The interface name is hardware-specific
            [$iface_slave]
            masterOnly 0
            [$iface_master_1]
            masterOnly 1
            [$iface_master_2]
            masterOnly 1
            [$iface_master_3]
            masterOnly 1
            [global]
            #
            # Default Data Set
            #
            twoStepFlag 1
            slaveOnly 0
            priority1 128
            priority2 128
            domainNumber 24
            #utc_offset 37
            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
            clock_class_threshold 135
            #
            # 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/$mcp"

    表 18.2. PTP 边界时钟 CR 配置选项

    自定义资源字段描述

    name

    PtpConfig CR 的名称。

    配置集

    指定包括一个或多个 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 服务。

    ptpSchedulingPolicy

    ptp4l 和 phc2sys 进程的调度策略。默认值为 SCHED_OTHER。在支持 FIFO 调度的系统上使用 SCHED_FIFO

    ptpSchedulingPriority

    ptpSchedulingPolicy 设置为 SCHED_FIFO 时,用于为 ptp4lphc2sys 进程设置 FIFO 优先级的整数值(1 到 65)。当 ptpSchedulingPolicy 设置为 SCHED_OTHER 时,不使用 ptpSchedulingPriority 字段。

    ptpClockThreshold

    可选。如果没有 ptpClockThreshold,用于 ptpClockThreshold 字段的默认值。ptpClockThreshold 配置在触发 PTP 时间前,PTP master 时钟已断开连接的时长。holdOverTimeout 是在 PTP master clock 断开连接时,PTP 时钟事件状态更改为 FREERUN 前的时间值(以秒为单位)。maxOffsetThresholdminOffsetThreshold 设置以纳秒为单位,它们与 CLOCK_REALTIME (phc2sys) 或 master 偏移 (ptp4l) 的值进行比较。当 ptp4lphc2sys 偏移值超出这个范围时,PTP 时钟状态被设置为 FREERUN。当偏移值在这个范围内时,PTP 时钟状态被设置为 LOCKED

    建议

    指定包括一个或多个 recommend 对象的数组,该数组定义了如何将配置集应用到节点的规则。

    .recommend.profile

    指定在 profile 部分定义的 .recommend.profile 对象名称。

    .recommend.priority

    使用 099 之间的一个整数值指定 priority。大数值的优先级较低,因此优先级 99 低于优先级 10。如果节点可以根据 match 字段中定义的规则与多个配置集匹配,则优先级较高的配置集会应用到该节点。

    .recommend.match

    使用 nodeLabelnodeName 值指定 .recommend.match 规则。

    .recommend.match.nodeLabel

    通过 oc get nodes --show-labels 命令,使用来自节点对象的 node.Labelskey 设置 nodeLabel。例如,node-role.kubernetes.io/worker

    .recommend.match.nodeName

    使用 oc get nodes 命令,将 nodeName 设置为来自节点对象的 node.Name 值。例如,compute-1.example.com

  2. 运行以下命令来创建 CR:

    $ oc create -f boundary-clock-ptp-config.yaml

验证

  1. 检查 PtpConfig 配置集是否已应用到节点。

    1. 运行以下命令,获取 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

    2. 检查配置集是否正确。检查与 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] ------------------------------------

其他资源

18.5.5. 将 linuxptp 服务配置为双 NIC 硬件边界时钟

重要

使用配置为边界时钟的双 NIC 的精确时间协议(PTP)硬件只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。

有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围

您可以通过为每个 NIC 创建一个 PtpConfig 自定义资源(CR)对象,将 linuxptp 服务(ptp4lphc2sys)配置为双 NIC 硬件的边界时钟。

双 NIC 硬件允许您将每个 NIC 连接到相同的上游领导时钟,并将每个 NIC 的 ptp4l 实例连接给下游时钟。

先决条件

  • 安装 OpenShift CLI(oc)。
  • 以具有 cluster-admin 特权的用户身份登录。
  • 安装 PTP Operator。

流程

  1. 创建两个单独的 PtpConfig CR,每个 NIC 使用 "Configuring linuxptp 服务作为边界时钟"中的引用 CR,作为每个 CR 的基础。例如:

    1. 创建 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
      1
      指定所需的接口来启动 ptp4l 作为一个边境时钟。例如,ens5f0 从 grandmaster 时钟同步,ens5f1 同步连接的设备。
      2
      所需的 phc2sysOpts 值。-m 将消息输出到 stdoutlinuxptp-daemon DaemonSet 解析日志并生成 Prometheus 指标。
    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 作为一个边境时钟。
      注意

      您必须从第二个 PtpConfig CR 中完全删除 phc2sysOpts 字段,以禁用第二个 NIC 上的 phc2sys 服务。

  2. 运行以下命令来创建双 NIC PtpConfig CR:

    1. 创建 CR 来为第一个 NIC 配置 PTP:

      $ oc create -f boundary-clock-ptp-config-nic1.yaml
    2. 创建 CR 来为第二个 NIC 配置 PTP:

      $ oc create -f boundary-clock-ptp-config-nic2.yaml

验证

  • 检查 PTP Operator 是否为两个 NIC 应用了 PtpConfig CR。检查与安装了双 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

18.5.6. Intel Columbiaville E800 series NIC 作为 PTP 常规时钟参考

下表描述了您必须对引用 PTP 配置进行的更改,以便使用 Intel Columbiaville E800 系列 NIC 作为普通时钟。在应用到集群的 PtpConfig 自定义资源(CR)中进行更改。

表 18.3. Intel Columbiaville NIC 的推荐 PTP 设置

PTP 配置推荐的设置

phc2sysOpts

-a -r -m -n 24 -N 8 -R 16

tx_timestamp_timeout

50

boundary_clock_jbod

0

注意

对于 phc2sysOpts-m 会将信息输出到 stdoutlinuxptp-daemon DaemonSet 解析日志并生成 Prometheus 指标。

其他资源

18.5.7. 为 PTP 硬件配置 FIFO 优先级调度

在需要低延迟性能的电信或其他部署配置中,PTP 守护进程线程在受限制的 CPU 占用空间以及剩余的基础架构组件一起运行。默认情况下,PTP 线程使用 SCHED_OTHER 策略运行。在高负载下,这些线程可能没有获得无错操作所需的调度延迟。

要缓解潜在的调度延迟错误,您可以将 PTP Operator linuxptp 服务配置为允许线程使用 SCHED_FIFO 策略运行。如果为 PtpConfig CR 设置了 SCHED_FIFO,则 ptp4lphc2sys 将在 chrt 的父容器中运行,且由 PtpConfig CR 的 ptpSchedulingPriority 字段设置。

注意

设置 ptpSchedulingPolicy 是可选的,只有在遇到延迟错误时才需要。

流程

  1. 编辑 PtpConfig CR 配置集:

    $ oc edit PtpConfig -n openshift-ptp
  2. 更改 ptpSchedulingPolicyptpSchedulingPriority 字段:

    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
    1
    ptp4lphc2sys 进程的调度策略。在支持 FIFO 调度的系统上使用 SCHED_FIFO
    2
    必需。设置整数值 1-65,用于为 ptp4lphc2sys 进程配置 FIFO 优先级。
  3. 保存并退出,以将更改应用到 PtpConfig CR。

验证

  1. 获取 linuxptp-daemon pod 的名称以及应用 PtpConfig CR 的对应节点:

    $ 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

  2. 检查 ptp4l 进程是否使用更新的 chrt FIFO 运行:

    $ 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

18.5.8. 为 linuxptp 服务配置日志过滤

linuxptp 守护进程生成可用于调试目的的日志。在具有有限存储容量的电信或其他部署配置中,这些日志可以添加到存储要求中。

要减少数量日志消息,您可以配置 PtpConfig 自定义资源 (CR) 来排除报告 master offset 值的日志消息。master offset 日志消息以纳秒为单位报告当前节点时钟和 master 时钟之间的区别。

先决条件

  • 安装 OpenShift CLI(oc)。
  • 以具有 cluster-admin 特权的用户身份登录。
  • 安装 PTP Operator。

流程

  1. 编辑 PtpConfig CR:

    $ oc edit PtpConfig -n openshift-ptp
  2. 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 偏移消息。

  3. 保存并退出,以将更改应用到 PtpConfig CR。

验证

  1. 获取 linuxptp-daemon pod 的名称以及应用 PtpConfig CR 的对应节点:

    $ 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

  2. 运行以下命令,验证 master 偏移信息是否不包括在日志中:

    $ oc -n openshift-ptp logs <linux_daemon_container> -c linuxptp-daemon-container | grep "master offset" 1
    1
    <linux_daemon_container> 是 linuxptp-daemon pod 的名称,如 linuxptp-daemon-gmv2n

    当您配置 logReduce 规格时,这个命令会在 linuxptp 守护进程日志中报告任何 master offset 实例。