美文网首页
es-集群扩展节点

es-集群扩展节点

作者: 李哈哈_2c85 | 来源:发表于2023-03-23 09:55 被阅读0次

    以下为es7.2.0版本

    原集群:(现增加两个节点node_76和node_211)
    1、老节点: 下载配置文件elasticsearch.ym、下载秘钥文件elastic-certificates.p12(无密码可以不用)、查看对应版本、查看node节点和集群状态
    [root@elastic20 config]# curl -u elastic:test_elastic 16.168.139.20:9200/_cat/nodes
    16.168.139.116 73 99 1 0.09 0.17 0.16 mdi * node_116
    16.168.139.20  33 99 0 0.16 0.07 0.06 mdi - node_20
    16.168.139.45  46 99 1 0.26 0.16 0.09 mdi - node_45
    
    2、----安装同版本es----
    新节点:
    优化文件描述符、安装jdk、安装同版本es、创建es账号、上传配置文件、秘钥文件,
    修改配置文件中(node名、本机ip、发现ip、可成为主节点ip)启动服务、加入开机启动
    

    安装具体参考:https://www.jianshu.com/p/d584579df340

    配置文件elasticsearch.yml:(我的文件是复制老节点来的,只修改node.name、network.host、cluster.initial_master_nodes、 discovery.seed_hosts)
    带认证的需要拷贝:elastic-certificates.p12这个文件到新节点(和老节点位置一样就行)
    # ======================== Elasticsearch Configuration =========================
     cluster.name: cluster-Es
     node.name: node_76
     network.host: 16.168.139.76
     node.master: true
     node.data: true
     # head 插件需要这打开这两个配置
     http.cors.allow-origin: "*"
     http.cors.enabled: true
     http.max_content_length: 200mb
     # 可以选举的主节点
     cluster.initial_master_nodes: ["16.168.139.20:9300","16.168.139.45:9300","16.168.139.116:9300","16.168.139.211:9300","16.168.139.76:9300"]
     discovery.seed_hosts: ["16.168.139.20:9300","16.168.139.45:9300","16.168.139.116:9300","16.168.139.211:9300","16.168.139.76:9300"]
     gateway.recover_after_nodes: 2
     network.tcp.keep_alive: true
     network.tcp.no_delay: true
     transport.tcp.compress: true
     #集群内同时启动的数据任务个数,默认是2个
     cluster.routing.allocation.cluster_concurrent_rebalance: 16
     #添加或删除节点及负载均衡时并发恢复的线程个数,默认4个
     cluster.routing.allocation.node_concurrent_recoveries: 16
     #初始化数据恢复时,并发恢复线程的个数,默认4个
     cluster.routing.allocation.node_initial_primaries_recoveries: 16
     #开启 xpack 功能,如果要禁止使用密码,请将以下内容注释,直接启动不需要设置密码
     xpack.security.enabled: true
     xpack.security.transport.ssl.enabled: true
     xpack.security.transport.ssl.verification_mode: certificate
     xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
     xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
    
    完成以上步骤后可以查看下nodes和集群状态;
    [root@sxsyjj-ymzs-db-07 data]# curl -u elastic:test_elastic 16.168.139.76:9200/_cat/nodes
    16.168.139.76   8 99 10 0.80 0.77 0.40 mdi - node_76
    16.168.139.45  54 99  9 0.63 0.44 0.31 mdi - node_45
    16.168.139.20  37 93  2 0.66 0.28 0.14 mdi - node_20
    16.168.139.211 54 99  7 0.16 0.14 0.09 mdi - node_211
    16.168.139.116 37 99  5 0.15 0.22 0.17 mdi * node_116
    [root@sxsyjj-ymzs-db-07 ~]# curl -u elastic:test_elastic 16.168.139.76:9200/_cluster/health?pretty
    {
      "cluster_name" : "cluster-Es",
      "status" : "green",
      "timed_out" : false,
      "number_of_nodes" : 5,
      "number_of_data_nodes" : 5,
      "active_primary_shards" : 581,
      "active_shards" : 640,
      "relocating_shards" : 7,
      "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
    }
    [root@sxsyjj-ymzs-db-07 ~]# 
    
    3、老节点--配置文件中以下两项修改为和新节点一样,不用重启(防止下次重启时报警或故障)
     cluster.initial_master_nodes: ["16.168.139.20:9300","16.168.139.45:9300","16.168.139.116:9300","16.168.139.211:9300","16.168.139.76:9300"]
     discovery.seed_hosts: ["16.168.139.20:9300","16.168.139.45:9300","16.168.139.116:9300","16.168.139.211:9300","16.168.139.76:9300"]
    

    参考:
    https://blog.csdn.net/yabingshi_tech/article/details/120909507

    相关文章

      网友评论

          本文标题:es-集群扩展节点

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