ES环境搭建

Catalogue
  1. 搭建集群环境
  • 异常
  • 重启win10 子系统
  • Elasticsearch Reference

    搭建集群环境

    下载安装包
    安装步骤

    选择 7.5.0. 更高版本需要jdk9 甚至更高版本.

    1
    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.5.0-linux-x86_64.tar.gz

    后续下载, 先下载jdk11, 然后下载高版本的 es.

    • 下载并解压

    • 修改配置文件

    default : $ES_HOME/config/elasticsearch.yml

    一般需要修改的几个地方如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    # 集群名称
    cluster.name: my-application
    # 节点名称
    node.name: node-1
    # 绑定的IP
    network.host: 192.168.1.106
    # 开始发现新节点的IP
    discovery.zen.ping.unicast.hosts: ["192.168.1.108", "192.168.1.106"]
    # 最多发现主节点的个数
    discovery.zen.minimum_master_nodes: 1
    # 当重启集群节点后最少启动N个节点后开始做恢复
    gateway.recover_after_nodes: 3
    # 在一台机器上最多启动的节点数
    node.max_local_storage_nodes: 1

    具体配置文件解释见: elasticsearch配置文件详解

    配置集群模式,在其它节点修改以上对应配置项,启动即可。

    • 启动
      1
      ./bin/elasticsearch -d 

    异常

    bootstrap check failure [1] of [2]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
    bootstrap check failure [2] of [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

    第二个异常: 原因是 es用户拥有的内存权限太小。 至少需要262144.
    解决方案: sudo sysctl -w vm.max_map_count=262144

    第一个异常:
    解决方案: vim /etc/security/limits.conf, 添加
    tensor soft nofile 65536
    tensor hard nofile 65536

    root soft nofile 65536
    root hard nofile 65536

    https://blog.csdn.net/qq_38636133/article/details/105621876

    验证:

    1
    2
    ulimit -Hu
    ulimit -Su

    ubuntu 环境不生效.

    经过排查,limits.conf这个文件实际是 Linux PAM(插入式认证模块,Pluggable Authentication Modules)中 pam_limits.so模块的配置文件,然而,ubuntu的PAM默认并没有加载这个模块,导致最后limits.conf里面的配置不生效。

    1. sudo vim /etc/pam.d/su

    https://mikemiao.com/ubuntu-limits-conf/

    第三个异常:

    1
    [2]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

    解决: cluster.initial_master_nodes: [“tensor-es”]
    node.name: tensor-es

    最大文件描述符》》》 ubuntu子系统 没法改.

    使用 高版本es.

    配置使用高版本的jdk. JAVA11_HOME=

    重启win10 子系统

    1
    2
    net stop LxssManager
    net start LxssManager