1、准备环境
- 一台安装了docker的机器(并且安装docker-compose)
- es版本:elasticsearch:8.6.2(使用的es版本)
- kibana:8.6.2
以上都是在ubuntu22.04下进行的安装
2、获取镜像
- docker pull elasticsearch:8.6.2
- docker pull kibana:8.6.2
上诉拉取镜像可能会比较慢,请耐心等待
3、docker-compose编排
创建一个elasticstack目录,在目录下分别创建node1,node2,node3 三个文件夹,作为三个节点的挂载目录(然后根据需求在nodex下创建data,conf等目录挂载容器内的es相关文件夹\文件)
3.1、编写docker-compose.yml配置
version: '3.7' services: es01: image: ${image} container_name: es01 ports: - "9200:9200" - "9300:9300" environment: node.name: es01 cluster.name: docker-cluster discovery.seed_hosts: es01,es02,es03 cluster.initial_master_nodes: es01,es02,es03 ES_JAVA_OPTS: -Xms512m -Xmx512m xpack.security.enabled: false # es8引入https,为了开发方便关闭 ulimits: memlock: soft: -1 hard: -1 volumes: - /home/zt/elasticstack/node1/data:/usr/share/elasticsearch/data networks: - es-net es02: image: ${image} container_name: es02 ports: - "9201:9200" - "9301:9300" environment: node.name: es02 cluster.name: docker-cluster discovery.seed_hosts: es01,es02,es03 cluster.initial_master_nodes: es01,es02,es03 ES_JAVA_OPTS: -Xms512m -Xmx512m xpack.security.enabled: false ulimits: memlock: soft: -1 hard: -1 volumes: - /home/zt/elasticstack/node2/data:/usr/share/elasticsearch/data networks: - es-net es03: image: ${image} container_name: es03 ports: - "9202:9200" - "9302:9300" environment: node.name: es03 cluster.name: docker-cluster discovery.seed_hosts: es01,es02,es03 cluster.initial_master_nodes: es01,es02,es03 ES_JAVA_OPTS: -Xms512m -Xmx512m xpack.security.enabled: false ulimits: memlock: soft: -1 hard: -1 volumes: - /home/zt/elasticstack/node3/data:/usr/share/elasticsearch/data networks: - es-net kibana: image: ${image_kibana} container_name: kibana depends_on: - es01 - es02 - es03 environment: SERVERNAME: kibana ES_JAVA_OPTS: -Xmx521m -Xms512m ELASTICSEARCH_HOSTS: '["http://es01:9200","http://es02:9200","http://es03:9200"]' networks: - es-net ports: - "5601:5601" - "9600:9600" networks: es-net: driver: bridgey 以上配置文件缩进可能有问题,复制请校对一下
3.2、编写.env配置
image=elasticsearch:8.6.2
image_kibana=kibana:8.6.2
3.3、启动集群
- docker-compoose up -d
- docker ps 查看集群启动情况
- 访问 http://ip:5601 查看kibana是否启动成功
- 在dev tool 执行GET _cluster/health 查看集群是否搭建成功 number_of_nodes 为3;status为green