• Linux中使用Docker搭建ElasticSearch集群


    1. 拉取镜像
    docker pull elasticsearch:6.5.4
    
    1. 先创建本地容器映射目录方便管理,我的目录结构
    + haoke
      + es-cluster
        + node01
        	+ data
        	+ elasticsearch.yml
        	+ jvm.options
        + node02
        	+ data
        	+ elasticsearch.yml
        	+ jvm.options
        + node03
        	+ data
        	+ elasticsearch.yml
        	+ jvm.options
        + ik          // IK分词
        + pinyin      // 拼音分词
    
    1. 分词器上传(非必须)

    上传ik分词器和pinyin分词器并解压到对应文件夹

    unzip elasticsearch-analysis-ik-6.5.4.zip  /haoke/es-cluster/ik/
    
    unzip elasticsearch-analysis-pinyin-6.5.4.zip /haoke/es-cluster/pinyin/
    
    1. 配置文件

    node01的elasticsearch.yml

    # 集群名称
    cluster.name: es-itcast-cluster
    # 节点名称
    node.name: node01
    node.master: true
    node.data: true
    truenetwork.host: 192.168.134.128
    http.port: 9200
    discovery.zen.ping.unicast.hosts: ["192.168.134.128"]
    
    # 设置minimum_master_nodes的大小为2,官方推荐:(N/2)+1,N为集群中节点数
    discovery.zen.minimum_master_nodes: 2 
    
    # 跨域(非必须)
    http.cors.enabled: true
    http.cors.allow-origin: "*"
    

    node02的elasticsearch.yml

    cluster.name: es-itcast-cluster
    node.name: node02
    node.master: true
    node.data: true
    truenetwork.host: 192.168.134.128
    http.port: 9201
    discovery.zen.ping.unicast.hosts: ["192.168.134.128"]
    discovery.zen.minimum_master_nodes: 2
    http.cors.enabled: true
    http.cors.allow-origin: "*"
    

    node03的elasticsearch.yml

    cluster.name: es-itcast-cluster
    node.name: node03
    node.master: true
    node.data: true
    truenetwork.host: 192.168.134.128
    http.port: 9202
    discovery.zen.ping.unicast.hosts: ["192.168.134.128"]
    discovery.zen.minimum_master_nodes: 2
    http.cors.enabled: true
    http.cors.allow-origin: "*"
    

    node01、node02、node03的jvm.options

    -Xms256m
    -Xmx256m
    
    1. 容器创建,设置net为host设置与虚拟机同一个IP

    创建容器node01

    docker create --name es-node01 --net host 
    -v /haoke/es-cluster/node01/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml 
    -v /haoke/es-cluster/node01/jvm.options:/usr/share/elasticsearch/config/jvm.options 
    -v /haoke/es-cluster/ik:/usr/share/elasticsearch/plugins/ik 
    -v /haoke/es-cluster/pinyin:/usr/share/elasticsearch/plugins/pinyin 
    -v /haoke/es-cluster/node01/data:/usr/share/elasticsearch/data elasticsearch:6.5.4
    

    创建容器node02

    docker create --name es-node02 --net host 
    -v /haoke/es-cluster/node02/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml 
    -v /haoke/es-cluster/node02/jvm.options:/usr/share/elasticsearch/config/jvm.options 
    -v /haoke/es-cluster/ik:/usr/share/elasticsearch/plugins/ik 
    -v /haoke/es-cluster/pinyin:/usr/share/elasticsearch/plugins/pinyin 
    -v /haoke/es-cluster/node02/data:/usr/share/elasticsearch/data elasticsearch:6.5.4
    

    创建容器node03

    docker create --name es-node03 --net host 
    -v /haoke/es-cluster/node03/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml 
    -v /haoke/es-cluster/node03/jvm.options:/usr/share/elasticsearch/config/jvm.options 
    -v /haoke/es-cluster/ik:/usr/share/elasticsearch/plugins/ik 
    -v /haoke/es-cluster/pinyin:/usr/share/elasticsearch/plugins/pinyin 
    -v /haoke/es-cluster/node03/data:/usr/share/elasticsearch/data elasticsearch:6.5.4
    
    1. 启动容器,并查看日志
    docker start es-node01 && docker logs -f es-node01 
    
    docker start es-node02 && docker logs -f es-node02
    
    docker start es-node03 && docker logs -f es-node03 
    
  • 相关阅读:
    c# 国际化国家代码
    转:Oracle Connect By用法
    函数关系: 单射 满射 双射
    python 乱码
    2010年下半年全国计算机技术与软件专业技术资格(水平)考试试题下载
    HDU1068 Girls and Boys 最大独立子集
    HDU1151 Air Raid 最小简单路径覆盖
    POJ2411 Mondriaan's Dream 状态压缩+DP
    HDU1556 方格取数(1) 状态压缩+dp
    POJ2239 Selecting Courses 二分匹配
  • 原文地址:https://www.cnblogs.com/lixin-nobody/p/14051901.html
Copyright © 2020-2023  润新知