基于docker-compose部署es集群和es-head

目录

1. 服务器基础设置

2. es集群的yml配置

3. 集群验证

3.1 访问es-head来查看集群

3.2 通过cerebro查看es集群

4. 参考资料


1. 服务器基础设置

修改/etcsysctl.conf文件
vi /etc/sysctl.conf
fs.file-max=65536
vm.max_map_count=262144

使用sysctl -p使条件生效

修改 /etc/security/limits.conf
vi /etc/security/limits.conf

添加如下配置
* soft nofile 65536
* hard nofile 65536
* soft nproc 65536
* hard nproc 65536
* soft memlock unlimited
* hard memlock unlimited

终端登出当前用户,让上述配置生效。


2. es集群的yml配置

使用下列yml配置,在一台服务器上,直接启动,即可开启一个具有3个节点的es集群。

使用启动命令:docker-compose  -f docker-es-cluster.yml up -d



version: '3'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.13.2
    container_name: es01
    environment:
      - node.name=es01
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es02,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - TZ="Asia/Shanghai"
      - node.master=true
      - node.data=true      
      - http.cors.enabled=true
      - http.cors.allow-origin=*      
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - /work/elk/es/data01/data:/usr/share/elasticsearch/data
      - /work/elk/es/data01/logs:/usr/share/elasticsearch/logs
    ports:
      - 9200:9200
    networks:
      - elastic
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.13.2
    container_name: es02
    environment:
      - node.name=es02
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es03
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - TZ="Asia/Shanghai"
      - node.master=true
      - node.data=true
      - http.cors.enabled=true
      - http.cors.allow-origin=*
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - /work/elk/es/data02/data:/usr/share/elasticsearch/data
      - /work/elk/es/data02/logs/logs:/usr/share/elasticsearch/logs
    ports:
      - 9201:9200
      - 9301:9300      
    networks:
      - elastic
  es03:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.13.2
    container_name: es03
    environment:
      - node.name=es03
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es02
      - cluster.initial_master_nodes=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - TZ="Asia/Shanghai"
      - node.master=true
      - node.data=true
      - http.cors.enabled=true
      - http.cors.allow-origin=*
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - /work/elk/es/data03/data:/usr/share/elasticsearch/data
      - /work/elk/es/data03/logs/logs:/usr/share/elasticsearch/logs
    ports:
      - 9202:9200
      - 9302:9300
    networks:
      - elastic
  kibana:
      image: docker.elastic.co/kibana/kibana:7.13.2
      container_name: kibana
      environment:
        - I18N_LOCALE=zh-CN
      ports:
        - "5601:5601"
      links:
        - es01:vm01
      depends_on:
        - es01
        - es02
        - es03
      networks:
        - elastic
  cerebro:
      image: lmenezes/cerebro:0.9.2
      container_name: cerebro
      ports:
        - "19000:9000"
      links:
        - es01:vm01
      command:
        - -Dhosts.0.host=http://vm01:9200
      networks:
        - elastic
  elasticsearch-head:
      image: wallbase/elasticsearch-head:6-alpine
      container_name: elasticsearch-head
      environment:
        TZ: 'Asia/Shanghai'
      ports:
        - '9100:9100'
      networks:
        - elastic
volumes:
  data01:
    driver: local
  data02:
    driver: local
  data03:
    driver: local

networks:
  elastic:
    driver: bridge

3. 集群验证

3.1 访问es-head来查看集群

http://vm01:9100/

在浏览器中输入vm01:9100即可访问到es-header的页面,会自动连接到我们的es集群:

如果我们想链接其他的es集群,则在下面的框中输入ip:9201即可连接到其他的es集群中。填写es集群中一个节点的ip:port

3.2 通过cerebro查看es集群

我们在上面的yml中配置了cerebro,因此我们可以通过cerebro访问es集群,在浏览器中输入

vm01:19000,即可访问到cerebro的页面,默认已经为我们连上了配置的es集群。

3.3 访问kibana

 

访问kibana前,请参考这里,修改容器中kibana.yml文件中es的实际地址,然后浏览器访问vm:01:5601即可


4. 参考资料

Elasticsearch 7.6.1集群部署_litlit023的专栏-CSDN博客_es集群部署

Install Elasticsearch with Docker | Elasticsearch Guide [7.13] | Elastic

今日头条

  • 1
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值