node.master:false
禁止bin/elasticsearch -E node.name=cluster0node -E cluster.name=cluster0 -E path.data=cluster0_data -E discovery.type=single-node -E http.port=9200 -E transport.port=9300
bin/elasticsearch -E node.name=cluster1node -E cluster.name=cluster1 -E path.data=cluster1_data -E discovery.type=single-node -E http.port=9201 -E transport.port=9301
bin/elasticsearch -E node.name=cluster2node -E cluster.name=cluster2 -E path.data=cluster2_data -E discovery.type=single-node -E http.port=9202 -E transport.port=9302
##在每个集群做如下设置
PUT _cluster/settings
{
"persistent": {
"cluster": {
"remote": {
"cluster0": {
"seeds": [
"127.0.0.1:9300"
],
"transport.ping_schedule": "30s"
},
"cluster1": {
"seeds": [
"127.0.0.1:9301"
],
"transport.compress": true,
"skip_unavailable": true
},
"cluster2": {
"seeds": [
"127.0.0.1:9302"
]
}
}
}
}
}
curl -XPUT "http://localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{"persistent":{"cluster":{"remote":{"cluster0":{"seeds":["127.0.0.1:9300"],"transport.ping_schedule":"30s"},"cluster1":{"seeds":["127.0.0.1:9301"],"transport.compress":true,"skip_unavailable":true},"cluster2":{"seeds":["127.0.0.1:9302"]}}}}}'
curl -XPUT "http://localhost:9201/_cluster/settings" -H 'Content-Type: application/json' -d'
{"persistent":{"cluster":{"remote":{"cluster0":{"seeds":["127.0.0.1:9300"],"transport.ping_schedule":"30s"},"cluster1":{"seeds":["127.0.0.1:9301"],"transport.compress":true,"skip_unavailable":true},"cluster2":{"seeds":["127.0.0.1:9302"]}}}}}'
curl -XPUT "http://localhost:9202/_cluster/settings" -H 'Content-Type: application/json' -d'
{"persistent":{"cluster":{"remote":{"cluster0":{"seeds":["127.0.0.1:9300"],"transport.ping_schedule":"30s"},"cluster1":{"seeds":["127.0.0.1:9301"],"transport.compress":true,"skip_unavailable":true},"cluster2":{"seeds":["127.0.0.1:9302"]}}}}}'
curl -XPOST "http://localhost:9200/users/_doc" -H 'Content-Type: application/json' -d'
{"name":"user1","age":10}'
curl -XPOST "http://localhost:9201/users/_doc" -H 'Content-Type: application/json' -d'
{"name":"user2","age":20}'
curl -XPOST "http://localhost:9202/users/_doc" -H 'Content-Type: application/json' -d'
{"name":"user3","age":30}'
GET /users,cluster1:users,cluster2:users/_search
{
"query": {
"range": {
"age": {
"gte": 20,
"lte": 40
}
}
}
}
# If no filters are given, the default is to select all nodes
GET /_nodes
# Explicitly select all nodes
GET /_nodes/_all
# Select just the local node
GET /_nodes/_local
# Select the elected master node
GET /_nodes/_master
# Select nodes by name, which can include wildcards
GET /_nodes/node_name_goes_here
GET /_nodes/node_name_goes_*
# Select nodes by address, which can include wildcards
GET /_nodes/10.0.0.3,10.0.0.4
GET /_nodes/10.0.0.*
# Select nodes by role
GET /_nodes/_all,master:false
GET /_nodes/data:true,ingest:true
GET /_nodes/coordinating_only:true
# Select nodes by custom attribute (e.g. with something like `node.attr.rack: 2` in the configuration file)
GET /_nodes/rack:2
GET /_nodes/ra*:2
GET /_nodes/ra*:2*
GET _cluster/health
GET /_cluster/health/twitter_v1,twitter_v2
GET /_cluster/health?wait_for_status=yellow&timeout=50s
GET /_cluster/health/twitter?level=shards
GET /_cluster/state
GET /_cluster/state/metadata,routing_table/twitter_v1,twitter_v2
GET /_cluster/state/_all/twitter_v1,twitter_v2
GET /_cluster/state/blocks
GET /_cluster/stats?human&pretty
GET /_cluster/stats/nodes/node1,node*,master:false
GET /_cluster/pending_tasks
POST /_cluster/reroute
{
"commands": [
{
"move": {
"index": "test",
"shard": 0,
"from_node": "node1",
"to_node": "node2"
}
},
{
"allocate_replica": {
"index": "test",
"shard": 1,
"node": "node3"
}
}
]
}
#
# order of precedence: transient, persistent, elasticsearch.yml
# It’s best to set all cluster-wide settings with the settings API and use the elasticsearch.yml file only for local configurations.
#
GET /_cluster/settings
GET /_cluster/settings?include_defaults=true
PUT /_cluster/settings
{
"persistent": {
"indices.recovery.max_bytes_per_sec": "50mb"
}
}PUT /_cluster/settings?flat_settings=true
{
"transient" : {
"indices.recovery.max_bytes_per_sec" : "20mb"
}
}
PUT /_cluster/settings?flat_settings=true
{
"transient": {
"indices.recovery.max_bytes_per_sec": "20mb"
}
}
#
# null means default
#
PUT /_cluster/settings
{
"transient": {
"indices.recovery.max_bytes_per_sec": null
}
}
PUT /_cluster/settings
{
"persistent": {
"indices.recovery.max_bytes_per_sec": null
}
}
PUT /_cluster/settings
{
"transient" : {
"indices.recovery.*" : null
}
}
GET /_nodes/stats
GET /_nodes/es7_01,es7_02/stats/process
GET /_nodes/stats/os,process
GET /_nodes/stats/indices
GET /_nodes/172.19.0.2/stats/process
GET /_nodes/stats/indices/fielddata
GET /_nodes/stats/indices/fielddata?level=indices&fields=docs,get
GET /_nodes/stats/indices/fielddata?level=shards&fields=field1,field2
GET /_nodes/stats/indices/fielddata?fields=field*
GET /_nodes/stats?groups=_all
GET /_nodes/stats/indices?groups=foo,bar
GET /_nodes
GET /_nodesGET /_nodes/process/es7_01,es7_02
GET /_nodes/process
GET /_nodes/_all/process
GET /_nodes/es7_01,es7_02/jvm,process
GET /_nodes/es7_01,es7_02/info/jvm,process
GET /_nodes/es7_01,es7_02/_all
GET /_nodes/plugins
# ingest - if set, the result will contain details about the available processors per node
GET /_nodes/ingest
GET _nodes/usage
GET _nodes/es7_02/usage
GET /_remote/info
GET _tasks
GET _tasks?nodes=es7_01,es7_02
GET _tasks?nodes=es7_01,es7_02&actions=cluster:*
GET _tasks/P9t-IW47Q0qmIMpGSxXnEw:113339
GET _tasks?actions=*search&detailed
GET _cat/tasks?detailed&v
GET /_nodes/hot_threads
GET /_nodes/es7_01,es7_02/hot_threads
GET /_cluster/allocation/explain
POST /_cluster/voting_config_exclusions/es7_01
DELETE /_cluster/voting_config_exclusions