ElasticSearch | 集群部署

ElasticSearch | 集群部署

1. 包解压

2. 用户设置

  • 增加用户:

    useradd es #新增 es 用户
    passwd es #为 es 用户设置密码
    userdel -r es #如果错了,可以删除再加
    chown -R es:es /opt/module/es-cluster #文件夹所有者
    

    3. 系统配置文件修改

    # 修改/etc/security/limits.conf
    # 添加如下 
    es soft nofile 65536
    es hard nofile 65536
    
    # 修改/etc/security/limits.d/20-nproc.conf
    # 添加如下
    es soft nofile 65536
    es hard nofile 65536
    * hard nproc 4096
    
    #修改/etc/sysctl.conf
    # 添加如下
    vm.max_map_count=655360
    
    #重新加载系统配置文件
    sysctl -p
    

4. es配置文件

  • 修改 /opt/module/es/config/elasticsearch.yml

    #集群名称
    cluster.name: cluster-es
    #节点名称,每个节点的名称不能重复
    node.name: node-1
    #ip 地址,每个节点的地址不能重复
    network.host: hadoop101
    #是不是有资格成为主节点
    node.master: true
    node.data: true
    http.port: 9200
    # head 插件需要这打开这两个配置
    http.cors.allow-origin: "*"
    http.cors.enabled: true
    http.max_content_length: 200mb
    #es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举 master
    cluster.initial_master_nodes: ["node-1"]
    #es7.x 之后新增的配置,节点发现
    discovery.seed_hosts: ["hadoop101:9300","hadoop102:9300","hadoop103: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
    

5. 启动

  • 分别启动集群(一个一个启动)

    #切换到es目录
    cd /opt/module/es-cluster
    #启动(前台启动 会占用窗口)
    bin/elasticsearch
    #后台启动(守护进程)
    bin/elasticsearch -d
    
    #检查
    curl -GET http://hadoop101:9200/_cat/nodes
    
posted @ 2021-11-24 18:33  —清风碎心—  阅读(94)  评论(0编辑  收藏  举报