第 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-rhel9:v4.19.6
    Copy to Clipboard Toggle word wrap
    • 要收集审计日志,请使用 -- /usr/bin/gather_audit_logs 参数,如以下部分所述。

      例如:

      $ oc adm must-gather -- /usr/bin/gather_audit_logs
      Copy to Clipboard Toggle word wrap
      注意
      • 作为默认信息集合的一部分,不会收集审计日志来减小文件的大小。
      • 在 Windows 操作系统上,安装 cwRsync 客户端,并添加到 PATH 变量中,以便与 oc rsync 命令一起使用。

当您运行 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
...
Copy to Clipboard Toggle word wrap

另外,您可以使用 --run-namespace 选项在特定命名空间中运行 oc adm must-gather 命令。

例如:

$ oc adm must-gather --run-namespace <namespace> \
  --image=registry.redhat.io/container-native-virtualization/cnv-must-gather-rhel9:v4.19.6
Copy to Clipboard Toggle word wrap

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

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

先决条件

  • 您可以使用具有 cluster-admin 角色的用户访问集群。

    注意

    在 OpenShift Dedicated 部署中,不使用客户云订阅(CCS)模型的用户无法使用 oc adm must-gather 命令,因为它需要 cluster-admin 权限。

  • 已安装 OpenShift CLI (oc)。

流程

  1. 进入要存储 must-gather 数据的目录。
  2. 运行 oc adm must-gather 命令:

    $ oc adm must-gather
    Copy to Clipboard Toggle word wrap
    注意

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

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

      注意

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

  3. 从工作目录中刚刚创建的 must-gather 目录创建一个压缩文件。确保为唯一的 must-gather 数据提供日期和集群 ID。有关如何查找集群 ID 的更多信息,请参阅如何在 OpenShift 集群上找到 cluster-id 或名称。例如,在使用 Linux 操作系统的计算机上运行以下命令:

    $ tar cvaf must-gather-`date +"%m-%d-%Y-%H-%M-%S"`-<cluster_id>.tar.gz <must_gather_local_dir> 
    1
    Copy to Clipboard Toggle word wrap
    1
    <must_gather_local_dir> 替换为实际目录名称。
  4. 红帽客户门户网站的客户支持页面中,将压缩文件附加到您的支持问题单中。

5.1.2. must-gather 标记

下表中列出的标记可用于 oc adm must-gather 命令。

Expand
表 5.1. oc adm must-gather的 OpenShift Dedicated 标志
标记示例命令描述

--all-images

oc adm must-gather --all-images=false

为集群中带有 operators.openshift.io/must-gather-image 注解的所有 Operator 使用默认镜像收集 must-gather 数据。

--dest-dir

oc adm must-gather --dest-dir='<directory_name>'

在保存收集数据的本地机器上设置一个特定的目录。

--host-network

oc adm must-gather --host-network=false

运行 must-gather pod 作为 hostNetwork: true。如果特定命令和镜像需要捕获主机级数据,则相关。

--image

oc adm must-gather --image=[<plugin_image>]

指定要运行的 must-gather 插件镜像。如果没有指定,则使用 OpenShift Dedicated 的默认 must-gather 镜像。

--image-stream

oc adm must-gather --image-stream=[<image_stream>]

指定一个`<image_stream>`,使用一个命名空间或 namespace or name:tag 值包括一个 must-gather 插件来运行。

--node-name

oc adm must-gather --node-name='<node>'

设置要使用的特定节点。如果没有指定,则默认使用一个随机的 master。

--node-selector

oc adm must-gather --node-selector='<node_selector_name>'

设置要使用的一个特定节点选择器。仅在指定需要同时捕获一组集群节点上的数据的命令和镜像时才相关。

--run-namespace

oc adm must-gather --run-namespace='<namespace>'

must-gather pod 应在其中运行的一个现有的特权命名空间。如果没有指定,会生成一个临时命名空间。

--since

oc adm must-gather --since=<time>

仅返回比指定持续时间更新的日志。默认为所有日志。为了支持这个功能,推荐使用插件,但这并不是必须的。只能使用 since-timesince 之一。

--since-time

oc adm must-gather --since-time='<date_and_time>'

仅在特定日期和时间后返回日志,以(RFC3339)格式表示。默认为所有日志。为了支持这个功能,推荐使用插件,但这并不是必须的。只能使用 since-timesince 之一。

--source-dir

oc adm must-gather --source-dir='/<directory_name>/'

指定您要从其中复制收集的数据的 pod 中的一个特定目录。

--timeout

oc adm must-gather --timeout='<time>'

在超时前收集数据的时间长度,以秒、分钟或小时表示,如 3s、5m 或 2h。指定的时间必须大于零。如果没有指定,则默认为 10 分钟。

--volume-percentage

oc adm must-gather --volume-percentage=<percent>

指定可用于 must-gather 的 pod 分配卷的最大百分比。如果超过这个限制,must-gather 会停止收集,但仍复制收集的数据。如果没有指定,则默认为 30%。

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

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

Expand
表 5.2. 支持的 must-gather 镜像
Image用途

registry.redhat.io/container-native-virtualization/cnv-must-gather-rhel9:v4.19.6

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/multicluster-engine/must-gather-rhel8

托管 control plane 的数据收集。

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

MTC 的数据收集。

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

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

quay.io/netobserv/must-gather

Network Observability Operator 的数据收集。

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

Red Hat OpenShift GitOps 的数据收集。

registry.redhat.io/openshift4/ose-secrets-store-csi-mustgather-rhel9:v<installed_version_secret_store>

