1、下载安装:elasticsearch-7.6.0-linux-x86_64.tar.gz
    2、登录主机,创建用户

    1. useradd elastic

    3、修改limit.conf
    修改最大文件打开数和不限内存锁

    1. vim /etc/security/limits.conf
    2. * soft nproc 524288
    3. * hard nproc 524288
    4. * soft nofile 524288
    5. * hard nofile 524288
    6. * soft memlock unlimited
    7. * hard memlock unlimited

    4、修改内核配置sysctl.conf
    最大mmp,禁用swap交互空间,socket最大端口范围

    1. vim /etc/sysctl.conf
    2. vm.max_map_count = 262144
    3. vm.swappiness = 1
    4. net.ipv4.ip_local_port_range = 10240 60999
    5. 执行命令:sysctl -p生效

    5、创建es数据目录和日志目录

    1. for i in {1..12};do for j in {1..4};do mkdir -p /HDATA/${i}/es-${j}/data; done;done
    2. for i in {1..12};do for j in {1..4};do chown -R elastic:elastic /HDATA/${i}/es-${j} ; done; done
    3. mkdir /log/es-1 /log/es-2 /log/es-3 /log/es-4
    4. chown -R elastic:elastic /log/es-1 /log/es-2 /log/es-3 /log/es-4

    6、解压安装包

    1. cd /app
    2. tar -zxf elasticsearch-7.6.0-linux-x86_64.tar.gz
    3. ln -s elasticsearch-7.6.0 es-1
    4. chown -R elastic:elastic es-1/

    7、检查主机可配置最大heap大小

    1. /app/es-1/jdk/bin/java -XX:+UnlockDiagnosticVMOptions -Xlog:gc+heap+coops=info

    image2020-3-23_17-47-29.png
    8、修改配置文件
    修改jvm.options,调整合适heap参数

    1. -Xms30g
    2. -Xmx30g
    3. 修改=logs为=/log/es-1

    修改elasticsearch.yml内容

    1. cluster.name: bdp-common-76 # 集群名称
    2. node.name: 10.116.107.215:9300 #节点名称,规范: 【主机ip:es进程端口】
    3. node.attr.rack: r1
    4. node.master: true
    5. node.data: false
    6. http.port: 9200 # es 7.x版本默认开启http服务,端口默认范围:9200-9300,每个实例上指定固定端口
    7. path.data: /HDATA/1/es-1/data,/HDATA/2/es-1/data,/HDATA/3/es-1/data
    8. path.logs: /log/es-1
    9. bootstrap.memory_lock: true
    10. network.host: 10.116.107.215
    11. transport.tcp.port: 9300
    12. discovery.seed_hosts: ["10.116.107.215:9300","10.116.107.216:9300","10.116.107.36:9300"]
    13. gateway.recover_after_nodes: 9 # 建议值:nodes * 3/4
    14. gateway.expected_nodes: 12 # 建议值:nodes num
    15. gateway.recover_after_time: 10m
    16. cluster.routing.allocation.same_shard.host: true
    17. cluster.initial_master_nodes: ["10.116.107.215:9300","10.116.107.216:9300","10.116.107.36:9300"]
    18. xpack.security.enabled: true # 开启基础安全设置
    19. xpack.security.transport.ssl.enabled: true
    20. xpack.security.transport.ssl.verification_mode: certificate
    21. xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
    22. xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

    修改env,使用默认的jdk

    1. vim /app/es-1/bin/elasticsearch-env
    2. 37行添加,
    3. JAVA_HOME="$ES_HOME/jdk"

    9、如果elastic-certificates.p12文件不存在,则创建ca证书,在其中一个node操作即可

    1. cd /app/es-1/bin/
    2. ./elasticsearch-certutil ca
    3. ./elasticsearch-certutil cert --ca elastic-stack-ca.p12
    4. 将生成的文件拷贝至/app/es-1/config/certs/目录
    5. 同时将certs目录拷贝至其他节点

    10、启动实例

    1. su - elastic -c "/app/es-1/bin/elasticsearch -d"

    11、为系统默认用户创建密码

    1. 如果keystore文件不存在,则创建
    2. cd /app/es-1/bin
    3. ./elasticsearch-keystore create
    4. 创建密码:
    5. ./elasticsearch-setup-passwords interactive,回车之后为每一个用户设置独立的密码。记住ES实例必须启动

    12、集群验证

    1. curl -s -u elastic:bdp@elastic 10.116.107.215:9200/_cluster/health?pretty
    2. {
    3. "cluster_name" : "bdp-common-76",
    4. "status" : "green",
    5. "timed_out" : false,
    6. "number_of_nodes" : 12,
    7. "number_of_data_nodes" : 9,
    8. "active_primary_shards" : 4,
    9. "active_shards" : 8,
    10. "relocating_shards" : 0,
    11. "initializing_shards" : 0,
    12. "unassigned_shards" : 0,
    13. "delayed_unassigned_shards" : 0,
    14. "number_of_pending_tasks" : 0,
    15. "number_of_in_flight_fetch" : 0,
    16. "task_max_waiting_in_queue_millis" : 0,
    17. "active_shards_percent_as_number" : 100.0
    18. }

    13、安装kibana