美文网首页
ES集群模式安装配置入门

ES集群模式安装配置入门

作者: _染123 | 来源:发表于2019-08-27 17:21 被阅读0次

    1.安装OpenJDK1.8+下载ES+5台服务器

    "10.167.20.47"
    "10.167.20.48"
    "10.167.20.49"
    "10.167.20.50"
    "10.167.20.51"
    

    2.创建新用户

    创建新的用户,因为es要求这样。

    //root下执行
    adduser es  //创建用户,起名叫es
    passwd es   //设置密码
    

    建立文件夹,并将es解压

    su es  //切换到es用户
    mkdir /home/es
    tar -zxvf ./elasticsearch-6.8.0.tar.gz /home/es/
    

    3.配置ES

    再创建两个文件夹

    cd /home/es
    mkdir data  //存放切片的数据
    mkdir log   //存放结点日志
    

    确保es文件夹下所有文件的owner属于用户es

    [es@searchdbdl028cn home]$ ll
    total 0
    drwx------. 7 es es 157 Aug 27 14:17 es
    

    如果不是要改

    chown -R es ./es    //改完记得切回es用户
    

    下面开始配置,cd到config目录下,vim elasticsearch.yml 每台都要配置

    # ============================= My Configuration ===============================
    #集群名称
    cluster.name: es-cluster   
    #该结点名称
    node.name: node-02             
    #该结点绑定的ip          
    network.host: 10.167.20.48
    #该节点对外提供服务端口
    http.port: 9200          
    #集群中所有结点                         
    discovery.zen.ping.unicast.hosts: ["10.167.20.47", "10.167.20.48", "10.167.20.49", "10.167.20.50", "10.167.20.51"]
    #当有的结点发生故障时,触发master竞选的最少活跃结点数
    #一般设置为 [总结点数]/2 +1,可以防止脑裂。
    discovery.zen.minimum_master_nodes: 4
    #该结点存储数据位置
    path.data: /home/es/data
    #该结点输出日志位置
    path.logs: /home/es/log
    

    4.启动

    启动的时候要切换到非root用户启动(这里设置了es用户),因为es内部有保护机制防止用root用户权限过多。

    使用CentOS7启动的时候一般会由于系统配置不足产生问题

    ERROR: [2] bootstrap checks failed
    [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
    [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    [2019-08-27T17:11:33,262][INFO ][o.e.n.Node               ] [node-02] stopping ...
    [2019-08-27T17:11:33,275][INFO ][o.e.n.Node               ] [node-02] stopped
    [2019-08-27T17:11:33,276][INFO ][o.e.n.Node               ] [node-02] closing ...
    [2019-08-27T17:11:33,284][INFO ][o.e.n.Node               ] [node-02] closed
    

    解决方法

    [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
    设置每个进程最大同时打开文件数
    切换到root用户,编辑limits.conf添加如下内容
    vi /etc/security/limits.conf
    * soft nofile 65536
    * hard nofile 65536
    
    [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    修改/etc/sysctl.conf文件,增加配置vm.max_map_count=262144
    vi /etc/sysctl.conf
    sysctl -p
    执行命令sysctl -p生效
    

    再启动就可以了

    //后台启动
    ./elasticsearch -d
    
    //查看当前节点信息
    curl http://10.167.20.47:9200
    {
      "name" : "node-01",
      "cluster_name" : "es-cluster",
      "cluster_uuid" : "e1E10qacTl-3keq91oAI_Q",
      "version" : {
        "number" : "6.8.0",
        "build_flavor" : "default",
        "build_type" : "tar",
        "build_hash" : "65b6179",
        "build_date" : "2019-05-15T20:06:13.172855Z",
        "build_snapshot" : false,
        "lucene_version" : "7.7.0",
        "minimum_wire_compatibility_version" : "5.6.0",
        "minimum_index_compatibility_version" : "5.0.0"
      },
      "tagline" : "You Know, for Search"
    }
    
    //查看集群信息
    curl http://10.167.20.47:9200/_cluster/health
    {"cluster_name":"es-cluster","status":"green","timed_out":false,"number_of_nodes":5,"number_of_data_nodes":5,"active_primary_shards":0,"active_shards":0,"relocating_shards":0,"initializing_shards":0,"unassigned_shards":0,"delayed_unassigned_shards":0,"number_of_pending_tasks":0,"number_of_in_flight_fetch":0,"task_max_waiting_in_queue_millis":0,"active_shards_percent_as_number":100.0}
    

    相关文章

      网友评论

          本文标题:ES集群模式安装配置入门

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