编写 docker-compose yaml
yaml
version: 'v3'
services:
elasticsearch-node1:
image: elasticsearch:7.17.24
container_name: 'elasticsearch-node1'
ports:
- "9200:9200"
- "9300:9300"
environment:
- node.name=elasticsearch-node1
- cluster.name=my-es-cluster
- discovery.seed_hosts=elasticsearch-node2,elasticsearch-node3
- cluster.initial_master_nodes=elasticsearch-node1,elasticsearch-node2,elasticsearch-node3
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
networks:
- custom-es
elasticsearch-node2:
image: elasticsearch:7.17.24
container_name: elasticsearch-node2
ports:
- "9201:9200"
- "9301:9300"
environment:
- node.name=elasticsearch-node2
- cluster.name=my-es-cluster
- discovery.seed_hosts=elasticsearch-node1,elasticsearch-node3
- cluster.initial_master_nodes=elasticsearch-node1,elasticsearch-node2,elasticsearch-node3
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
networks:
- custom-es
elasticsearch-node3:
image: elasticsearch:7.17.24
container_name: elasticsearch-node3
ports:
- "9202:9200"
- "9302:9300"
environment:
- node.name=elasticsearch-node3
- cluster.name=my-es-cluster
- discovery.seed_hosts=elasticsearch-node1,elasticsearch-node2
- cluster.initial_master_nodes=elasticsearch-node1,elasticsearch-node2,elasticsearch-node3
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
networks:
- custom-es
my-es-cluster-kibana:
container_name: my-es-cluster-kibana
image: kibana:7.17.24
ports:
- "5601:5601"
environment:
- ELASTICSEARCH_HOSTS=http://elasticsearch-node1:9200
networks:
- custom-es
depends_on:
- elasticsearch-node1
- elasticsearch-node2
- elasticsearch-node3
networks:
custom-es:
driver: bridge
编写 docker-compose 然后在命令行启动这个 docker-compose
启动 docker-compose
docker-compose -f docker-compose.yml -d up
这个命令可以在后台启动一个compose,里面包含 es3个节点的集群+kibana
然后在 chrome 中查询当前的集群信息
分别是
bash
# 查询节点信息
curl http://127.0.0.1:9200/_cat/nodes
# 访问 kibana
curl http://127.0.0.1:5601
当我们输入以后可以看到这样的街面就可以正常使用 es 和 kibana 了
关闭启动的docker-compose
docker-compose -f docker-compose.yaml down