Secret Store CSI Driver Operator 的数据收集。

注意

要确定 OpenShift Dedicated 组件镜像的最新版本,请参阅红帽客户门户网站中的 OpenShift Operator 生命周期 网页。

先决条件

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

流程

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

    注意
    • 要收集除特定功能数据外的默认 must-gather 数据,请添加 --image-stream=openshift/must-gather 参数。

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

    $ oc adm must-gather \
      --image-stream=openshift/must-gather \ 
    1
    
      --image=registry.redhat.io/container-native-virtualization/cnv-must-gather-rhel9:v4.19.6 
    2
    Copy to Clipboard Toggle word wrap
    1
    默认 OpenShift Dedicated must-gather 镜像
    2
    OpenShift Virtualization 的 must-gather 镜像

    您可以将 must-gather 工具与额外参数搭配使用,以收集集群中与 OpenShift Logging 和 Cluster 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}')
    Copy to Clipboard Toggle word wrap

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

    ├── cluster-logging
    │  ├── clo
    │  │  ├── cluster-logging-operator-74dd5994f-6ttgt
    │  │  ├── clusterlogforwarder_cr
    │  │  ├── cr
    │  │  ├── csv
    │  │  ├── deployment
    │  │  └── logforwarding_cr
    │  ├── collector
    │  │  ├── fluentd-2tr64
    │  ├── curator
    │  │  └── curator-1596028500-zkz4s
    │  ├── 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
       │  │  │  ├── curator-1596021300-wn2ks.162634ebf0055a94.yaml
       │  │  │  ├── curator.162638330681bee2.yaml
       │  │  │  ├── elasticsearch-delete-app-1596020400-gm6nl.1626341a296c16a1.yaml
       │  │  │  ├── elasticsearch-delete-audit-1596020400-9l9n4.1626341a2af81bbd.yaml
       │  │  │  ├── elasticsearch-delete-infra-1596020400-v98tk.1626341a2d821069.yaml
       │  │  │  ├── elasticsearch-rollover-app-1596020400-cc5vc.1626341a3019b238.yaml
       │  │  │  ├── elasticsearch-rollover-audit-1596020400-s8d5s.1626341a31f7b315.yaml
       │  │  │  ├── elasticsearch-rollover-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
       │  │  ├── curator-1596028500-zkz4s
       │  │  ├── elasticsearch-cdm-lp8l38m0-1-794d6dd989-4jxms
       │  │  ├── elasticsearch-delete-app-1596030300-bpgcx
       │  │  │  ├── elasticsearch-delete-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
          ├── ...
    Copy to Clipboard Toggle word wrap
  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
    Copy to Clipboard Toggle word wrap
    1
    默认 OpenShift Dedicated must-gather 镜像
    2
    KubeVirt 的 must-gather 镜像
  4. 从工作目录中刚刚创建的 must-gather 目录创建一个压缩文件。确保为唯一的 must-gather 数据提供日期和集群 ID。有关如何查找集群 ID 的更多信息,请参阅如何在 OpenShift 集群上找到 cluster-id 或名称。例如,在使用 Linux 操作系统的计算机上运行以下命令:

    $ tar cvaf must-gather-`date +"%m-%d-%Y-%H-%M-%S"`-<cluster_id>.tar.gz <must_gather_local_dir> 
    1
    Copy to Clipboard Toggle word wrap
    1
    <must_gather_local_dir> 替换为实际目录名称。
  5. 红帽客户门户网站的客户支持页面中,将压缩文件附加到您的支持问题单中。

5.1.4. 收集网络日志

您可以在集群中的所有节点上收集网络日志。

流程

  1. 使用 -- gather_network_logs 运行 oc adm must-gather 命令:

    $ oc adm must-gather -- gather_network_logs
    Copy to Clipboard Toggle word wrap
    注意

    默认情况下,must-gather 工具从集群中的所有节点收集 OVN nbdbsbdb 数据库。添加 -- gather_network_logs 选项,使其包含包含 OVN nbdb 数据库的 OVN-Kubernetes 事务的额外日志。

  2. 从工作目录中刚刚创建的 must-gather 目录创建一个压缩文件。确保为唯一的 must-gather 数据提供日期和集群 ID。有关如何查找集群 ID 的更多信息,请参阅如何在 OpenShift 集群上找到 cluster-id 或名称。例如,在使用 Linux 操作系统的计算机上运行以下命令:

    $ tar cvaf must-gather-`date +"%m-%d-%Y-%H-%M-%S"`-<cluster_id>.tar.gz <must_gather_local_dir>
    1
    Copy to Clipboard Toggle word wrap
    1
    <must_gather_local_dir> 替换为实际目录名称。
  3. 红帽客户门户网站的客户支持页面中,将压缩文件附加到您的支持问题单中。

5.1.5. 更改 must-gather 存储限制

当使用 oc adm must-gather 命令收集数据时,信息的默认最大存储是容器的存储容量的 30%。达到 30% 限值后,容器被终止,收集过程将停止。收集到的信息会下载到您的本地存储中。要再次运行 must-gather 命令,您需要一个具有更多存储容量的容器,或者调整最大卷百分比。

如果容器达到存储限制,则生成类似以下示例的错误消息。

输出示例

Disk usage exceeds the volume percentage of 30% for mounted directory. Exiting...
Copy to Clipboard Toggle word wrap

先决条件

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

流程

  • 使用 volume-percentage 标志运行 oc adm must-gather 命令。新值不能超过 100。

    $ oc adm must-gather --volume-percentage <storage_percentage>
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat