1 运行环境
虚拟机 centos 7 内存2G
2 创建用户
elasticsearch 不允许使用 root 启动
# 加账户
[root@localhost bin]# adduser es
# 设置密码
[root@localhost bin]# passwd es
# 切换账户
[root@localhost bin]# su es
3 修改目录权限
[root@localhost local]# chown es:es /usr/local/elasticsearch-6.2.4/ -R
4 root 启动报错
[root@localhost bin]# ./elasticsearch
[2018-09-06T00:05:27,296][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
切换成 es 用户启动
5 vm.max_map_count 错误
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决如下:
# 方法1,当前生效,开机消失
[root@localhost bin]# sysctl -w vm.max_map_count=262144
vm.max_map_count = 262144
# 方法2:开机生效
[root@localhost bin]# vim /etc/profile
# 最后追加内容
sysctl -w vm.max_map_count=262144
# 立即生效
[root@localhost bin]# source /etc/profile
5 max file descriptors 错误
ERROR: [1] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解决方案:
# 修改文件
vim /etc/security/limits.conf
# 追加内容
es hard nofile 65536
es soft nofile 65536
6 启动
[es@localhost bin]$ ./elasticsearch
7 查看进程
ps aux|grep elasticsearch
8 访问网址