10.2. 查看日志存储的状态

您可以查看 OpenShift Elasticsearch Operator 的状态以及多个 Elasticsearch 组件的状态。

10.2.1. 查看日志存储的状态

您可以查看日志存储的状态。

先决条件

  • 必须安装 Cluster Logging 和 Elasticsearch。

流程

  1. 进入 openshift-logging 项目。

    $ oc project openshift-logging
  2. 查看状态:

    1. 获取日志存储实例的名称:

      $ oc get Elasticsearch

      输出示例

      NAME            AGE
      elasticsearch   5h9m

    2. 获取日志存储状态:

      $ oc get Elasticsearch <Elasticsearch-instance> -o yaml

      例如:

      $ oc get Elasticsearch elasticsearch -n openshift-logging -o yaml

      输出中包含类似于如下的信息:

      输出示例

      status: 1
        cluster: 2
          activePrimaryShards: 30
          activeShards: 60
          initializingShards: 0
          numDataNodes: 3
          numNodes: 3
          pendingTasks: 0
          relocatingShards: 0
          status: green
          unassignedShards: 0
        clusterHealth: ""
        conditions: [] 3
        nodes: 4
        - deploymentName: elasticsearch-cdm-zjf34ved-1
          upgradeStatus: {}
        - deploymentName: elasticsearch-cdm-zjf34ved-2
          upgradeStatus: {}
        - deploymentName: elasticsearch-cdm-zjf34ved-3
          upgradeStatus: {}
        pods: 5
          client:
            failed: []
            notReady: []
            ready:
            - elasticsearch-cdm-zjf34ved-1-6d7fbf844f-sn422
            - elasticsearch-cdm-zjf34ved-2-dfbd988bc-qkzjz
            - elasticsearch-cdm-zjf34ved-3-c8f566f7c-t7zkt
          data:
            failed: []
            notReady: []
            ready:
            - elasticsearch-cdm-zjf34ved-1-6d7fbf844f-sn422
            - elasticsearch-cdm-zjf34ved-2-dfbd988bc-qkzjz
            - elasticsearch-cdm-zjf34ved-3-c8f566f7c-t7zkt
          master:
            failed: []
            notReady: []
            ready:
            - elasticsearch-cdm-zjf34ved-1-6d7fbf844f-sn422
            - elasticsearch-cdm-zjf34ved-2-dfbd988bc-qkzjz
            - elasticsearch-cdm-zjf34ved-3-c8f566f7c-t7zkt
        shardAllocationEnabled: all

      1
      在输出中,集群状态字段显示在 status 小节中。
      2
      日志存储的状态:
      • 活跃的主分片的数量。
      • 活跃分片的数量。
      • 正在初始化的分片的数量。
      • 保存数据节点的日志数量。
      • 日志存储节点的总数。
      • 待处理的任务数量。
      • 日志存储状态: greenredyellow
      • 未分配分片的数量。
      3
      任何状态条件(若存在)。日志存储态代表了当无法放置容器时来自于调度程序的原因。显示与以下情况有关的所有事件:
      • 容器正在等待日志存储和代理容器。
      • 日志存储和代理容器的容器终止。
      • Pod 不可调度。此外还显示适用于多个问题的情况,具体请参阅情况消息示例
      4
      集群中的日志存储节点,带有 upgradeStatus
      5
      集群中的日志存储客户端、数据和 master 节点,列在 failed、notReadyready 状态下。

10.2.1.1. 情况消息示例

以下是来自 Elasticsearch 实例的 Status 部分的一些情况消息的示例。

此状态消息表示节点已超过配置的低水位线,并且没有分片将分配给此节点。

status:
  nodes:
  - conditions:
    - lastTransitionTime: 2019-03-15T15:57:22Z
      message: Disk storage usage for node is 27.5gb (36.74%). Shards will be not
        be allocated on this node.
      reason: Disk Watermark Low
      status: "True"
      type: NodeStorage
    deploymentName: example-elasticsearch-cdm-0-1
    upgradeStatus: {}

此状态消息表示节点已超过配置的高水位线,并且分片将重新定位到其他节点。

status:
  nodes:
  - conditions:
    - lastTransitionTime: 2019-03-15T16:04:45Z
      message: Disk storage usage for node is 27.5gb (36.74%). Shards will be relocated
        from this node.
      reason: Disk Watermark High
      status: "True"
      type: NodeStorage
    deploymentName: example-elasticsearch-cdm-0-1
    upgradeStatus: {}

此状态消息表示 CR 中的日志存储节点选择器与集群中的任何节点都不匹配:

status:
    nodes:
    - conditions:
      - lastTransitionTime: 2019-04-10T02:26:24Z
        message: '0/8 nodes are available: 8 node(s) didn''t match node selector.'
        reason: Unschedulable
        status: "True"
        type: Unschedulable

此状态消息表示日志存储 CR 使用了不存在的 PVC。

status:
   nodes:
   - conditions:
     - last Transition Time:  2019-04-10T05:55:51Z
       message:               pod has unbound immediate PersistentVolumeClaims (repeated 5 times)
       reason:                Unschedulable
       status:                True
       type:                  Unschedulable

此状态消息表示日志存储集群没有足够的节点来支持日志存储的冗余策略。

status:
  clusterHealth: ""
  conditions:
  - lastTransitionTime: 2019-04-17T20:01:31Z
    message: Wrong RedundancyPolicy selected. Choose different RedundancyPolicy or
      add more nodes with data roles
    reason: Invalid Settings
    status: "True"
    type: InvalidRedundancy

此状态消息表示集群有太多 control plane 节点(也称为 master 节点):

status:
  clusterHealth: green
  conditions:
    - lastTransitionTime: '2019-04-17T20:12:34Z'
      message: >-
        Invalid master nodes count. Please ensure there are no more than 3 total
        nodes with master roles
      reason: Invalid Settings
      status: 'True'
      type: InvalidMasters