一、下载解压以后修改 elasticsearch.yml
# 集群名字 几个节点要一致
cluster.name: my-es
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
# 节点名称
node.name: node-2
#
# 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: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#
# 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: 172.16.xxx.xxx
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# 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: ["172.16.xxx.xx4","172.16.xxx.xx3","172.16.xxx.xx2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
cluster.initial_master_nodes: ["172.16.xxx.xx4","172.16.xxx.xx3","172.16.xxx.xx2"]
#
# 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
二、启动
./bin/elasticsearch
这里必须用es的账户启动,不然会报异常:
需要把文件夹都赋值es账号权限:
再来试一下:
可以看到已经可以初步启动了,接着往下看启动日志,会发现又出现新的异常:
max number of threads [2048] for user [es] is too low, increase to at least [4096]
最大线程数太小了,修改配置文件
/etc/security/limits.conf
我们需要修改到4096
/etc/security/limits.d/90-nproc.conf
三、再启动
发现还是报异常:
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: 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 /usr/local/elasticsearch-7.6.1/logs/my-es.log
用户内存不够了,需要分配一些:
vm.max_map_count=262144
四、配置不生效处理
如果上边修改的两个文件修改了还是报上边的错误 ,那么很可能是配置没有生效,可以试着操作:
source /ect/... 等
如果还是没生效,那么只能reboot了。
五、启动成功