1.准备安装包
elasticsearch-7.4.2-linux-x86_64.tar.gz
2.上传至安装目录解压
tar -zxvf /opt/elk/elasticsearch-7.4.2-linux-x86_64.tar.gz
3.创建elsearch用户级用户组
groupadd elsearch
useradd elsearch -g elsearch -p elasticsearch
4.更改elasticsearch文件夹及内部文件的所属用户及组为elsearch:elsearch
cd /opt
chown -R elsearch:elsearch /opt/elk/elasticsearch-7.4.2
5.启动命令
su elsearch ./bin/elasticsearch
su elsearch ./bin/elasticsearch -d # 后端启动
su elsearch ./bin/elasticsearch & # 后端启动
1.简单配置
## elasticsearch.yml
node.name: node-1
bootstrap.memory_lock: true
network.host: 0.0.0.0
discovery.seed_hosts: ["127.0.0.1", "[::1]"]
cluster.initial_master_nodes: ["node-1"]
## ./bin/elasticsearch
ES_JAVA_OPTS="-Xms8g -Xmx8g" # 内存一半
异常
ERROR: bootstrap checks failed memory locking requested for elasticsearch process but memory is not locked
解决
临时解决方法:
ulimit -l unlimited
永久解决方法:root权限编辑/etc/security/limits.conf
sudo vim /etc/security/limits.conf 添加
* soft memlock unlimited
* hard memlock unlimited
修改/etc/sysctl.conf
sudo echo "vm.swappiness=0" >> /etc/sysctl.conf
sudo echo "vm.max_map_count=655360" >> /etc/sysctl.conf
异常
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
解决
ulimit -n 查看
编辑 sudo vim /etc/security/limits.conf
添加
* soft nofile 65536
* hard nofile 65536
vim /etc/profile
添加 ulimit -SHn 65536
source /etc/profile
ulimit -n 查看
异常
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决
echo "vm.max_map_count=262144" > /etc/sysctl.conf
sysctl -p
异常
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:125) ~[elasticsearch-cli-7.4.2.jar:7.4.2]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:115) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:92) ~[elasticsearch-7.4.2.jar:7.4.2]
Caused by: java.lang.IllegalArgumentException
at java.util.concurrent.ThreadPoolExecutor.(ThreadPoolExecutor.java:1293) ~[?:?]
at org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor.(EsThreadPoolExecutor.java:57) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.common.util.concurrent.EsExecutors.newScaling(EsExecutors.java:108) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.threadpool.ScalingExecutorBuilder.build(ScalingExecutorBuilder.java:100) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.threadpool.ScalingExecutorBuilder.build(ScalingExecutorBuilder.java:39) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.threadpool.ThreadPool.(ThreadPool.java:208) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.node.Node.(Node.java:330) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.node.Node.(Node.java:255) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Bootstrap$5.(Bootstrap.java:221) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:221) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:349) ~[elasticsearch-7.4.2.jar:7.4.2]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-7.4.2.jar:7.4.2]
解决
将参数thread_pool.flush.core 的值调小
thread_pool.flush.core: 4