19.3. 检查 Kafka 重启
使用 oc 命令列出 Cluster Operator 启动的重启事件。通过使用 reportingController 或 源 事件字段将 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-operatorCopy 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 rolledCopy 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=PodForceRestartOnErrorCopy 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 yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow 显示详细事件输出的示例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
以下字段已弃用,因此不会为这些事件填充它们:
-
firstTimestamp -
lastTimestamp -
source