zoukankan      html  css  js  c++  java
  • docker安装es集群

    ELasticsearch的集群是由多个节点组成的,通过cluster.name设置集群名称,并且用于区分其它的集群,每个节点通过node.name指定节点的名称。
    在Elasticsearch中,节点的类型主要有4种:
    master节点

    • 配置文件中node.master属性为true(默认为true),就有资格被选为master节点。
    • master节点用于控制整个集群的操作。比如创建或删除索引,管理其它非master节点等。

    data节点

    • 配置文件中node.data属性为true(默认为true),就有资格被设置成data节点。
    • data节点主要用于执行数据相关的操作。比如文档的CRUD。

    客户端节点

    • 配置文件中node.master属性和node.data属性均为false。
    • 该节点不能作为master节点,也不能作为data节点。
    • 可以作为客户端节点,用于响应用户的请求,把请求转发到其他节点

    部落节点

    • 当一个节点配置tribe.*的时候,它是一个特殊的客户端,它可以连接多个集群,在所有连接的集群上执行搜索和其他操作。

    搭建集群

    准备3台服务器,去拉镜像

    [root@iZ1la3d1xbmukrZ config]# docker images
    REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
    docker.io/elasticsearch   5.6.12              de05e10fa879        17 months ago       486 MB
    [root@iZ1la3d1xbmukrZ config]#

    创建配置文件,做数据卷挂载

    [root@iZbp143t3oxhfc3ar7jey0Z ~]# mkdir /es/config -p
    [root@iZbp143t3oxhfc3ar7jey0Z ~]#  cd /es/config/

    然后创建一个yml配置文件里面的内容为

    cluster.name: elasticsearch-cluster
    node.name: es-node1
    network.host: 0.0.0.0
    network.publish_host: 服务器1的ip
    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: ["服务器1的ip:9300","服务器2的ip:9300","服务器3的ip:9300"]
    discovery.zen.minimum_master_nodes: 2

    注意:最好要3台服务器,要是2台的话,会出现脑裂问题。这是docker的配置,假如你是通过压缩包的方式,就要如下:

    #node01的配置:
    cluster.name: es-itcast-cluster
    node.name: node01
    node.master: true
    node.data: true
    network.host: 0.0.0.0
    http.port: 9200
    discovery.zen.ping.unicast.hosts: ["192.168.40.133","192.168.40.134","192.168.40.135"]
    discovery.zen.minimum_master_nodes: 2
    http.cors.enabled: true
    http.cors.allow-origin: "*"

    是有所不同的,不然集群之间不会通的,我也这样试过

    [root@dalianpai config]# docker run -e ES_JAVA_OPTS="-Xms256m -Xmx256m" -d -p 9200:9200 -p 9300:9300 -v /es/config/es3.yml:/usr/share/elasticsearch/config/elasticsearch.yml  --name ES03  de05e10fa879
    c5b68fc9d1b44c5792788102d79e0605758491c46fbcf4448d7edf93e3476f6e

    启动3台服务器,查看日志

     都是我阿里云的地址,就不显示了。

  • 相关阅读:
    0309. Best Time to Buy and Sell Stock with Cooldown (M)
    0621. Task Scheduler (M)
    0106. Construct Binary Tree from Inorder and Postorder Traversal (M)
    0258. Add Digits (E)
    0154. Find Minimum in Rotated Sorted Array II (H)
    0797. All Paths From Source to Target (M)
    0260. Single Number III (M)
    0072. Edit Distance (H)
    0103. Binary Tree Zigzag Level Order Traversal (M)
    0312. Burst Balloons (H)
  • 原文地址:https://www.cnblogs.com/dalianpai/p/12701635.html
Copyright © 2011-2022 走看看