重置备份


curl -XPUT "http://localhost:9200/_settings" -d'

{

"number_of_replicas" : 2

}'


2.安全关闭

curl -XPUThttp://localhost:9200/_cluster/settings -d'

{

"transient" : {

"cluster.routing.allocation.enable" : "none"

}

}'




curl -XPUT http://localhost:9200/_cluster/settings -d'

{

"transient" : {

"cluster.routing.allocation.enable" : "all"

}

}'


3.关闭自动刷新


大批量插入之前

# curl -XPUThttp://127.0.0.1:9200/*-d'

{

"settings" : {

"refresh_interval": "-1"

}

}'

大批量插入之后改回1


4.索引别名

curl -XPOST'http://localhost:9200/_aliases' -d '

{

"actions": [

{"remove":{"index": "*", "alias":"*"}},

{"add":{"index":"*", "alias": " *"}}

]

}'


5.手动分配分片

分配一个未分配的分片到指定节点。可以指定索引名和分片号。node参数指定分配到那个节点。allow_primary参数可以强制分配主分片,不过这样可能导致数据丢失。

curl -s"http://localhost:9200/_cat/shards" | grep UNASSIGNED

curl'localhost:9200/_nodes/process?pretty'


curl -XPOST'localhost:9200/_cluster/reroute' -d '{

"commands" : [ {

"allocate" : {

"index" :"your_index_name",

"shard" : 1 (shareindex),

"node" :"AfUyuXmGTESHXpwi4OExxx(NODE 编码)",

"allow_primary" :true

}

}

]

}'