使用docker-compose容器编排技术,搭建ES集群,包含ElasticSearch、Logstash、Kibana,使用的是目前官方提供的最新版本7.8.0。前期呢,自己也踩了很多的坑,把它分享一下
新建docker-compose.yml
version: '2.2'
services:
kibana:
image: kibana:7.8.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: elasticsearch:7.8.0
container_name: es7
environment:
- node.name=es7
- cluster.name=es-cluster
- discovery.seed_hosts=es7,es7_02
- cluster.initial_master_nodes=es7,es7_02
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- ~/Docker/env/elastic/es/data:/usr/share/elasticsearch/data
ports:
- 9200:9200
- 9300:9300
networks:
- elastic
elasticsearch2:
image: elasticsearch:7.8.0
container_name: es7_02
environment:
- node.name=es7_02
- cluster.name=es-cluster
- discovery.seed_hosts=es7,es7_02
- cluster.initial_master_nodes=es7,es7_02
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- ~/Docker/env/elastic/es2/data:/usr/share/elasticsearch/data
networks:
- elastic
logstash:
image: logstash:7.8.0
container_name: logstash7
volumes:
- ~/Docker/env/elastic/logstash/logstash.conf:/usr/share/logstash/logstash.conf
networks:
- elastic
networks:
elastic:
driver: bridge
容器编排:
docker-compose up -d
如果是linux root用户,需要给宿主机映射目录赋权
chmod -R 775 ~/Docker/env/elastic/es/data chmod -R 775 ~/Docker/env/elastic/es2/data
运行
ES集群验证
查看ES节点
GET _cat/nodes
验证ES集群健康度
GET _cluster/health
如下图所示,status 值为 green 表示集群环境正常