第 5 章 收集集群数据

在提交问题单时同时提供您的集群信息,可以帮助红帽支持为您进行排除故障。

建议您提供:

5.1. 关于 must-gather 工具

oc adm must-gather CLI 命令可收集最有助于解决问题的集群信息,包括:

  • 资源定义
  • 服务日志

默认情况下,oc adm must-gather 命令使用默认的插件镜像,并写入 ./must-gather.local

另外,您可以使用适当的参数运行命令来收集具体信息,如以下部分所述:

  • 要收集与一个或多个特定功能相关的数据,请使用 --image 参数和镜像,如以下部分所述。

    例如:

    $ oc adm must-gather  --image=registry.redhat.io/container-native-virtualization/cnv-must-gather-rhel8:v4.12.0
  • 要收集审计日志,请使用 -- /usr/bin/gather_audit_logs 参数,如以下部分所述。

    例如:

    $ oc adm must-gather -- /usr/bin/gather_audit_logs
    注意

    作为默认信息集合的一部分,不会收集审计日志来减小文件的大小。

当您运行 oc adm must-gather 时,集群的新项目中会创建一个带有随机名称的新 pod。在该 pod 上收集数据,并保存至以 must-gather.local 开头的一个新目录中。此目录在当前工作目录中创建。

例如:

NAMESPACE                      NAME                 READY   STATUS      RESTARTS      AGE
...
openshift-must-gather-5drcj    must-gather-bklx4    2/2     Running     0             72s
openshift-must-gather-5drcj    must-gather-s8sdh    2/2     Running     0             72s
...

5.1.1. 为红帽支持收集您的集群数据

您可使用 oc adm must-gather CLI 命令收集有关您的集群的调试信息。

先决条件

  • 使用具有 cluster-admin 角色的用户访问集群。
  • 已安装 OpenShift Container Platform CLI (oc)。

流程

  1. 进入要存储 must-gather 数据的目录。

    注意

    如果集群在断开连接的环境中,则需要执行额外的步骤。如果您镜像的容器镜像仓库有一个信任的 CA,您必须首先将这个信任的 CA 添加到集群中。对于在断开连接的环境中的所有集群,您必须导入默认的 must-gather 镜像作为镜像流。

    $ oc import-image is/must-gather -n openshift
  2. 运行 oc adm must-gather 命令:

    $ oc adm must-gather
    重要

    如果您位于断开连接的环境中,请使用 --image 标志作为 must-gather 的一部分,指向有效负载镜像。

    注意

    因为这个命令会默认会选择一个随机 control plane 节点,所以 pod 可能会被调度到处于 NotReadySchedulingDisabled 状态的 control plane 节点。

    1. 如果此命令失败,例如,您无法在集群中调度 pod,则使用 oc adm inspect 命令来收集特定资源的信息。

      注意

      请联络红帽支持以获取推荐收集的资源信息。

  3. 从刚刚在您的工作目录中创建的 must-gather 目录创建一个压缩文件。例如,在使用 Linux 操作系统的计算机上运行以下命令:

    $ tar cvaf must-gather.tar.gz must-gather.local.5421342344627712289/ 1
    1
    务必将 must-gather-local.5421342344627712289/ 替换为实际目录名称。
  4. 红帽客户门户网站的客户支持页面中,将压缩文件附加到您的支持问题单中。

5.1.2. 收集有关特定功能的数据

您可通过将 oc adm must-gather CLI 命令与 --image--image-stream 参数结合使用来收集有关特定功能的调试信息。must-gather 工具支持多个镜像,这样您便可通过运行单个命令收集多个功能的数据。

表 5.1. 支持的 must-gather 镜像

Image用途

registry.redhat.io/container-native-virtualization/cnv-must-gather-rhel8:v4.12.10

OpenShift Virtualization 的数据收集。

registry.redhat.io/openshift-serverless-1/svls-must-gather-rhel8

OpenShift Serverless 的数据收集。

registry.redhat.io/openshift-service-mesh/istio-must-gather-rhel8:<installed_version_service_mesh>

Red Hat OpenShift Service Mesh 的数据收集。

registry.redhat.io/rhmtc/openshift-migration-must-gather-rhel8:v<installed_version_migration_toolkit>

MTC 的数据收集。

registry.redhat.io/odf4/ocs-must-gather-rhel8:v<installed_version_ODF>

Red Hat OpenShift Data Foundation 的数据收集。

registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator:v<installed_version_logging>

用于日志记录的数据收集。

registry.redhat.io/openshift4/ose-csi-driver-shared-resource-mustgather-rhel8

OpenShift 共享资源 CSI 驱动程序的数据收集。

registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel8:v<installed_version_LSO>

Local Storage Operator 的数据收集。

registry.redhat.io/openshift-sandboxed-containers/osc-must-gather-rhel8:v<installed_version_sandboxed_containers>

OpenShift 沙盒容器的数据收集。

registry.redhat.io/workload-availability/self-node-remediation-must-gather-rhel8:v<installed-version-SNR>

用于自节点修复 (SNR) Operator 和 Node Health Check (NHC) Operator 的数据收集。

