PS: 在安装elasticsearch之前请确认jdk是否安装了1.8及以上版本
1、下载及解压elasticsearch
所有release版本:https://www.elastic.co/cn/downloads/past-releases/
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz
tar -zvxf elasticsearch-6.2.4.tar.gz
2、启动elasticsearch
./bin/elasticsearch
此时如果是以root用户操作,会提示:不能以root来运行,因为elasticsearch不允许以root用户运行,所以我们需要新建一个
普通用户来运行,命令如下:
groupadd elk #新增用户组
useradd elk -g elk -p 1234 #新建elk用户所属elk用户组密码为1234
chown -R elk:elk ./elasticsearch-6.2.4 #将elasticsearch目录授权给elk用户
su elk #切换到elk用户
再次启动elasticsearch:./bin/elasticsearch -d # -d表示后台启动
3、安装IK分词器插件
PS:ik分词器插件版本须和elasticsearch版本一致
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.4/elasticsearch-analysis-ik-6.2.4.zip
4、安装过程中遇到的问题
4.1、es不能以root用户运行,须保证非root用户对es目录的权限,在第二步已处理
4.2、问题:max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
解决方法:修改limits.conf配置文件
vi /etc/security/limits.conf 或 sudo vi /etc/security/limits.conf,增加下面两行
* hard nofile 65536
* soft nofile 65536
4.3、问题:max number of threads [1024] for user [lish] likely too low, increase to at least [2048]
解决方法:进入limits.d目录下修改配置文件
vi /etc/security/limits.d/90-nproc.conf 或 sudo vi /etc/security/limits.d/90-nproc.conf
修改 * soft nproc 1024 为 * soft nproc 2048
4.4、问题:max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
解决方法:修改sysctl.conf配置文件
vi /etc/sysctl.conf 或 sudo vi /etc/sysctl.conf,增加下面配置项
vm.max_map_count=262144
保存后,执行命令:sysctl -p
启动成功,访问elasticsearch.yml network.host参数配置地址+http.port参数配置的端口,访问后页面展示如下:
如果访问不了,关闭防火墙或开放http.port参数配置的端口