在3个vms上部署elasticsearch集群

时间:2018-02-17 18:11:54

标签: docker elasticsearch docker-compose docker-machine boot2docker

我用docker-machine和VirtualBox创建了3个虚拟机,我正在尝试部署elasticseach。 我创建了这个docker-compose:

version: '3.0'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.1
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
    volumes:
      - esdatavm1:/usr/share/elasticsearch/data
    deploy:
      placement:
        constraints: [node.role == manager]
    ports:
      - 9200:9200
    networks:
      - esvmnet
  elasticsearch2:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.1
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=elasticsearch"
    volumes:
      - esdatavm2:/usr/share/elasticsearch/data
    deploy:
      placement:
        constraints: [node.role == worker]
    networks:
      - esvmnet
  elasticsearch3:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.2.1
    environment:
      - cluster.name=docker-cluster
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - "discovery.zen.ping.unicast.hosts=elasticsearch"
    volumes:
      - esdatavm3:/usr/share/elasticsearch/data
    deploy:
      placement:
        constraints: [node.role == worker]
    networks:
      - esvmnet
volumes:
  esdatavm1:
    driver: local
  esdatavm2:
    driver: local
  esdatavm3:
    driver: local
networks:
  esvmnet:

但是弹性搜索不能上去,我收到这些警告信息:

[2018-02-17T17:40:12,751][WARN ][o.e.b.JNANatives         ] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
[2018-02-17T17:40:12,753][WARN ][o.e.b.JNANatives         ] This can result in part of the JVM being swapped out.
[2018-02-17T17:40:12,753][WARN ][o.e.b.JNANatives         ] Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: 65536
[2018-02-17T17:40:12,753][WARN ][o.e.b.JNANatives         ] These can be adjusted by modifying /etc/security/limits.conf, for example: 
    # allow user 'elasticsearch' mlockall
    elasticsearch soft memlock unlimited
    elasticsearch hard memlock unlimited

之后弹性模具:

ERROR: [1] bootstrap checks failed
[1]: memory locking requested for elasticsearch process but memory is not locked
[2018-02-17T17:40:26,490][INFO ][o.e.n.Node               ] [F8VD2bv] stopping ...

我应该像警告中那样设置溃疡吗? 在boot2docker中我没有任何/etc/security/limits.conf我应该在哪里设置该选项?

有人可以帮助我吗? 非常感谢。 问候。

1 个答案:

答案 0 :(得分:0)

问题不同。我尝试用单节点在我的机器上复制。

问题如下

  

[o.e.b.BootstrapChecks] [4qfUlP0]绑定或发布到非环回或非链接本地地址,执行引导检查   错误:[1]引导程序检查失败   [1]:弹性搜索过程请求的内存锁定但内存未锁定

取消注释环境

中的行
- bootstrap.memory_lock=true

另外,请仔细阅读有关环境变量的弹性文档。