1.健康状态查看
curl -XGET 'http://192.168.1.7:9201/_cat/health?pretty' -H 'Content-Type: application/json'
[esadmin@oracle1 ~]$ curl -XGET 'http://192.168.1.7:9201/_cat/health?pretty' -H 'Content-Type: application/json'
1719475043 07:57:23 escluster1 green 5 4 53 25 0 0 0 0 - 100.0%
2.禁止数据写入
curl -XPUT http://192.168.1.7:9201/_cluster/settings -H 'Content-Type: application/json' -d '{
"transient" : {
"cluster.routing.allocation.enable" : "none"
}
}'
3.分片数据同步
curl http://192.168.1.7:9201/_flush/synced
{
"_shards": {
"total": 53,
"successful": 53,
"failed": 0
},
"xsq-ä½ å¥½": {
"total": 10,
"successful": 10,
"failed": 0
},
"xsq1": {
"total": 10,
"successful": 10,
"failed": 0
},
"xsq3": {
"total": 10,
"successful": 10,
"failed": 0
},
"myindex1": {
"total": 2,
"successful": 2,
"failed": 0
},
"xs1": {
"total": 2,
"successful": 2,
"failed": 0
},
"xsq-index": {
"total": 10,
"successful": 10,
"failed": 0
},
"mydb1": {
"total": 9,
"successful": 9,
"failed": 0
}
}
4.停止Node5
esadmin 3010 2176 6 15:38 pts/0 00:01:21 /esdb/jdk-17.0.11/bin/java
-Xshare:auto -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10
-XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8
-Djna.nosys=true -XX:-OmitStackTraceInFastThrow -XX:+ShowCodeDetailsInExceptionMessages
-Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0 -Dio.netty.allocator.numDirectArenas=0
-Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true
-Djava.locale.providers=SPI,COMPAT -server -Xmx256m -Xms256m -Xmn100m
-Xss228K -XX:+DisableExplicitGC -XX:HeapDumpPath=/esdb/eslog/eslog9205
-XX:ErrorFile=/esdb/eslog/eslog9205/hs_err_pid%p.log
-Xlog:gc*,gc+age=trace,safepoint:file=/esdb/eslog/eslog9205/gc.log:utctime,pid,tags:filecount=32,filesize=64m -XX:+UseG1GC -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30
-Djava.io.tmpdir=/tmp/elasticsearch-5568961552261958455
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data
-XX:ErrorFile=logs/hs_err_pid%p.log -XX:MaxDirectMemorySize=134217728
-Des.path.home=/esdb/esapp/esapp9205 -Des.path.conf=/esdb/esapp/esapp9205/config -Des.distribution.flavor=default -Des.distribution.type=tar -Des.bundled_jdk=true -cp /esdb/esapp/esapp9205/lib/* org.elasticsearch.bootstrap.Elasticsearch
esadmin 3958 3334 0 15:59 pts/1 00:00:00 grep --color=auto elast
[esadmin@oracle1 ~]$ kill -9 3010
*/
5.开启数据平衡
curl -XPUT http://192.168.1.7:9204/_cluster/settings -H 'Content-Type: application/json' -d '{
"transient" : {
"cluster.routing.allocation.enable" : "all"
}
}'
6.检查集群健康状态
--当前是4个节点3个数据节点,状态GREEN,正常。
:"all"}}}}}[esadmin@oracle1 ~]$ curl -XGET 'http://192.168.1.7:9201/_cat/health?pretty' -H 'Co application/json'
1719475304 08:01:44 escluster1 green 4 3 53 25 0 0 0 0 - 100.0%
7.数据分片查看
[esadmin@oracle1 ~]$ curl http://192.168.1.7:9201/_cat/shards?v
index shard prirep state docs store ip node
xsq3 4 p STARTED 1 6.5kb 192.168.1.7 esdb-node-3
xsq3 4 r STARTED 1 6.5kb 192.168.1.7 esdb-node-1
xsq3 3 r STARTED 2 6.8kb 192.168.1.7 esdb-node-3
xsq3 3 p STARTED 2 6.8kb 192.168.1.7 esdb-node-1
xsq3 2 p STARTED 3 7kb 192.168.1.7 esdb-node-2
xsq3 2 r STARTED 3 7kb 192.168.1.7 esdb-node-1
xsq3 1 p STARTED 1 6.6kb 192.168.1.7 esdb-node-3
xsq3 1 r STARTED 1 6.6kb 192.168.1.7 esdb-node-2
xsq3 0 p STARTED 4 7.3kb 192.168.1.7 esdb-node-3
xsq3 0 r STARTED 4 7.3kb 192.168.1.7 esdb-node-2
mydb1 2 r STARTED 1 5.6kb 192.168.1.7 esdb-node-3
--由此可见,node5已经下线,且其上的数据已经均为分不到node1/2/3;