docker-compose.yml 文件
version: '3.7'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.7.1
container_name: es01
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es02,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- /Users/keith/devtools/docker/es-docker/data01/data:/usr/share/elasticsearch/data
- /Users/keith/devtools/docker/es-docker/data01/logs:/usr/share/elasticsearch/logs
ports:
- 9200:9200
networks:
- elastic
es02:
image: docker.elastic.co/elasticsearch/elasticsearch:7.7.1
container_name: es02
environment:
- node.name=es02
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es03
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- /Users/keith/devtools/docker/es-docker/data02/data:/usr/share/elasticsearch/data
- /Users/keith/devtools/docker/es-docker/data02/logs:/usr/share/elasticsearch/logs
networks:
- elastic
es03:
image: docker.elastic.co/elasticsearch/elasticsearch:7.7.1
container_name: es03
environment:
- node.name=es03
- cluster.name=es-docker-cluster
- discovery.seed_hosts=es01,es02
- cluster.initial_master_nodes=es01,es02,es03
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- /Users/keith/devtools/docker/es-docker/data03/data:/usr/share/elasticsearch/data
- /Users/keith/devtools/docker/es-docker/data03/logs:/usr/share/elasticsearch/logs
networks:
- elastic
kibana:
image: docker.elastic.co/kibana/kibana:7.7.1
container_name: kibana
environment:
- I18N_LOCALE=zh-CN
ports:
- "5601:5601"
links:
- es01:elasticsearch
depends_on:
- es01
- es02
- es03
networks:
- elastic
cerebro:
image: lmenezes/cerebro:0.9.2
container_name: cerebro
ports:
- "9000:9000"
links:
- es01:elasticsearch
command:
- -Dhosts.0.host=http://elasticsearch:9200
networks:
- elastic
volumes:
data01:
driver: local
data02:
driver: local
data03:
driver: local
networks:
elastic:
driver: bridge
执行docker-compose 命令启动
docker-compose up -d
常见问题:
- 权限不足
报错:Error opening log file ‘logs/gc.log’: Permission denie 挂载目录权限问题
解决方法:在环境变量 TAKE_FILE_OWNERSHIP=true - 文件数不足
报错:ERROR: bootstrap checks failed
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决办法:
临时提高了 vm.max_map_count 的大小,此操作需要 root 权限:
sudo sysctl -w vm.max_map_count=262144
sysctl -a|grep vm.max_map_count
永久修改 vm.max_map_count:切换到 root 用户修改配置 sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
然后,重新启动elasticsearch,即可启动成功。
- jvm配置问题
2017-01-12T16:12:22,404][INFO ][o.e.b.BootstrapCheck ] [SfD5sIh] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
ERROR: bootstrap checks failed
initial heap size [536870912] not equal to maximum heap size [1073741824]; this can cause resize pauses and prevents mlockall from locking the entire heap
解决方法:vi config/jvm.options
###-Xms 和 -Xmx需要配置的相等,不然无法启动成功。
-Xms1024m
-Xmx1024m
网友评论