美文网首页
docker-compose 部署 es集群

docker-compose 部署 es集群

作者: Fenix_Liu | 来源:发表于2020-12-08 14:48 被阅读0次

docker-compose.yml 文件

version: '3.7'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.7.1
    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"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - /Users/keith/devtools/docker/es-docker/data01/data:/usr/share/elasticsearch/data
      - /Users/keith/devtools/docker/es-docker/data01/logs:/usr/share/elasticsearch/logs
    ports:
      - 9200:9200
    networks:
      - elastic
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.7.1
    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"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - /Users/keith/devtools/docker/es-docker/data02/data:/usr/share/elasticsearch/data
      - /Users/keith/devtools/docker/es-docker/data02/logs:/usr/share/elasticsearch/logs
    networks:
      - elastic
  es03:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.7.1
    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"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - /Users/keith/devtools/docker/es-docker/data03/data:/usr/share/elasticsearch/data
      - /Users/keith/devtools/docker/es-docker/data03/logs:/usr/share/elasticsearch/logs
    networks:
      - elastic
  kibana:
      image: docker.elastic.co/kibana/kibana:7.7.1
      container_name: kibana
      environment:
        - I18N_LOCALE=zh-CN
      ports:
        - "5601:5601"
      links:
        - es01:elasticsearch
      depends_on:
        - es01
        - es02
        - es03
      networks:
        - elastic
  cerebro:
      image: lmenezes/cerebro:0.9.2
      container_name: cerebro
      ports:
        - "9000:9000"
      links:
        - es01:elasticsearch
      command:
        - -Dhosts.0.host=http://elasticsearch:9200
      networks:
        - elastic
volumes:
  data01:
    driver: local
  data02:
    driver: local
  data03:
    driver: local

networks:
  elastic:
    driver: bridge

执行docker-compose 命令启动

docker-compose up -d

常见问题:

  1. 权限不足
    报错:Error opening log file ‘logs/gc.log’: Permission denie 挂载目录权限问题
    解决方法:在环境变量 TAKE_FILE_OWNERSHIP=true
  2. 文件数不足
    报错:ERROR: bootstrap checks failed
    max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    解决办法:
    临时提高了 vm.max_map_count 的大小,此操作需要 root 权限:
sudo  sysctl -w vm.max_map_count=262144
sysctl -a|grep vm.max_map_count

永久修改 vm.max_map_count:切换到 root 用户修改配置 sysctl.conf

vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
然后,重新启动elasticsearch,即可启动成功。
  1. jvm配置问题
    2017-01-12T16:12:22,404][INFO ][o.e.b.BootstrapCheck ] [SfD5sIh] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
    ERROR: bootstrap checks failed
    initial heap size [536870912] not equal to maximum heap size [1073741824]; this can cause resize pauses and prevents mlockall from locking the entire heap
    解决方法:vi config/jvm.options
###-Xms 和 -Xmx需要配置的相等,不然无法启动成功。
-Xms1024m
-Xmx1024m

相关文章

网友评论

      本文标题:docker-compose 部署 es集群

      本文链接:https://www.haomeiwen.com/subject/rtafgktx.html