1 先安装docker-compose
apt install docker-compose
2 为避免Elastic容器退出
日志内报错
ERROR: [1] bootstrap checks failed [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
则在宿主机中执行
vi /etc/sysctl.conf
追加如下代码
vm.max_map_count=262144
刷新系统配置
sysctl -p
3 编写配置文件
vim docker-compose.yaml
version: '2.2'
services:
cerebro:
image: lmenezes/cerebro:0.8.3
container_name: cerebro
ports:
- "9000:9000"
command:
- -Dhosts.0.host=http://elasticsearch:9200
networks:
- elastic
kibana:
image: docker.elastic.co/kibana/kibana:7.1.0
container_name: kibana7
environment:
- I18N_LOCALE=zh-CN
- XPACK_GRAPH_ENABLED=true
- TIMELION_ENABLED=true
- XPACK_MONITORING_COLLECTION_ENABLED="true"
ports:
- "5601:5601"
networks:
- elastic
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.1.0
container_name: es7_01
environment:
- node.name=es7_01
- cluster.name=es_cluster
- discovery.seed_hosts=es7_02
- cluster.initial_master_nodes=es7_01,es7_02
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- es7data1:/usr/share/elasticsearch/data
ports:
- "9200:9200"
networks:
- elastic
elasticsearch2:
image: docker.elastic.co/elasticsearch/elasticsearch:7.1.0
container_name: es7_02
environment:
- node.name=es7_02
- cluster.name=es_cluster
- discovery.seed_hosts=es7_01
- cluster.initial_master_nodes=es7_01,es7_02
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- es7data2:/usr/share/elasticsearch/data
networks:
- elastic
volumes:
es7data1:
driver: local
es7data2:
driver: local
networks:
elastic:
driver: bridge
执行docker-compose.yaml生成并启动服务, -d的意思是后台启动
sudo docker-compose up -d