content
Download the installation package of ElasticSeach, this case uses version 6.2.4
Modify the configuration item jvm.options
Modify the configuration item elasticsearch.yml
1.3.1. Error 1: Kernel is too low
1.3.2. Error 2: Insufficient file permissions
1.3.3. Error 3: Not enough threads
1.3.4. Error 4: Process virtual memory
Elasticsearch is a distributed, RESTful search and data analysis engine that addresses a wide variety of emerging use cases. At the heart of the Elastic Stack, it stores your data centrally, helping you discover the unexpected and the unexpected.
Elasticsearch is a JSON-based distributed search and analysis engine.
Developed in the Java language and released as open source under the terms of the Apache License, Elasticsearch is a popular enterprise-grade search engine. Elasticsearch is used in cloud computing to achieve real-time search, stable, reliable, fast, and easy to install and use.
- Distributed real-time file storage, every field is indexed and searchable
- Distributed search engine for real-time analysis
- Scalable to hundreds of servers, processing petabytes of structured or unstructured data
Official website address: Elasticsearch: The official distributed search and analysis engine | Elastic
Preliminary preparation
For security reasons, elasticsearch is not allowed to run as root by default.
ES cannot be installed with the root user, and a normal user is required.
create user
# 创建用户
useradd leyou
# 设置密码
passwd leyou
# 切换用户
su - leyou
Download the installation package of ElasticSeach, this case uses version 6.2.4
# 解压缩安装包
tar -zxvf elasticsearch-6.2.4.tar.gz
# 将文件夹重命名
mv elasticsearch-6.3.0/ elasticsearch
# 进入config目录
cd config
Modify the configuration item jvm.options
# 编辑jvm.options:
vim jvm.options
# 默认配置如下:
-Xms1g
-Xmx1g
内存占用太多了,我们调小一些:
-Xms512m
-Xmx512m
Modify the configuration item elasticsearch.yml
# 编辑elasticsearch.yml
vim elasticsearch.yml
# 修改数据和日志目录:(我们需要按照这个路径创建存储数据和日志的文件夹)
path.data: /home/leyou/elasticsearch/data # 数据目录位置
path.logs: /home/leyou/elasticsearch/logs # 日志目录位置
# 继续修改elasticsearch.yml
# 默认只允许本机访问,修改为0.0.0.0后则可以远程访问
network.host: 0.0.0.0 # 绑定到0.0.0.0,允许任何ip来访问
Solve the error
Start Elasticsearch
Enter the bin directory and enter the startup command
./elasticsearch
Failed to start, there is a problem with the configuration item, which needs to be resolved.
1.3.1. Error 1: Kernel is too low
Modify the elasticsearch.yml file and add the following configuration at the bottom:
bootstrap.system_call_filter: false
1.3.2. Error 2: Insufficient file permissions
报错日志: max file descriptors [4096] for elasticsearch process likely too low, increase to at least
# 退出当前用户
exit
# 提升文件权限
vim /etc/security/limits.conf
# 添加下面的内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096
1.3.3. Error 3: Not enough threads
Error log: max number of threads [1024] for user [leyou] is too low, increase to at least [4096]
# 修改线程数
vim /etc/security/limits.d/90-nproc.conf
或者 vim /etc/security/limits.d/20-nproc.conf
# 将soft nproc 改为:
* soft nproc 4096
1.3.4. Error 4: Process virtual memory
Error log: max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
vim /etc/sysctl.conf
# 添加下面内容:
vm.max_map_count=655360
# 然后执行命令:
sysctl -p
Started successfully
Enter the bin directory, enter the command, and finally print out started, indicating that the startup is successful
./elasticsearch
You can use http://127.0.0.1:9200. If data is returned, it means the startup is successful.