ElasticSearch之跨集群搜索cross cluster search

写在前面

本文看下跨集群搜索相关内容。

1:实战

1.1:创建集群

复制代码
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

1.2:设置各个集群支持跨集群搜索

复制代码
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"]}}}}}'

1.3:创建测试数据

复制代码
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}'

1.4:搜索测试

http://192.168.10.96:9201/users,cluster1:users,cluster2:users/_search

写在后面

参考文章列表

相关推荐
问君能有几多愁~1 天前
Git 上库流程培训文档
大数据·git·elasticsearch
TracyCoder1231 天前
MySQL 实战宝典(二):MySQL vs Elasticsearch 文本检索性能全方位对比
数据库·mysql·elasticsearch
TracyCoder1231 天前
后端架构基石:MySQL、ES、Redis 与 RabbitMQ 核心设计指南
mysql·elasticsearch·架构
南棱笑笑生1 天前
20260127让天启AIO-3576Q38开发板跑Rockchip瑞芯微原厂的Buildroot【linux-6.1内核】【使用天启Firefly的DTS】
linux·运维·elasticsearch·rockchip
小北方城市网2 天前
Elasticsearch 分布式检索生产级优化:从索引设计到查询性能
java·大数据·运维·redis·分布式·elasticsearch·搜索引擎
大志哥1232 天前
使用logstash和elasticsearch实现日志链路(一)
大数据·elasticsearch·搜索引擎
阿白逆袭记2 天前
Git原理与使用详解(十):Git大师之路——总结与最佳实践
大数据·git·elasticsearch
阿白逆袭记2 天前
Git原理与使用详解(八):企业级Git工作流与DevOps实践
git·elasticsearch·devops
阿白逆袭记2 天前
Git原理与使用详解(四):时光回溯——版本回退与修改撤销
大数据·git·elasticsearch
阿白逆袭记2 天前
Git原理与使用详解(二):初探Git仓库与核心工作流程
大数据·git·elasticsearch