盒子
盒子
文章目录
  1. 第一步:安装JDK
  2. 第二步:系统配置
    1. 2.1 禁用交换区
    2. 2.2 开最大文件数的限制
    3. 2.3 设置虚拟内存
    4. 2.4 线程数量
  3. 第三步:创建用户并设置密码
  4. 第四步:安装目录介绍
    1. 4.1 创建安装包目录
    2. 4.2 上传压缩包并解压
    3. 4.3 数据日志位置介绍及创建
  5. 4.4 切换至root用户并拷贝config目录
  • 第五步:修改ES基本配置(已下步骤操作均在elasticsearch用户下操作)
    1. 5.1 进入elasticsearch.yml
    2. 5.1 修改elasticsearch.yml配置
    3. 5.1 修改jvm.options配置
    4. 第六步:创建启动脚本(elasticsearch用户目录下) start_elasticsearch.sh
    5. 第七步:验证集群启动情况
    6. 遇到的问题
      1. 低版本的Centos抛出的警告
      2. java.io.IOException: No route to host
  • ElasticSearch7.6集群安装手册

    第一步:安装JDK
    JDK要求jdk1.8+
    
    第二步:系统配置
    2.1 禁用交换区
    1
    sudo swapoff -a
    2.2 开最大文件数的限制
    1
    2
    3
    4
    5
    6
    编辑文件 /etc/security/limits.conf把nofile设置为65536
    或者执行
    echo "* soft nofile 65536" >> /etc/security/limits.conf
    echo "* hard nofile 65536" >> /etc/security/limits.conf
    echo "elasticsearch soft memlock unlimited" >> /etc/security/limits.conf
    echo "elasticsearch hard memlock unlimited" >> /etc/security/limits.conf
    2.3 设置虚拟内存
    1
    2
    3
    临时生效 sysctl -w vm.max_map_count=262144
    永久生效 编辑/etc/sysctl.conf vm.max_map_count
    验证命令 sysctl vm.max_map_count
    2.4 线程数量
    1
    2
    3
    4
    5
    root用户执行 ulimit -u 4096
    或者
    编辑/etc/security/limits.conf把nproc设置为4096
    echo "* soft nproc 4096" >> /etc/security/limits.conf
    echo "* hard nproc 4096" >> /etc/security/limits.conf
    第三步:创建用户并设置密码
    1
    2
    useradd elasticsearch
    passwd elasticsearch
    第四步:安装目录介绍
    4.1 创建安装包目录
    1
    mkdir -p home/shenjian
    4.2 上传压缩包并解压
    1
    2
    tar xf elasticsearch-7.6.2-linux-x86_64.tar.gz -C /usr/local
    tar xf kibana-7.6.2-linux-x86_64.tar.gz -C /usr/local
    4.3 数据日志位置介绍及创建
    目录 位置
    数据目录 /home/elasticsearch/data
    日志目录 /home/elasticsearch/logs
    配置目录 /home/elasticsearch/config
    1
    2
    3
    4
    5
    6
    7
    8
    mkdir /home/elasticsearch
    ## 为elasticsearch用户授予权限
    chown -hR elasticsearch /home/elasticsearch
    ## 请先切换至elasticsearch用户下进行创建目录
    su elasticsearch
    mkdir config
    mkdir logs
    mkdir data
    4.4 切换至root用户并拷贝config目录
    1
    2
    3
    cp /usr/local/elasticsearch-7.6.2/config/* /home/elasticsearch/config
    ## 再次为elasticsearch授权
    chown -hR elasticsearch /home/elasticsearch/*

    第五步:修改ES基本配置(已下步骤操作均在elasticsearch用户下操作)

    5.1 进入elasticsearch.yml
    1
    vi /usr/local/elasticsearch-7.6.2/config/elasticsearch.yml
    5.1 修改elasticsearch.yml配置
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    cluster.name: fangjia
    path.data: /home/elasticsearch/data
    path.logs: /home/elasticsearch/logs
    bootstrap.memory_lock: false
    bootstrap.system_call_filter: false
    http.port: 9200
    discovery.seed_hosts: ["192.168.0.6","192.168.0.7", "192.168.0.8"]
    cluster.initial_master_nodes: ["192.168.0.6","192.168.0.7", "192.168.0.8"]
    node.master: true
    node.data: true
    5.1 修改jvm.options配置
    1
    2
    -Xms20g
    -Xmx20g
    第六步:创建启动脚本(elasticsearch用户目录下) start_elasticsearch.sh
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    ###指定ES的安装目录
    ES_HOME="/usr/local/elasticsearch-7.6.2"
    ###指定ES配置文件的目录
    export ES_PATH_CONF="/home/elasticsearch/config"
    pid=`ps ax | grep elasticsearch | grep java | head -1 | awk '{print $1}'`
    kill -9 $pid
    echo "kill -9 $pid success"
    ulimit -u 4096
    #IP=`ifconfig | grep "inet addr:" |grep 192.168.0| sed '/127/d' | awk '{print $2}' | awk -F : '{print $2}'`
    #echo $IP
    IP=192.168.0.6
    $ES_HOME/bin/elasticsearch -Enode.name=HOST${IP} -Enetwork.host=${IP}
    第七步:验证集群启动情况
    1
    2
    3
    4
    5
    6
    curl http://192.168.0.8:9200/_cat/nodes?pretty

    可以看到打印信息
    192.168.0.7 10 78 0 0.11 0.05 0.06 dilm * HOST192.168.0.7
    192.168.0.8 17 79 1 0.02 0.02 0.05 dilm - HOST192.168.0.8
    192.168.0.6 16 87 29 0.77 0.38 0.18 dilm - HOST192.168.0.6
    遇到的问题
    低版本的Centos抛出的警告
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed
    at org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilter.java:341) ~[elasticsearch-6.2.4.jar:6.2.4]
    at org.elasticsearch.bootstrap.SystemCallFilter.init(SystemCallFilter.java:616) ~[elasticsearch-6.2.4.jar:6.2.4]
    at org.elasticsearch.bootstrap.JNANatives.tryInstallSystemCallFilter(JNANatives.java:258) [elasticsearch-6.2.4.jar:6.2.4]
    at org.elasticsearch.bootstrap.Natives.tryInstallSystemCallFilter(Natives.java:113) [elasticsearch-6.2.4.jar:6.2.4]
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:110) [elasticsearch-6.2.4.jar:6.2.4]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:172) [elasticsearch-6.2.4.jar:6.2.4]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:323) [elasticsearch-6.2.4.jar:6.2.4]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) [elasticsearch-6.2.4.jar:6.2.4]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) [elasticsearch-6.2.4.jar:6.2.4]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) [elasticsearch-6.2.4.jar:6.2.4]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) [elasticsearch-cli-6.2.4.jar:6.2.4]
    at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-cli-6.2.4.jar:6.2.4]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) [elasticsearch-6.2.4.jar:6.2.4]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:85) [elasticsearch-6.2.4.jar:6.2.4]

    解决方案:

    修改elasticsearch.yml 添加一下内容
    bootstrap.memory_lock: false
    bootstrap.system_call_filter: false
    java.io.IOException: No route to host
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    Caused by: java.io.IOException: No route to host
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[?:?]
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:715) ~[?:?]
    at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:330) ~[netty-transport-4.1.43.Final.jar:4.1.43.Final]
    at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334) ~[netty-transport-4.1.43.Final.jar:4.1.43.Final]
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:688) ~[?:?]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysPlain(NioEventLoop.java:600) ~[?:?]
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:554) ~[?:?]
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:514) ~[?:?]
    at io.netty.util.concurrent.SingleThreadEventExecutor$6.run(SingleThreadEventExecutor.java:1050) ~[?:?]
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[?:?]
    at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_281]

    192.168.0.6机器出现该问题,查看防火墙,发现与其他两台不一致
    firewall-cmd --state # 查看防火墙状态
    systemctl stop firewalld.service # 关闭防火墙
    systemctl disable firewalld.service # 禁止开机自启动
    ok,解决
    支持一下
    扫一扫,支持沈健
    • 微信扫一扫
    • 支付宝扫一扫