使用hadoop账号操作
cd /home/hadoop
安装包下载到/home/hadoop,并解压
elasticsearch.yml配置:
cd elasticsearch-7.7.1/config/
10.130.49.84、10.130.49.96、10.130.49.97”需要换成线上实际的IP
node.name参数3台机器分别为node-1、node-2、node-3
# ======================== Elasticsearch Configuration =========================## NOTE: Elasticsearch comes with reasonable defaults for most settings.# Before you set out to tweak and tune the configuration, make sure you# understand what are you trying to accomplish and the consequences.## The primary way of configuring a node is via this file. This template lists# the most important settings you may want to configure for a production cluster.## Please consult the documentation for further information on configuration options:# https://www.elastic.co/guide/en/elasticsearch/reference/index.html## ---------------------------------- Cluster -----------------------------------## Use a descriptive name for your cluster:#cluster.name: middle-platform-es## ------------------------------------ Node ------------------------------------## Use a descriptive name for the node:#node.name: node-1## Add custom attributes to the node:##node.attr.rack: r1## ----------------------------------- Paths ------------------------------------## Path to directory where to store the data (separate multiple locations by comma):#path.data: /home/aitpm/software/elasticsearch-7.7.1/data## Path to log files:#path.logs: /home/aitpm/software/elasticsearch-7.7.1/logs## ----------------------------------- Memory -----------------------------------## Lock the memory on startup:##bootstrap.memory_lock: true## Make sure that the heap size is set to about half the memory available# on the system and that the owner of the process is allowed to use this# limit.## Elasticsearch performs poorly when the system is swapping the memory.## ---------------------------------- Network -----------------------------------## Set the bind address to a specific IP (IPv4 or IPv6):##network.host: 192.168.0.1network.host: 0.0.0.0## Set a custom port for HTTP:#http.port: 8011## For more information, consult the network module documentation.## --------------------------------- Discovery ----------------------------------## Pass an initial list of hosts to perform discovery when this node is started:# The default list of hosts is ["127.0.0.1", "[::1]"]##discovery.seed_hosts: ["host1", "host2"]discovery.seed_hosts: ["10.130.49.84", "10.130.49.96", "10.130.49.97"]## Bootstrap the cluster using an initial set of master-eligible nodes:##cluster.initial_master_nodes: ["node-1", "node-2"]cluster.initial_master_nodes: ["10.130.49.84", "10.130.49.96", "10.130.49.97"]## For more information, consult the discovery and cluster formation module documentation.## ---------------------------------- Gateway -----------------------------------## Block initial recovery after a full cluster restart until N nodes are started:##gateway.recover_after_nodes: 3## For more information, consult the gateway module documentation.## ---------------------------------- Various -----------------------------------## Require explicit names when deleting indices:##action.destructive_requires_name: true
修改JVM配置:
## JVM configuration################################################################## IMPORTANT: JVM heap size#################################################################### You should always set the min and max JVM heap## size to the same value. For example, to set## the heap to 4 GB, set:#### -Xms4g## -Xmx4g#### See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html## for more information################################################################### Xms represents the initial size of total heap space# Xmx represents the maximum size of total heap space-Xms4g-Xmx4g################################################################## Expert settings#################################################################### All settings below this section are considered## expert settings. Don't tamper with them unless## you understand what you are doing#################################################################### GC configuration8-13:-XX:+UseConcMarkSweepGC8-13:-XX:CMSInitiatingOccupancyFraction=758-13:-XX:+UseCMSInitiatingOccupancyOnly## G1GC Configuration# NOTE: G1 GC is only supported on JDK version 10 or later# to use G1GC, uncomment the next two lines and update the version on the# following three lines to your version of the JDK# 10-13:-XX:-UseConcMarkSweepGC# 10-13:-XX:-UseCMSInitiatingOccupancyOnly14-:-XX:+UseG1GC14-:-XX:G1ReservePercent=2514-:-XX:InitiatingHeapOccupancyPercent=30## JVM temporary directory-Djava.io.tmpdir=${ES_TMPDIR}## heap dumps# generate a heap dump when an allocation from the Java heap fails# heap dumps are created in the working directory of the JVM-XX:+HeapDumpOnOutOfMemoryError# specify an alternative path for heap dumps; ensure the directory exists and# has sufficient space-XX:HeapDumpPath=data# specify an alternative path for JVM fatal error logs-XX:ErrorFile=logs/hs_err_pid%p.log## JDK 8 GC logging8:-XX:+PrintGCDetails8:-XX:+PrintGCDateStamps8:-XX:+PrintTenuringDistribution8:-XX:+PrintGCApplicationStoppedTime8:-Xloggc:logs/gc.log8:-XX:+UseGCLogFileRotation8:-XX:NumberOfGCLogFiles=328:-XX:GCLogFileSize=64m# JDK 9+ GC logging9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
分别启动3台elasticsearch
cd /home/aitpm/software/elasticsearch-7.7.1/bin./elasticsearch -d
查看启动日志:
cd /home/aitpm/software/elasticsearch-7.7.1/logstail-fn 100 *.log
部署可能出现问题问题及解决方法:
1、max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决:
切换到root用户
执行命令:
sysctl -w vm.max_map_count=262144
查看结果:
sysctl -a|grep vm.max_map_count
显示:
vm.max_map_count = 262144
上述方法修改之后,如果重启虚拟机将失效,所以:
解决办法:
在
/etc/sysctl.conf文件最后添加一行
vm.max_map_count=262144
执行下sysctl -p命令
即可永久修改
2、elasticsearch:max file descriptors [4096] for elasticsearch process is too low
解决方案:
su账号修改 /etc/security/limits.conf
在文件末尾增加以下两行:
- soft nofile 65536
- hard nofile 65536
修改为退出ssh,并重新进入生效。
本文详细介绍了如何使用hadoop账号在三台机器上配置和启动Elasticsearch 7.7.1集群。配置包括设置节点名称、网络主机、内存参数以及JVM配置。启动后,通过日志监控确保服务正常运行。同时,文章列举了可能遇到的问题,如max_map_count和最大文件描述符限制,并提供了相应的解决方法。
693





