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.第 11 章 手动滚动部署 Elasticsearch
OpenShift Container Platform 支持 Elasticsearch 集群滚动重启。滚动重启可以在不需要 Elasticsearch 集群下线的情况下,将适用的更改应用到 Elasticsearch 集群(这需要已配置了三个 master)。Elasticsearch 集群保持联机和可运行状态,节点则逐一脱机。
11.1. 执行 Elasticsearch 集群滚动重启
				在更改 elasticsearch ConfigMap 或任何 elasticsearch-* 部署配置时,执行滚动重启。
			
此外,如果运行 Elasticsearch Pod 的节点需要重启,则建议滚动重启。
前提条件
- 必须安装 Cluster Logging 和 Elasticsearch。
流程
执行集群滚动重启:
- 进入 - openshift-logging项目:- oc project openshift-logging - $ oc project openshift-logging- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- 使用以下命令,从 Elasticsearch 提取 CA 证书并写入到 admin-ca 文件: - oc extract secret/elasticsearch --to=. --keys=admin-ca - $ oc extract secret/elasticsearch --to=. --keys=admin-ca admin-ca- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- 执行分片同步刷新,确保在关机之前没有等待写入磁盘的待定操作: - oc exec <any_es_pod_in_the_cluster> -c elasticsearch -- curl -s --cacert /etc/elasticsearch/secret/admin-ca --cert /etc/elasticsearch/secret/admin-cert --key /etc/elasticsearch/secret/admin-key -XPOST 'https://localhost:9200/_flush/synced' - $ oc exec <any_es_pod_in_the_cluster> -c elasticsearch -- curl -s --cacert /etc/elasticsearch/secret/admin-ca --cert /etc/elasticsearch/secret/admin-cert --key /etc/elasticsearch/secret/admin-key -XPOST 'https://localhost:9200/_flush/synced'- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 例如: - oc exec -c elasticsearch-cdm-5ceex6ts-1-dcd6c4c7c-jpw6 -- curl -s --cacert /etc/elasticsearch/secret/admin-ca --cert /etc/elasticsearch/secret/admin-cert --key /etc/elasticsearch/secret/admin-key -XPOST 'https://localhost:9200/_flush/synced' - $ oc exec -c elasticsearch-cdm-5ceex6ts-1-dcd6c4c7c-jpw6 -- curl -s --cacert /etc/elasticsearch/secret/admin-ca --cert /etc/elasticsearch/secret/admin-cert --key /etc/elasticsearch/secret/admin-key -XPOST 'https://localhost:9200/_flush/synced'- 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 'https://localhost:9200/_cluster/settings' -d '{ "transient": { "cluster.routing.allocation.enable" : "none" } }'- $ oc exec <any_es_pod_in_the_cluster> -c elasticsearch -- es_util --query=_cluster/settings -XPUT 'https://localhost:9200/_cluster/settings' -d '{ "transient": { "cluster.routing.allocation.enable" : "none" } }'- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 例如: - 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 deployment.extensions/elasticsearch-cdm-0-1 resumed- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 部署了一个新 Pod。当 Pod 具有就绪的容器后,就能继续进行下一部署。 - 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 deployment.extensions/elasticsearch-cdm-0-1 paused- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- 检查 Elasticsearch 集群是否处于 - green状态:- 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 名称。 - 例如: - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- 在继续操作之前,请确保此参数为green。
 
 
- 如果更改了 Elasticsearch 配置映射,请对每个 Elasticsearch Pod 重复这些步骤。
- 推出集群的所有部署后,重新启用分片平衡: - oc exec <any_es_pod_in_the_cluster> -c elasticsearch -- es_util --query=_cluster/settings -XPUT 'https://localhost:9200/_cluster/settings' -d '{ "transient": { "cluster.routing.allocation.enable" : "none" } }'- $ oc exec <any_es_pod_in_the_cluster> -c elasticsearch -- es_util --query=_cluster/settings -XPUT 'https://localhost:9200/_cluster/settings' -d '{ "transient": { "cluster.routing.allocation.enable" : "none" } }'- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 例如: - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow