1. 下载 elasticsearch
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.3.tar.gz
2. 启动 elasticsearch
在CentOS 7下启动es的时候报错java.lang.RuntimeException: can not run elasticsearch as root,发现是由于安全问题elasticsearch 不让用root用户直接运行,所以要创建新用户, CentOS 7创建新用户 adduser XXX 然后给创建的用户加密码 passwd XXX 输入两次密码。切换刚才创建的用户 su XXX 然后执行elasticsearch 会显示Permission denied 权限不足。
给新建的用户XXX赋权限,chmod 777 * 这个不行,因为这个用户本身就没有权限,肯定自己不能给自己付权限。所以要用root用户登录付权限。 su root
root给XXX赋权限,chown -R XXX /你的elasticsearch安装目录。
启动./bin/elasticsearch
3. 在启动过程中遇到的问题。
max file descriptors [65535] 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]
第一步:
#切换到root用户修改
vim /etc/security/limits.conf
# 在最后面追加下面内容(备注:*** 是启动ES的用户)
*** hard nofile 65536
*** soft nofile 65536
第二步:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改/etc/sysctl.conf文件,增加配置vm.max_map_count=262144
vi /etc/sysctl.conf
sysctl -p
执行命令sysctl -p生效
安装 elasticsearch 中文分词插件
bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.5.3/elasticsearch-analysis-ik-6.5.3.zip