This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.4.3.8. 执行 Elasticsearch 集群滚动重启
在更改 elasticsearch
配置映射或任何 elasticsearch-*
部署配置时,执行滚动重启。
此外,如果运行 Elasticsearch Pod 的节点需要重启,则建议滚动重启。
先决条件
- 必须安装 OpenShift Logging 和 Elasticsearch。
流程
执行集群滚动重启:
进入
openshift-logging
项目:oc project openshift-logging
$ oc project openshift-logging
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 获取 Elasticsearch Pod 的名称:
oc get pods | grep elasticsearch-
$ oc get pods | grep elasticsearch-
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 缩减 Fluentd pod,以便它们停止向 Elasticsearch 发送新日志:
oc -n openshift-logging patch daemonset/logging-fluentd -p '{"spec":{"template":{"spec":{"nodeSelector":{"logging-infra-fluentd": "false"}}}}}'
$ oc -n openshift-logging patch daemonset/logging-fluentd -p '{"spec":{"template":{"spec":{"nodeSelector":{"logging-infra-fluentd": "false"}}}}}'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 使用 OpenShift Container Platform es_util 工具执行分片同步刷新,确保在关机之前没有等待写入磁盘的待定操作:
oc exec <any_es_pod_in_the_cluster> -c elasticsearch -- es_util --query="_flush/synced" -XPOST
$ oc exec <any_es_pod_in_the_cluster> -c elasticsearch -- es_util --query="_flush/synced" -XPOST
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 例如:
oc exec -c elasticsearch-cdm-5ceex6ts-1-dcd6c4c7c-jpw6 -c elasticsearch -- es_util --query="_flush/synced" -XPOST
$ oc exec -c elasticsearch-cdm-5ceex6ts-1-dcd6c4c7c-jpw6 -c elasticsearch -- es_util --query="_flush/synced" -XPOST
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
{"_shards":{"total":4,"successful":4,"failed":0},".security":{"total":2,"successful":2,"failed":0},".kibana_1":{"total":2,"successful":2,"failed":0}}
{"_shards":{"total":4,"successful":4,"failed":0},".security":{"total":2,"successful":2,"failed":0},".kibana_1":{"total":2,"successful":2,"failed":0}}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 使用 OpenShift Container Platform es_util 工具防止在有意关闭节点时进行分片平衡:
oc exec <any_es_pod_in_the_cluster> -c elasticsearch -- es_util --query="_cluster/settings" -XPUT -d '{ "persistent": { "cluster.routing.allocation.enable" : "primaries" } }'
$ oc exec <any_es_pod_in_the_cluster> -c elasticsearch -- es_util --query="_cluster/settings" -XPUT -d '{ "persistent": { "cluster.routing.allocation.enable" : "primaries" } }'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 例如:
oc exec elasticsearch-cdm-5ceex6ts-1-dcd6c4c7c-jpw6 -c elasticsearch -- es_util --query="_cluster/settings" -XPUT -d '{ "persistent": { "cluster.routing.allocation.enable" : "primaries" } }'
$ oc exec elasticsearch-cdm-5ceex6ts-1-dcd6c4c7c-jpw6 -c elasticsearch -- es_util --query="_cluster/settings" -XPUT -d '{ "persistent": { "cluster.routing.allocation.enable" : "primaries" } }'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
{"acknowledged":true,"persistent":{"cluster":{"routing":{"allocation":{"enable":"primaries"}}}},"transient":
{"acknowledged":true,"persistent":{"cluster":{"routing":{"allocation":{"enable":"primaries"}}}},"transient":
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 完成后,会在每个部署中都有一个 ES 集群:
默认情况下,OpenShift Container Platform Elasticsearch 集群会阻止向其节点推出部署。使用以下命令来允许推出部署并允许 Pod 获取更改:
oc rollout resume deployment/<deployment-name>
$ oc rollout resume deployment/<deployment-name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 例如:
oc rollout resume deployment/elasticsearch-cdm-0-1
$ oc rollout resume deployment/elasticsearch-cdm-0-1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
deployment.extensions/elasticsearch-cdm-0-1 resumed
deployment.extensions/elasticsearch-cdm-0-1 resumed
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 部署了一个新 Pod。当 Pod 具有就绪的容器后,就能继续进行下一部署。
oc get pods | grep elasticsearch-
$ oc get pods | grep elasticsearch-
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
NAME READY STATUS RESTARTS AGE elasticsearch-cdm-5ceex6ts-1-dcd6c4c7c-jpw6k 2/2 Running 0 22h elasticsearch-cdm-5ceex6ts-2-f799564cb-l9mj7 2/2 Running 0 22h elasticsearch-cdm-5ceex6ts-3-585968dc68-k7kjr 2/2 Running 0 22h
NAME READY STATUS RESTARTS AGE elasticsearch-cdm-5ceex6ts-1-dcd6c4c7c-jpw6k 2/2 Running 0 22h elasticsearch-cdm-5ceex6ts-2-f799564cb-l9mj7 2/2 Running 0 22h elasticsearch-cdm-5ceex6ts-3-585968dc68-k7kjr 2/2 Running 0 22h
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 部署完成后,重置 Pod 以禁止推出部署:
oc rollout pause deployment/<deployment-name>
$ oc rollout pause deployment/<deployment-name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 例如:
oc rollout pause deployment/elasticsearch-cdm-0-1
$ oc rollout pause deployment/elasticsearch-cdm-0-1
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
deployment.extensions/elasticsearch-cdm-0-1 paused
deployment.extensions/elasticsearch-cdm-0-1 paused
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 检查 Elasticsearch 集群是否处于
green
或yellow
状态:oc exec <any_es_pod_in_the_cluster> -c elasticsearch -- es_util --query=_cluster/health?pretty=true
$ oc exec <any_es_pod_in_the_cluster> -c elasticsearch -- es_util --query=_cluster/health?pretty=true
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 注意如果您对先前命令中使用的 Elasticsearch Pod 执行了推出部署,该 Pod 将不再存在,并且此处需要使用新的 Pod 名称。
例如:
oc exec elasticsearch-cdm-5ceex6ts-1-dcd6c4c7c-jpw6 -c elasticsearch -- es_util --query=_cluster/health?pretty=true
$ oc exec elasticsearch-cdm-5ceex6ts-1-dcd6c4c7c-jpw6 -c elasticsearch -- es_util --query=_cluster/health?pretty=true
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- 在继续操作前,请确保此参数值为
green
或者yellow
。
- 如果更改了 Elasticsearch 配置映射,请对每个 Elasticsearch Pod 重复这些步骤。
推出集群的所有部署后,重新启用分片平衡:
oc exec <any_es_pod_in_the_cluster> -c elasticsearch -- es_util --query="_cluster/settings" -XPUT -d '{ "persistent": { "cluster.routing.allocation.enable" : "all" } }'
$ oc exec <any_es_pod_in_the_cluster> -c elasticsearch -- es_util --query="_cluster/settings" -XPUT -d '{ "persistent": { "cluster.routing.allocation.enable" : "all" } }'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 例如:
oc exec elasticsearch-cdm-5ceex6ts-1-dcd6c4c7c-jpw6 -c elasticsearch -- es_util --query="_cluster/settings" -XPUT -d '{ "persistent": { "cluster.routing.allocation.enable" : "all" } }'
$ oc exec elasticsearch-cdm-5ceex6ts-1-dcd6c4c7c-jpw6 -c elasticsearch -- es_util --query="_cluster/settings" -XPUT -d '{ "persistent": { "cluster.routing.allocation.enable" : "all" } }'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输出示例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 扩展 Fluentd Pod,以便它们向 Elasticsearch 发送新日志。
oc -n openshift-logging patch daemonset/logging-fluentd -p '{"spec":{"template":{"spec":{"nodeSelector":{"logging-infra-fluentd": "true"}}}}}'
$ oc -n openshift-logging patch daemonset/logging-fluentd -p '{"spec":{"template":{"spec":{"nodeSelector":{"logging-infra-fluentd": "true"}}}}}'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow