我有一个简单的弹性搜索群集,我已经在文档中看到主节点必须访问弹性数据卷。
但事实是,如果两个节点使用相同的数据卷,则会发生此错误:Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/share/elasticsearch/data/escluster]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
我尝试了很多配置,但无法找到如何在不同节点之间共享卷。
Docker-compose
version: '2'
services:
esmaster:
build: elasticsearch/
volumes:
- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
volumes_from:
- esdata
environment:
cluster.name: "escluster"
node.data: "false"
http.enabled: "false"
node.master: "true"
ES_JAVA_OPTS: "-Xmx2g -Xms2g"
discovery.zen.ping.unicast.hosts: esmaster
cap_add:
- IPC_LOCK
networks:
- elk
esclient:
build: elasticsearch/
volumes:
- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
ports:
- "9200"
- "9300"
environment:
cluster.name: "escluster"
node.data: "false"
http.enabled: "true"
node.master: "false"
ES_JAVA_OPTS: "-Xmx2g -Xms2g"
discovery.zen.ping.unicast.hosts: esclient
cap_add:
- IPC_LOCK
networks:
- elk
depends_on:
- esmaster
esdata:
build: elasticsearch/
volumes:
- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- ./elasticsearch/data:/usr/share/elasticsearch/data
environment:
cluster.name: "escluster"
node.data: "true"
http.enabled: "false"
node.master: "false"
ES_JAVA_OPTS: "-Xmx2g -Xms2g"
discovery.zen.ping.unicast.hosts: esdata
cap_add:
- IPC_LOCK
networks:
- elk
logstash:
build: logstash/
volumes:
- ./logstash/config/logstash.yml:/usr/share/logstash/config/logstash.yml
- ./logstash/pipeline:/usr/share/logstash/pipeline
ports:
- "5000:5000"
environment:
LS_JAVA_OPTS: "-Xmx6g -Xms6g"
networks:
- elk
depends_on:
- esmaster
kibana:
build: kibana/
volumes:
- ./kibana/config/:/usr/share/kibana/config
ports:
- "5601:5601"
networks:
- elk
depends_on:
- esmaster
networks:
elk:
driver: bridge
答案 0 :(得分:1)
您不想共享数据目录。每个Elasticsearch实例都应该使用它自己的数据目录。
您可以在https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-cli-run-prod-mode部分找到一个有效的docker-compose文件 - 两个节点,每个节点都使用自己的Docker命名卷。