一、检测是否已经安装的elasticsearch
ps aux|grep elasticsearch
二、下载elasticsearch
cd /usr/local
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.7.tar.gz
三、解压安装
tar -zxvf elasticsearch-5.6.7.tar.gz
mv elasticsearch-5.6.7.tar.gz elasticsearch
四、修改配置文件
1:进入如下目录
cd /usr/local/elasticsearch/config
vi elasticsearch.yml
添加如下代码(若无将会出现下面常见问题2):
vm.max_map_count=262144
在memory下添加如下(若无将会出现下面常见问题4):
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
退出保存后执行如下命令:
sysctl -p
2:修改如下文件
vi /etc/security/limits.conf
在文件末尾添加如下代码(若无将会出现下面常见问题3):
# python为登录服务器的用户名
python soft nofile 65536
python hard nofile 65536
python soft nproc 4096
python hard nproc 4096
3:创建python用户(root用户不能启动elasticsearch)
useradd python
passwd python
按提示输入两次密码:python
然后授权:
cd /usr/local
sudo chown -R python:python elasticsearch
切换用户
su - python
五、启动elasticsearch
1:控制台启动(ctrl+c 后停止):
./bin/elasticsearch
2:后台启动:
./bin/elasticsearch -d
六、常见问题
1:can not run elasticsearch as root
Elasticsearch版本> = 5.0.0时,是不可用超级管理员运行Elasticsearch的,退出管理员账号,切换成普通用户登录即可
2:
max virutal memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方案,请看上面修改配置文件第2项
3:max number of threads [3750] for user [xxx] is too low, increase to at least [4096]
具体修改配置,请看修改配置文件第3项
4:bootstrap checks failed system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
具体修改配置,请看修改配置文件第4项