elasticearch corss cluster search
STEP 1: 设定三个Cluster,一个主机一个cluster
bin/elasticsearch -E node.name=win88 -E cluster.name=cluster0 -E discovery.type=single-node -E path.data=cluster0-data -E http.port=9200 -E transport.port=9300 -E network.host=0.0.0.0
bin/elasticsearch -E node.name=win89 -E cluster.name=cluster1 -E discovery.type=single-node -E path.data=cluster1-data -E http.port=9200 -E transport.port=9300 -E network.host=0.0.0.0
bin/elasticsearch -E node.name=win90 -E cluster.name=cluster2 -E path.data=cluster2-data -E discovery.type=single-node -E http.port=9200 -E transport.port=9300 -E network.host=0.0.0.0
STEP2 cluster 设定
设置成功后有以下显示
{"acknowledged":true,"persistent":{"cluster":{"remote":{"cluster1":{"skip_unavailable":"true","seeds":["win89:9300"],"transport":{"compress":"true"}},"cluster0":{"seeds":["win88:9300"],"transport":{"ping_schedule":"30s"}},"cluster2":{"seeds":["win90:9300"]}}}},"transient":{}}
SETP3 创建三个Cluster上创建相同的索引
`curl -XPOST "http://win88:9200/users/_doc" -H 'Content-Type: application/json' -d'
{"name":"user1","age":10}'`
` curl -XPOST "http://win89:9200/users/_doc" -H 'Content-Type: application/json' -d'
{"name":"user2","age":20}'`
curl -XPOST "http://win90:9200/users/_doc" -H 'Content-Type: application/json' -d'
{"name":"user3","age":30}'
SETP4. cross client search
点击查看代码
curl -XGET "http://win88.inno.com:9200/users,cluster1:users,cluster2:users/_search"
curl -XGET "http://win89.inno.com:9200/users,cluster0:users,cluster2:users/_search"
curl -XGET "http://win90.inno.com:9200/users,cluster0:users,cluster1:users/_search"