使用 docker-compose 启动 es 集群 + kibana

编写 docker-compose 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 中查询当前的集群信息
分别是

# 查询节点信息
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
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值