elasticsearch分片集群搭建

这里准备了三台机子111,112,113以及一台原始配置过es单机的110。

  1. 创建子用户es

    在每台服务器上面执行:
    useradd es #添加es用户
    passwd es #设置密码
    
  2. 将110下面配置好的es发送到另外三台上

    scp -r /home/es/elasticsearch-7.13.2/ es@192.168.31.111:/home/es
    scp -r /home/es/elasticsearch-7.13.2/ es@192.168.31.112:/home/es
    scp -r /home/es/elasticsearch-7.13.2/ es@192.168.31.113:/home/es
    
  3. jdk配置信息也要拷贝过去

    scp -r /home/es/.bash_profile es@192.168.31.111:/home/es
    scp -r /home/es/.bash_profile es@192.168.31.112:/home/es
    scp -r /home/es/.bash_profile es@192.168.31.113:/home/es
    
  4. jdk配置信息也要拷贝过去

    scp -r /home/es/.bash_profile es@192.168.31.111:/home/es
    scp -r /home/es/.bash_profile es@192.168.31.112:/home/es
    scp -r /home/es/.bash_profile es@192.168.31.113:/home/es
    
  5. 我们随便找一台主机运行elasticsearch

    cd /home/es/elasticsearch-7.13.2/bin/
    ./elasticsearch
    

    发现爆了以下三个错误

    ERROR: [3] bootstrap checks failed. You must address the points described in the following [3] lines before starting Elasticsearch.
    bootstrap check failure [1] of [3]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
    bootstrap check failure [2] of [3]: max number of threads [3870] for user [es] is too low, increase to at least [4096]
    bootstrap check failure [3] of [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    ERROR: Elasticsearch did not exit normally - check the logs at /home/es/elasticsearch-7.13.2/path/to/logs/elasticsearch.log
    

    错误一:文件权限不足

    [1]: max file descriptors [4096] for elasticsearch process likely too low,
    increase to at least [65536]

    首先用root用户登录。然后修改配置文件

    su
    vim /etc/security/limits.conf
    

    在结尾处添加以下代码

    * soft nofile 65536
    * hard nofile 131072
    * soft nproc 4096
    * hard nproc 4096
    

    然后切回es用户

    错误二:进程虚拟内存

    max number of threads [1024] for user [es] is too low, increase to at least
    [4096]

    登录root用户,修改配置文件

    su
    vim /etc/security/limits.d/20-nproc.conf
    

    修改下面的内容:

    * soft nproc 1024
    

    改为:

    * soft nproc 4096
    

    错误三:进程虚拟内存

    max virtual memory areas vm.max_map_count [65530] likely too low, increase to
    at least [262144]

    root身份

    vim /etc/sysctl.conf
    

    添加下面内容:

    vm.max_map_count=655360
    

    执行完后

    sysctl -p
    
  6. 修改完后,我们我们再次打开elasticsearch
    页面访问http://192.168.31.111:9200/出现以下代码则代表没有问题。

    {
      "name" : "node-1",
      "cluster_name" : "elasticsearch",
      "cluster_uuid" : "sddmCOeASoutGhwZ02RslQ",
      "version" : {
        "number" : "7.13.2",
        "build_flavor" : "default",
        "build_type" : "tar",
        "build_hash" : "4d960a0733be83dd2543ca018aa4ddc42e956800",
        "build_date" : "2021-06-10T21:01:55.251515791Z",
        "build_snapshot" : false,
        "lucene_version" : "8.8.2",
        "minimum_wire_compatibility_version" : "6.8.0",
        "minimum_index_compatibility_version" : "6.0.0-beta1"
      },
      "tagline" : "You Know, for Search"
    }
    
  7. 集群搭建,清除data和log日志文件,因为这里是scp发送过来的
    需要进行节点查看/home/es/elasticsearch-7.13.2/config/elasticsearch.yml查看路径地址
    三台都要删除

    [es@localhost es]$ cd /home/es/elasticsearch-7.13.2/path/to/data
    [es@localhost es]$ rm -rf *
    [es@localhost es]$ cd /home/es/elasticsearch-7.13.2/path/to/logs
    [es@localhost es]$ rm -rf *
    
  8. 配置

    cd /home/es/elasticsearch-7.13.2/config/
    vim elasticsearch.yml
    

    111节点配置以下内容:

    #node01的配置:
    #集群名称
    cluster.name: my-es
    node.name: node01
    #	是否参加选举
    node.master: true
    #	是否是数据节点
    node.data: true
    network.host: 192.168.31.111
    http.port: 9200
    discovery.seed_hosts: ["192.168.31.111","192.168.31.112","192.168.31.113"]
    cluster.initial_master_nodes: ["node01", "node02", "node03"]
    # 最小节点数
    discovery.zen.minimum_master_nodes: 2
    # 跨域专用
    http.cors.enabled: true
    http.cors.allow-origin: "*"
    
    path.data: /home/es/elasticsearch-7.13.2/path/to/data
    path.logs: /home/es/elasticsearch-7.13.2/path/to/logs
    

    112节点配置以下内容:

    #node01的配置:
    #集群名称
    cluster.name: my-es
    node.name: node02
    #	是否参加选举
    node.master: true
    #	是否是数据节点
    node.data: true
    network.host: 192.168.31.112
    http.port: 9200
    discovery.seed_hosts: ["192.168.31.111","192.168.31.112","192.168.31.113"]
    cluster.initial_master_nodes: ["node01", "node02", "node03"]
    # 最小节点数
    discovery.zen.minimum_master_nodes: 2
    # 跨域专用
    http.cors.enabled: true
    http.cors.allow-origin: "*"
    
    path.data: /home/es/elasticsearch-7.13.2/path/to/data
    path.logs: /home/es/elasticsearch-7.13.2/path/to/logs
    

    113节点配置以下内容:

    	
    #集群名称
    cluster.name: my-es
    node.name: node03
    #	是否参加选举
    node.master: true
    #	是否是数据节点
    node.data: true
    network.host: 192.168.31.113
    http.port: 9200
    discovery.seed_hosts: ["192.168.31.111","192.168.31.112","192.168.31.113"]
    cluster.initial_master_nodes: ["node01", "node02", "node03"]
    # 最小节点数
    discovery.zen.minimum_master_nodes: 2
    # 跨域专用
    http.cors.enabled: true
    http.cors.allow-origin: "*"
    
    path.data: /home/es/elasticsearch-7.13.2/path/to/data
    path.logs: /home/es/elasticsearch-7.13.2/path/to/logs
    
  9. 配置成功后启动三台服务器,等待选举成功。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值