opensearch ccr
openearch ccr 设置
es 的 ccr 收费,采用开源免费的方式式, 现在使用7.x 可以无缝使用 opensearch 1.x 系列,使用 docker 方式进行测试
1.
version: '3'
services:
replication-node1:
image: opensearchproject/opensearch:1.3.19
container_name: replication-node1
environment:
- cluster.name=leader-cluster
- discovery.type=single-node
- bootstrap.memory_lock=true
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
- "DISABLE_SECURITY_PLUGIN=true" # Disables security plugin
ulimits:
memlock:
soft: -1
hard: -1
# volumes:
# - opensearch-data1:/usr/share/opensearch/data
ports:
- 9200:9200
- 9700:9600 # required for Performance Analyzer
networks:
- opensearch-net
dashboard-node1:
image: opensearchproject/opensearch-dashboards:1.3.19
container_name: dashboard-node1
environment:
- OPENSEARCH_HOSTS=http://replication-node1:9200
- "DISABLE_SECURITY_DASHBOARDS_PLUGIN=true" # disables security dashboards plugin in OpenSearch Dashboards
ports:
- 5601:5601
depends_on:
- replication-node1
networks:
- opensearch-net
replication-node2:
image: opensearchproject/opensearch:1.3.19
container_name: replication-node2
environment:
- cluster.name=follower-cluster
- discovery.type=single-node
- bootstrap.memory_lock=true
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
- "DISABLE_SECURITY_PLUGIN=true" # Disables security plugin
ulimits:
memlock:
soft: -1
hard: -1
# volumes:
# - opensearch-data2:/usr/share/opensearch/data
ports:
- 9201:9200
- 9600:9600 # required for Performance Analyzer
networks:
- opensearch-net
dashboard-node2:
image: opensearchproject/opensearch-dashboards:1.3.19
container_name: dashboard-node2
environment:
- OPENSEARCH_HOSTS=http://replication-node2:9200
- "DISABLE_SECURITY_DASHBOARDS_PLUGIN=true" # disables security dashboards plugin in OpenSearch Dashboards
ports:
- 5602:5601
depends_on:
- replication-node2
networks:
- opensearch-net
# volumes:
# opensearch-data1:
# opensearch-data2:
networks:
opensearch-net:
2
在 http://localhost:5602/app/dev_tools#/console 开发工具中执行
从集群中建立跨集群的连接
PUT /_cluster/settings?pretty
{
"persistent": {
"cluster": {
"remote": {
"my-connection-alias": {
"seeds": ["replication-node1:9300"]
}
}
}
}
}
3
http://localhost:5601/app/dev_tools#/console
主中创建索引
PUT /test
{
"mappings": {
"properties": {
"main_data_type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
..................
4
http://localhost:5602/app/dev_tools#/console
从集群中启动CCR
PUT /_plugins/_replication/test/_start?pretty
{
"leader_alias": "my-connection-alias",
"leader_index": "test",
"use_roles":{
"leader_cluster_role": "all_access",
"follower_cluster_role": "all_access"
}
}
5
在主集群中
http://localhost:5601/app/dev_tools#/console
写入测试数据
6
http://localhost:5602/app/dev_tools#/console
可看到数据同步成功
GET test/_search
{
"query": {
"match_all": {}
}
}
7
http://localhost:5602/app/dev_tools#/console
可查看同步状态
GET /_plugins/_replication/test/_status