registry.redhat.io/openshift4/ptp-must-gather-rhel8:v<installed-version-ptp>

PTP Operator 的数据收集。

registry.redhat.io/workload-availability/node-maintenance-must-gather-rhel8:v<installed-version-NMO>

Node Maintenance Operator (NMO) 的数据收集。

quay.io/openshift-pipeline/must-gather

Red Hat OpenShift Pipelines 的数据收集

registry.redhat.io/openshift-gitops-1/must-gather-rhel8:v<installed_version_GitOps>

Red Hat OpenShift GitOps 的数据收集。

registry.redhat.io/lvms4/lvms-must-gather-rhel8:v<installed_version_LVMS>

LVM Operator 的数据收集。

registry.redhat.io/rhacm2/acm-must-gather-rhel9:v<ACM_version>

Red Hat Advanced Cluster Management (RHACM) 2.10 及更新版本的数据收集。

registry.redhat.io/rhacm2/acm-must-gather-rhel8:v<ACM_version>

RHACM 2.9 及更早版本的数据收集。

<registry_name:port_number>/rhacm2/acm-must-gather-rhel9:v<ACM_version>

在断开连接的环境中,RHACM 2.10 及更新版本的数据收集。

<registry_name:port_number>/rhacm2/acm-must-gather-rhel8:v<ACM_version>

在断开连接的环境中,RHACM 2.9 及更早版本的数据收集。

注意

要确定 OpenShift Container Platform 组件镜像的最新版本,请参阅红帽客户门户网站中的 Red Hat OpenShift Container Platform 生命周期政策网页。

先决条件

  • 使用具有 cluster-admin 角色的用户访问集群。
  • 已安装 OpenShift Container Platform CLI (oc)。

