Openshift中集群ElasticSearch的运维
大家都知道,Openshift集成了EFK(Elasticsearch + Fluentd + Kibana)作为集群的日志管理平台。我们该怎样去维护ElasticSearch.
- 找到ES所在的pod
plaintext
1 | oc get pod -l component=es -o name -n logging | cut -d/ -f2 |
- 查看所有ES索引
plaintext
1 | oc exec $es-pod-name -- curl -s --cert /etc/elasticsearch/secret/admin-cert --key /etc/elasticsearch/secret/admin-key --cacert /etc/elasticsearch/secret/admin-ca https://localhost:9200/_cat/indices?v |
- 清理所有3月份的ES索引
plaintext
1 | oc exec $es-pod-name -- curl -s --cert /etc/elasticsearch/secret/admin-cert --key /etc/elasticsearch/secret/admin-key --cacert /etc/elasticsearch/secret/admin-ca -XDELETE https://localhost:9200/*.2018.03.* |
curl可以加-k这样就不需要--cacert参数
- 打开Kibana,显示错误
Elasticsearch is still initializing the kibana index
解决办法:删除kibana的索引,重新进入kibana
plaintext
1 | oc exec $es-pod-name -- curl -s --cert /etc/elasticsearch/secret/admin-cert --key /etc/elasticsearch/secret/admin-key --cacert /etc/elasticsearch/secret/admin-ca -XDELETE https://localhost:9200/.kibana |
- 确认ES集群的工作状态
plaintext
1 | $ oc exec $es-pod-name -c elasticsearch -- health |
- 停止ES节点分片平衡
plaintext
1 | $ oc exec $es-pod-name -c elasticsearch -- curl --cert /etc/elasticsearch/secret/admin-cert --key /etc/elasticsearch/secret/admin-key --cacert /etc/elasticsearch/secret/admin-ca -XPUT https://localhost:9200/_cluster/settings -d '{"transient": {"cluster.routing.allocation.enable":"none"}}' |
6.开启ES节点分片平衡
plaintext
1 | $ oc exec $es-pod-name -c elasticsearch -- curl --cert /etc/elasticsearch/secret/admin-cert --key /etc/elasticsearch/secret/admin-key --cacert /etc/elasticsearch/secret/admin-ca -XPUT https://localhost:9200/_cluster/settings -d '{"transient": {"cluster.routing.allocation.enable":"all"}}' |
- ES扩容
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Michael Blog!
评论
未找到相关的 Issues 进行评论
请联系 @xhuaustc 初始化创建