linux安装Elasticsearch详细步骤
# ## 安装java运行环境
elasticsearch是用Java实现的 跑elasticsearch必须要有jre支持 所以必须先安装jre
可以参考 https://www.cnblogs.com/renxixao/p/11469754.html
# ## 安装elasticsearch-6.2.4
解压后启动 elasticsearch
[[email protected] ~]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz [[email protected] ~]# tar -zxvf elasticsearch-6.2.4.tar.gz -C /usr/local/
[[email protected] ~]# sh /usr/local/elasticsearch-6.2.4/bin/elasticsearch
发现报错了
从5.0开始 elasticsearch 安全级别提高了 不允许采用root帐号启动 所以我们要添加一个用户用来启动 elasticsearch
开始之前先把防火墙关了 耽误事
[[email protected] ~]# systemctl stop firewalld.service [[email protected]~]# systemctl disable firewalld.service//禁止防火墙开机启动 [[email protected] ~]# useradd es//创建es用户 [[email protected] ~]# chown -R es:es /usr/local/elasticsearch-6.2.4///把目录权限赋予给es用户 [[email protected] ~]# su es//切换至es用户 [[email protected] root]$ vi /usr/local/elasticsearch-6.2.4/config/elasticsearch.yml
把 host改为本机地址
记得把前面注释#删掉 再执行 sh /usr/local/elasticsearch-6.2.4/bin/elasticsearch
执行sh /usr/local/elasticsearch-6.2.4/bin/elasticsearch后可能会出现几种报错情况
注意:以下操作都要切换到root下执行
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
修改/etc/security/limits.conf文件 在文件末尾添加如下
[[email protected] root]$ su root
[[email protected]~]# vi /etc/security/limits.conf
* hard nofile 65536
* soft nofile 65536
[2]: max number of threads [3818] for user [es] is too low, increase to at least [4096]
[[email protected] ~]# vi /etc/security/limits.d/20-nproc.conf
* soft nproc 4096
* hard nproc 4096
root soft nproc unlimited
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
/etc/sysctl.conf文件末尾添加 vm.max_map_count = 2621441
[[email protected] ~]# vi /etc/sysctl.conf [[email protected]~]# sudo sysctl -p /etc/sysctl.conf//立即生效
以上三个是常见的三个错误 其余的请自行百度
[[email protected] ~]# ulimit -a
发现当前最大线程数还是为3818 别慌 重启下虚拟机 重启后才能生效
接着切换到es用户启动
[[email protected] ~]# su es [[email protected] root]$ sh/usr/local/elasticsearch-6.2.4/bin/elasticsearch -d //加-d就是启动后台进程 [[email protected] root]$ ps -ef|grep elasticsearch 验证下服务是否正常运行 curl http://192.168.88.133:9200
出来这个 说明配置OK
浏览器请求下 http://192.168.88.133:9200/