美文网首页
docker安装elasticsearch集群

docker安装elasticsearch集群

作者: 懒人程序猿 | 来源:发表于2020-05-23 01:32 被阅读0次

    docker安装可参照:https://www.jianshu.com/p/0a0d2315805a
    elasticsearch-head和kibana安装可参照:https://www.jianshu.com/p/3883774d80ed
    拉取elasticsearch镜像

    docker pull elasticsearch:6.8.0
    

    创建es配置文件,容器映射目录

    cd /
    mkdir elasticsearch
    cd elasticsearch
    

    在elasticsearch目录下分别创建:elasticsearch-1.yml、elasticsearch-2.yml
    elasticsearch-1.yml配置如下:

    cluster.name: elasticsearch-cluster
    node.name: es-node1
    network.host: 0.0.0.0
    network.publish_host: es容器1IP
    http.port: 9200
    transport.tcp.port: 9300
    http.cors.enabled: true
    http.cors.allow-origin: "*"
    node.master: true
    node.data: true
    discovery.zen.ping.unicast.hosts: ["es容器1IP:9300","es容器2IP:9300"]
    discovery.zen.minimum_master_nodes: 1
    

    elasticsearch-2.yml

    cluster.name: elasticsearch-cluster
    node.name: es-node2
    network.host: 0.0.0.0
    network.publish_host: es容器2IP
    http.port: 9200
    transport.tcp.port: 9300
    http.cors.enabled: true
    http.cors.allow-origin: "*"
    node.master: true
    node.data: true
    discovery.zen.ping.unicast.hosts: ["es容器1IP:9300","es容器2IP:9300"]
    discovery.zen.minimum_master_nodes: 1
    

    创建es容器

    # es容器1
    docker run -itd --name es1 -p 9200:9200 -p 9300:9300 \
    -v /elasticsearch/elasticsearch-1.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
    -e ES_JAVA_OPTS="-Xms256m -Xmx256m" elasticsearch:6.8.0
    # es容器2
    docker run -itd --name es2 -p 9201:9200 -p 9301:9300 \
    -v /elasticsearch/elasticsearch-2.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
    -e ES_JAVA_OPTS="-Xms256m -Xmx256m" elasticsearch:6.8.0
    

    查看两个容器IP

    # 查看es1IP
    docker inspect --format '{{ .NetworkSettings.IPAddress }}' es1
    # 查看es2IP
    docker inspect --format '{{ .NetworkSettings.IPAddress }}' es2
    

    修改elasticsearch-1.yml、elasticsearch-2.yml配置文件IP设置
    重启容器,打开 elasticsearch-head 查看


    image.png

    打开kibana查看


    image.png

    相关文章

      网友评论

          本文标题:docker安装elasticsearch集群

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