26.3. 检查 Kafka 重启
使用 oc
命令列出 Cluster Operator 启动的重启事件。使用 reportingController
或 source
事件字段将 Cluster Operator 设置为报告组件来过滤 Cluster Operator 发出的重启事件。
先决条件
- Cluster Operator 在 OpenShift 集群中运行。
流程
获取 Cluster Operator 发出的所有重启事件:
oc -n kafka get events --field-selector reportingController=strimzi.io/cluster-operator
oc -n kafka get events --field-selector reportingController=strimzi.io/cluster-operator
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 显示返回的事件示例
LAST SEEN TYPE REASON OBJECT MESSAGE 2m Normal CaCertRenewed pod/strimzi-cluster-kafka-0 CA certificate renewed 58m Normal PodForceRestartOnError pod/strimzi-cluster-kafka-1 Pod needs to be forcibly restarted due to an error 5m47s Normal ManualRollingUpdate pod/strimzi-cluster-kafka-2 Pod was manually annotated to be rolled
LAST SEEN TYPE REASON OBJECT MESSAGE 2m Normal CaCertRenewed pod/strimzi-cluster-kafka-0 CA certificate renewed 58m Normal PodForceRestartOnError pod/strimzi-cluster-kafka-1 Pod needs to be forcibly restarted due to an error 5m47s Normal ManualRollingUpdate pod/strimzi-cluster-kafka-2 Pod was manually annotated to be rolled
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 您还可以指定
reason
或其他field-selector
选项来限制返回的事件。在这里,添加了具体原因:
oc -n kafka get events --field-selector reportingController=strimzi.io/cluster-operator,reason=PodForceRestartOnError
oc -n kafka get events --field-selector reportingController=strimzi.io/cluster-operator,reason=PodForceRestartOnError
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 使用 YAML 等输出格式返回有关一个或多个事件的更多详细信息。
oc -n kafka get events --field-selector reportingController=strimzi.io/cluster-operator,reason=PodForceRestartOnError -o yaml
oc -n kafka get events --field-selector reportingController=strimzi.io/cluster-operator,reason=PodForceRestartOnError -o yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 显示详细事件输出示例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
以下字段已弃用,因此这些事件不会填充它们:
-
firstTimestamp
-
lastTimestamp
-
source