zoukankan      html  css  js  c++  java
  • docker安装elasticsearch

    1.拉取es docker镜像,地址:https://www.docker.elastic.co/r/elasticsearch/elasticsearch

       ES docker安装参考:https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html

       ES参数配置:https://www.cnblogs.com/aqicheng/p/14262484.html

    2.ES单节点群集,docker-compose.yml内容如下:

    version: '3'
    services:
      watchad_elasticsearch7:
        image: docker.elastic.co/elasticsearch/elasticsearch:7.15.0
        container_name: es7
        hostname: es7
        environment:
          http.host: 0.0.0.0
          transport.host: 127.0.0.1
          cluster.name: docker-cluster
          bootstrap.memory_lock: "true"
          ES_JAVA_OPTS: "-Xms512m -Xmx512m"   #设置占用内存大小 -Xms2g -Xmx2g
          thread_pool.write.size: 9     #设置写入线程数量及队列大小
          thread_pool.write.queue_size: 1000
          xpack.security.enabled: "false"
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        ports:
          - "9201:9200"
        networks:
          - watchad-master_default
        restart: always
    
    networks:
      watchad-master_default:
        external: true

    3.ES多节节点群集,docker-compose.yml内容如下:

    version: '3'
    services:
      watchad_elasticsearch7_01:
        image: docker.elastic.co/elasticsearch/elasticsearch:7.15.0
        container_name: es701
        hostname: es701
        environment:
          node.name: es701
          cluster.name: es-cluster
          discovery.seed_hosts: es702
          cluster.initial_master_nodes: es701,es702
          bootstrap.memory_lock: "true"
          ES_JAVA_OPTS: "-Xms512m -Xmx512m"
          thread_pool.write.size: 9
          thread_pool.write.queue_size: 1000
          xpack.security.enabled: "false"
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        volumes:
         - es701_data:/usr/share/elasticsearch/data
        ports:
          - "9201:9200"
        restart: always
    
      watchad_elasticsearch7_02:
        image: docker.elastic.co/elasticsearch/elasticsearch:7.15.0
        container_name: es702
        hostname: es702
        environment:
          node.name: es702
          cluster.name: es-cluster
          discovery.seed_hosts: es701
          cluster.initial_master_nodes: es701,es702
          bootstrap.memory_lock: "true"
          ES_JAVA_OPTS: "-Xms512m -Xmx512m"
          thread_pool.write.size: 9
          thread_pool.write.queue_size: 1000
          xpack.security.enabled: "false"
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        volumes:
         - es702_data:/usr/share/elasticsearch/data
        restart: always
    
    volumes:
      es701_data:
      es702_data:
    
    networks:
      default:
        external:
          name: watchad-master_default
    #此处使用的桥接网络,es各节点之间互相解析,实际是通过container_name进行的解析,所以container_name和node.name必须要保持一致

    如果在docker-compose up后出现如下报错,处理方式:

    max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

    vi /etc/sysctl.conf,添加如下内容:

      vm.max_map_count=262144

    然后 sysctl -p重新载入该文件生效

    启动后访问:http://192.168.120.27:9201/_cat/health?v 可以看到有2个节点

    docker host模式安装ES群集:

    注:host模式共享主机网卡,-p绑定端口是无效的

    version: '3'
    services:
      watchad_elasticsearch7_01:
        image: docker.elastic.co/elasticsearch/elasticsearch:7.15.0
        container_name: es701
        hostname: es701
        environment:
          node.name: es701
          cluster.name: docker-cluster
          http.port: 9201
          transport.tcp.port: 9301
          http.cors.enabled: "true"   #开启跨站访问
          http.cors.allow-origin: "*"  #设置跨站来源
          discovery.zen.ping.unicast.hosts: 192.168.120.27:9301, 192.168.120.27:9302  #发现其他节点
          discovery.zen.minimum_master_nodes: 1 #设置最小主节点个数,防止脑裂
          bootstrap.memory_lock: "true"
          ES_JAVA_OPTS: "-Xms512m -Xmx512m"
          thread_pool.write.size: 9
          thread_pool.write.queue_size: 1000
          xpack.security.enabled: "false"
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        volumes:
         - es701_data:/usr/share/elasticsearch/data
        network_mode: "host"
        restart: always
    
      watchad_elasticsearch7_02:
        image: docker.elastic.co/elasticsearch/elasticsearch:7.15.0
        container_name: es702
        hostname: es702
        environment:
          node.name: es702
          cluster.name: docker-cluster
          http.port: 9202
          transport.tcp.port: 9302
          http.cors.enabled: "true"
          http.cors.allow-origin: "*"
          discovery.zen.ping.unicast.hosts: 192.168.120.27:9301, 192.168.120.27:9302
          discovery.zen.minimum_master_nodes: 1
          bootstrap.memory_lock: "true"
          ES_JAVA_OPTS: "-Xms512m -Xmx512m"
          thread_pool.write.size: 9
          thread_pool.write.queue_size: 1000
          xpack.security.enabled: "false"
        ulimits:
          memlock:
            soft: -1
            hard: -1
          nofile:
            soft: 65536
            hard: 65536
        volumes:
         - es702_data:/usr/share/elasticsearch/data
        network_mode: "host"
        restart: always
    
    volumes:
      es701_data:
      es702_data:
  • 相关阅读:
    Android控件之ListView探究二
    解决activity页面跳转时显示桌面
    TextView实现滚动显示的效果
    QPainter的坐标系系统的转换
    MODBUS_RTU通信协议
    收藏的博客 -- Qt有关的GitHub/Gitee开源项目
    VS联调多个解决方案的项目
    软件工具——GitGUI使用教程
    Python中对文件的操作
    VMware虚拟机三种网络模式详解 --------- NAT(地址转换模式)
  • 原文地址:https://www.cnblogs.com/dreamer-fish/p/15347032.html
Copyright © 2011-2022 走看看