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

写在后面

参考文章列表

相关推荐
Elasticsearch1 天前
Elasticsearch Reindex 现已支持跨节点自动迁移:无需人工干预,不会丢失进度
elasticsearch
星辰_mya1 天前
数据同步的几种姿势
大数据·elasticsearch·搜索引擎
曾阿伦1 天前
Elasticsearch Analyzer 分析器开发指南
大数据·elasticsearch·搜索引擎
Elastic 中国社区官方博客1 天前
使用 Jina CLIP v2 和 Elasticsearch 实现多语言图片搜索
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·jina
醉颜凉1 天前
Elasticsearch 核心数据结构:FST 原理与应用场景全解析
数据结构·elasticsearch·jenkins
garmin Chen1 天前
Elasticsearch(4):Java Rest Client 搜索与聚合速查
java·分布式·elasticsearch
独隅1 天前
Git Submodule深度避坑指南
大数据·git·elasticsearch
Elastic 中国社区官方博客1 天前
使用 Elasticsearch 和 GitHub Copilot SDK 构建一个 RAG agent
大数据·人工智能·elasticsearch·搜索引擎·github·全文检索·copilot
星辰_mya1 天前
Elasticsearch 数据处理常见问题
大数据·elasticsearch·搜索引擎
宸津-代码粉碎机1 天前
Spring AI企业级RAG进阶|文档智能分片调优、ES深度整合、接口限流熔断监控生产实战
java·开发语言·人工智能·后端·spring·elasticsearch·oracle