用docker镜像部署的es,更换了镜像里的log4j包,整个集群更换镜像的步骤。
根据es的版本选择不同的官方指导:
https://www.elastic.co/guide/en/elasticsearch/reference/6.4/setup-upgrade.html
如果升级版本,要考虑原来的索引是否可用,但本次操作无需考虑。
要点如下:
0)备份
如果没有快照仓库,需要创建一个
# PUT /_snapshot/my_backup/
curl -X PUT “localhost:9200/_snapshot/my_backup/%3Csnapshot-%7Bnow%2Fd%7D%3E?pretty”
参考:https://www.elastic.co/guide/en/elasticsearch/reference/6.4/modules-snapshots.html
0)观察集群状态
1)集群停止分片
2)节点升级
a)内存写入磁盘
b)停节点服务
c)更换文件或镜像
d)起服务
e)观察节点状态
f)升下一个节点
3)观察集群状态和测试业务
参考:
https://www.cnblogs.com/bonelee/p/7443823.html
https://www.jianshu.com/p/252d97a94200
https://www.cnblogs.com/powerwu/articles/12034098.html
https://www.jianshu.com/p/9752709bfea4
https://www.cnblogs.com/bonelee/p/7285878.html
观察集群状态
curl -XGET "http://127.0.0.1:9200/_cluster/health?pretty=true"{"cluster_name" : "xxx","status" : "green","timed_out" : false,"number_of_nodes" : 3,"number_of_data_nodes" : 3,"active_primary_shards" : 20,"active_shards" : 40,"relocating_shards" : 0,"initializing_shards" : 0,"unassigned_shards" : 0,"delayed_unassigned_shards" : 0,"number_of_pending_tasks" : 0,"number_of_in_flight_fetch" : 0,"task_max_waiting_in_queue_millis" : 0,"active_shards_percent_as_number" : 100.0}#or curl -XGET http://localhost:9200/_cluster/health?pretty#状态:curl -XGET "http://127.0.0.1:9200/_cluster/stats?pretty=true"……太多,略
1)集群停止分片和重新平衡
curl -H "Content-Type:application/json" -XPOST 'http://localhost:9200/_cluster/settings' -d '{"transient": {"cluster.routing.allocation.enable": "none","cluster.routing.rebalance.enable": "none"}}'
2)节点升级
a)内存写入磁盘
curl -XGET 'http://localhost:9200/_nodes/flush/synced'
有时候会出错,再次执行又成功了。
curl: (56) Recv failure: Connection reset by peer
延迟响应
curl -H Content-Type:application/json -XPUT http://localhost:9200/_all/_settings -d '{ "settings": { "index.unassigned.node_left.delayed_timeout": "5m" } }'提示:{"acknowledged":true}
b)停节点服务
curl -XPOST http://localhost:9200/_cluster/nodes/_local/_shutdown
c)更换文件或镜像
d)起服务
e)观察节点状态
curl -XGET http://localhost:9200/_nodes/process?pretty
f)升下一个节点
3)恢复设置
curl -H "Content-Type:application/json" -XPOST 'http://localhost:9200/_cluster/settings' -d '{"transient": {"cluster.routing.allocation.enable": "all","cluster.routing.rebalance.enable": "all"}}
4)观察集群状态和测试业务
可能的报错和处理:
x-www-form-urlencoded is not supported
curl时加上-H “Content-Type:application/json”
其他一些查询:
curl -XGET http://localhost:9200/_cat=^.^=/_cat/allocation/_cat/shards/_cat/shards/{index}/_cat/master/_cat/nodes/_cat/tasks/_cat/indices/_cat/indices/{index}/_cat/segments/_cat/segments/{index}/_cat/count/_cat/count/{index}/_cat/recovery/_cat/recovery/{index}/_cat/health/_cat/pending_tasks/_cat/aliases/_cat/aliases/{alias}/_cat/thread_pool/_cat/thread_pool/{thread_pools}/_cat/plugins/_cat/fielddata/_cat/fielddata/{fields}/_cat/nodeattrs/_cat/repositories/_cat/snapshots/{repository}/_cat/templates
