Elasticsearch5 安装

centos7 下面安装elasticsearch5

首先安装好jdk,如果需要请查看jdk1.8安装配置

https://blog.wojc.cn/2029.html

【使用root用户操作】

elasticsearch 使用非root用户启动
创建一个用户用来启动es

useradd elastic
passwordd elastic

我这里使用root用户下载并授权给elastic
下载/解压包

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.1.tar.gz
tar xf elasticsearch-5.4.1.tar.gz

移动/更名

mv elasticsearch-5.4.1 /usr/local/elsticsearch
chown -R elastic.elastic /usr/local/elsticsearch

由于系统的一些配置限制导致启动时候的问题,这里写修改需要修改的配置文件
错误1【PS:我这里打开最大文件数是已修改过为65535的,es提示要65536】

max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
解决:
vim /etc/security/limits.conf
#添加下面内容
* soft nofile 65536
* hard nofile 65536

错误2【max number of threads [1024] for user [elk] is too low, increase to at least [2048]】

解决:
vim /etc/security/limits.d/90-nproc.conf
#修改为2048
* soft nproc 2048
root soft nproc unlimited

错误3【max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]】

解决:
vim /etc/sysctl.conf 
#添加下面一句
vm.max_map_count=262144
#再执行读取生效下
sysctl -p

#错误4【centos6.* 下面会报一个错误】
[2017-07-14T19:35:42,948][ERROR][o.e.b.Bootstrap ] [node-1] node validation exception
[1] bootstrap checks failed
[1]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
这是在因为Centos6不支持SecComp,而ES5.2.0默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。

解决:
配置文件加入:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

 

【使用elastic用户操作】

切换到elastic用户

su - elastic

修改配置文件

vim /usr/local/elsticsearch/config/elasticsearch.yml
#修改下面几项(名称自定义)
cluster.name: my-elk
node.name: elk-1
network.host: 0.0.0.0
http.port: 9200

启动

/usr/local/elsticsearch/bin/elasticsearch -d

#查看端口启动情况
netstat -lntp |egrep "9200|9300"
tcp 0 0 0.0.0.0:9200 0.0.0.0:* LISTEN 14203/java 
tcp 0 0 0.0.0.0:9300 0.0.0.0:* LISTEN 14203/java

#启动成功,如果没有端口查看日志中错误,自行百度谷歌

查看程序日志

cat /usr/local/elsticsearch/logs/elasticsearch.log

#如果机器配置低的话,elsticsearch 默认2G的内存,需要修改内存

vim /usr/local/elsticsearch/config/jvm.options
#默认为2g,修改为适当的值,我这里机器4G内存,修改为1G或者512m
-Xms1g
-Xmx1g
或
-Xms512m
-Xmx512m

https://blog.wojc.cn/2221.html

分享