流程

  1. 进入存储 must-gather 数据的目录。
  2. 使用一个或多个 --image--image-stream 参数运行 oc adm must-gather 命令。

    注意
    • 要收集除特定功能数据外的默认 must-gather 数据,请添加 --image-stream=openshift/must-gather 参数。
    • 有关收集有关自定义 Metrics Autoscaler 的数据的详情,请参考下面的附加资源部分。

    例如,使用以下命令可收集默认集群数据和 OpenShift Virtualization 特定信息:

    $ oc adm must-gather \
     --image-stream=openshift/must-gather \ 1
     --image=registry.redhat.io/container-native-virtualization/cnv-must-gather-rhel8:v4.12.10 2
    1
    默认 OpenShift Container Platform must-gather 镜像
    2
    OpenShift Virtualization 的 must-gather 镜像

    您可以将 must-gather 工具与额外参数搭配使用,以收集集群中与 OpenShift Logging 和 Red Hat OpenShift Logging Operator 相关的数据。对于 OpenShift Logging,运行以下命令:

    $ oc adm must-gather --image=$(oc -n openshift-logging get deployment.apps/cluster-logging-operator \
     -o jsonpath='{.spec.template.spec.containers[?(@.name == "cluster-logging-operator")].image}')

    例 5.1. OpenShift Logging 的 must-gather 输出示例

    ├── cluster-logging
    │  ├── clo
    │  │  ├── cluster-logging-operator-74dd5994f-6ttgt
    │  │  ├── clusterlogforwarder_cr
    │  │  ├── cr
    │  │  ├── csv
    │  │  ├── deployment
    │  │  └── logforwarding_cr
    │  ├── collector
    │  │  ├── fluentd-2tr64
    │  ├── eo
    │  │  ├── csv
    │  │  ├── deployment
    │  │  └── elasticsearch-operator-7dc7d97b9d-jb4r4
    │  ├── es
    │  │  ├── cluster-elasticsearch
    │  │  │  ├── aliases
    │  │  │  ├── health
    │  │  │  ├── indices
    │  │  │  ├── latest_documents.json
    │  │  │  ├── nodes
    │  │  │  ├── nodes_stats.json
    │  │  │  └── thread_pool
    │  │  ├── cr
    │  │  ├── elasticsearch-cdm-lp8l38m0-1-794d6dd989-4jxms
    │  │  └── logs
    │  │     ├── elasticsearch-cdm-lp8l38m0-1-794d6dd989-4jxms
    │  ├── install
    │  │  ├── co_logs
    │  │  ├── install_plan
    │  │  ├── olmo_logs
    │  │  └── subscription
    │  └── kibana
    │     ├── cr
    │     ├── kibana-9d69668d4-2rkvz
    ├── cluster-scoped-resources
    │  └── core
    │     ├── nodes
    │     │  ├── ip-10-0-146-180.eu-west-1.compute.internal.yaml
    │     └── persistentvolumes
    │        ├── pvc-0a8d65d9-54aa-4c44-9ecc-33d9381e41c1.yaml
    ├── event-filter.html
    ├── gather-debug.log
    └── namespaces
       ├── openshift-logging
       │  ├── apps
       │  │  ├── daemonsets.yaml
       │  │  ├── deployments.yaml
       │  │  ├── replicasets.yaml
       │  │  └── statefulsets.yaml
       │  ├── batch
       │  │  ├── cronjobs.yaml
       │  │  └── jobs.yaml
       │  ├── core
       │  │  ├── configmaps.yaml
       │  │  ├── endpoints.yaml
       │  │  ├── events
       │  │  │  ├── elasticsearch-im-app-1596020400-gm6nl.1626341a296c16a1.yaml
       │  │  │  ├── elasticsearch-im-audit-1596020400-9l9n4.1626341a2af81bbd.yaml
       │  │  │  ├── elasticsearch-im-infra-1596020400-v98tk.1626341a2d821069.yaml
       │  │  │  ├── elasticsearch-im-app-1596020400-cc5vc.1626341a3019b238.yaml
       │  │  │  ├── elasticsearch-im-audit-1596020400-s8d5s.1626341a31f7b315.yaml
       │  │  │  ├── elasticsearch-im-infra-1596020400-7mgv8.1626341a35ea59ed.yaml
       │  │  ├── events.yaml
       │  │  ├── persistentvolumeclaims.yaml
       │  │  ├── pods.yaml
       │  │  ├── replicationcontrollers.yaml
       │  │  ├── secrets.yaml
       │  │  └── services.yaml
       │  ├── openshift-logging.yaml
       │  ├── pods
       │  │  ├── cluster-logging-operator-74dd5994f-6ttgt
       │  │  │  ├── cluster-logging-operator
       │  │  │  │  └── cluster-logging-operator
       │  │  │  │     └── logs
       │  │  │  │        ├── current.log
       │  │  │  │        ├── previous.insecure.log
       │  │  │  │        └── previous.log
       │  │  │  └── cluster-logging-operator-74dd5994f-6ttgt.yaml
       │  │  ├── cluster-logging-operator-registry-6df49d7d4-mxxff
       │  │  │  ├── cluster-logging-operator-registry
       │  │  │  │  └── cluster-logging-operator-registry
       │  │  │  │     └── logs
       │  │  │  │        ├── current.log
       │  │  │  │        ├── previous.insecure.log
       │  │  │  │        └── previous.log
       │  │  │  ├── cluster-logging-operator-registry-6df49d7d4-mxxff.yaml
       │  │  │  └── mutate-csv-and-generate-sqlite-db
       │  │  │     └── mutate-csv-and-generate-sqlite-db
       │  │  │        └── logs
       │  │  │           ├── current.log
       │  │  │           ├── previous.insecure.log
       │  │  │           └── previous.log
       │  │  ├── elasticsearch-cdm-lp8l38m0-1-794d6dd989-4jxms
       │  │  ├── elasticsearch-im-app-1596030300-bpgcx
       │  │  │  ├── elasticsearch-im-app-1596030300-bpgcx.yaml
       │  │  │  └── indexmanagement
       │  │  │     └── indexmanagement
       │  │  │        └── logs
       │  │  │           ├── current.log
       │  │  │           ├── previous.insecure.log
       │  │  │           └── previous.log
       │  │  ├── fluentd-2tr64
       │  │  │  ├── fluentd
       │  │  │  │  └── fluentd
       │  │  │  │     └── logs
       │  │  │  │        ├── current.log
       │  │  │  │        ├── previous.insecure.log
       │  │  │  │        └── previous.log
       │  │  │  ├── fluentd-2tr64.yaml
       │  │  │  └── fluentd-init
       │  │  │     └── fluentd-init
       │  │  │        └── logs
       │  │  │           ├── current.log
       │  │  │           ├── previous.insecure.log
       │  │  │           └── previous.log
       │  │  ├── kibana-9d69668d4-2rkvz
       │  │  │  ├── kibana
       │  │  │  │  └── kibana
       │  │  │  │     └── logs
       │  │  │  │        ├── current.log
       │  │  │  │        ├── previous.insecure.log
       │  │  │  │        └── previous.log
       │  │  │  ├── kibana-9d69668d4-2rkvz.yaml
       │  │  │  └── kibana-proxy
       │  │  │     └── kibana-proxy
       │  │  │        └── logs
       │  │  │           ├── current.log
       │  │  │           ├── previous.insecure.log
       │  │  │           └── previous.log
       │  └── route.openshift.io
       │     └── routes.yaml
       └── openshift-operators-redhat
          ├── ...
  3. 使用一个或多个 --image--image-stream 参数运行 oc adm must-gather 命令。例如,使用以下命令可收集默认集群数据和 KubeVirt 特定信息:

    $ oc adm must-gather \
     --image-stream=openshift/must-gather \ 1
     --image=quay.io/kubevirt/must-gather 2
    1
    默认 OpenShift Container Platform must-gather 镜像
    2
    KubeVirt 的 must-gather 镜像
  4. 从工作目录中刚刚创建的 must-gather 目录创建一个压缩文件。例如,在使用 Linux 操作系统的计算机上运行以下命令:

    $ tar cvaf must-gather.tar.gz must-gather.local.5421342344627712289/ 1
    1
    务必将 must-gather-local.5421342344627712289/ 替换为实际目录名称。
  5. 红帽客户门户网站的客户支持页面中,将压缩文件附加到您的支持问题单中。