我有以下Docker-compose 3文件:
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.4
container_name: elasticsearch
...
...
volumes:
- /path/to/elasticsearch:/usr/share/elasticsearch/data
- /path/to/elasticsearch/backup:/opt/elasticsearch/backup
ports:
- 9200:9200
networks:
- elasticnetwork
因此,我将path.repo设置为/ path / to / elasticsearch / backup。但是,运行curl http://127.0.0.1:9200/_nodes/?pretty不会产生path.repo:
"settings" : {
...
"path" : {
"logs" : "/usr/share/elasticsearch/logs",
"home" : "/usr/share/elasticsearch"
},
...
},
我希望在路径中看到"repo" : ["/opt/elasticsearch/backup"]
。
答案 0 :(得分:2)
如文档中所述,您必须在path.repo
文件中设置elasticsearch.yml
。该文件位于图像的 / usr / share / elasticsearch / config / 目录中。因此,您的撰写文件应如下所示:
version: '3'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch-oss:6.2.4
container_name: elasticsearch
volumes:
- elastic-data:/usr/share/elasticsearch/data
- elastic-backup:/usr/share/elasticsearch/backup
- ./elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
ports:
- 9200:9200
environment:
discovery.type: single-node
volumes:
elastic-data:
elastic-backup:
和您的elasticsearch.yml
应该具有以下内容:
cluster.name: "docker-cluster"
network.host: 0.0.0.0
# minimum_master_nodes need to be explicitly set when bound on a public IP
# # set to 1 to allow single node clusters
# # Details: https://github.com/elastic/elasticsearch/pull/17288
# discovery.zen.minimum_master_nodes: 1
path.repo: ["/usr/share/elasticsearch/backup"]
启动容器后,我可以在http://127.0.0.1:9200/_nodes/?pretty响应中看到repo
"settings" : {
"cluster" : {
"name" : "docker-cluster"
},
"node" : {
"name" : "3cUpSf-"
},
"path" : {
"logs" : "/usr/share/elasticsearch/logs",
"home" : "/usr/share/elasticsearch",
"repo" : [
"/usr/share/elasticsearch/backup"
]
},
答案 1 :(得分:2)
version: "3"
services:
elasticsearch:
image: elasticsearch:6.8.2
environment:
- 'path.repo=/opt/elasticsearch/backup'
答案 2 :(得分:0)
这是我正在使用的 Docker Compose。我正在使用安装在卷下的外部路径。
我正在使用可以使用 docker network create --driver bridge apps
来创建的自定义网络
version: '3.7'
x-common-config: &common-config
networks:
- network
restart: always
ulimits:
nproc: 65535
nofile:
soft: 65535
hard: 65535
memlock:
soft: -1
hard: -1
services:
elasticsearch:
<<: *common-config
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.1
container_name: elasticsearch
ports:
- 9200:9200
- 9300:9300
environment:
- node.name=elasticsearch
- cluster.name=elasticsearch-cluster
- discovery.type=single-node
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms2g -Xmx2g"
- "path.repo=/usr/share/backup"
volumes:
- data:/usr/share/elasticsearch/data
- /mnt/elastic-backup:/usr/share/backup
kibana:
<<: *common-config
image: docker.elastic.co/kibana/kibana:7.6.1
container_name: kibana
ports:
- 5601:5601
environment:
SERVER_NAME: kibana
XPACK.SECURITY.ENCRYPTIONKEY: <KEY>
depends_on:
- elasticsearch
volumes:
data:
driver: local
networks:
network:
driver: bridge
external:
name: apps