天天看点

elasticsearch-5.5.2安装,及安装遇到的问题

elasticsearch-5.5.2安装

最近在自己电脑上折腾elasticsearch,安装过程中出现许多问题,记录下来,供以后查阅参考,也希望可以帮到遇到同样问题的小伙伴

本人安装的是elasticsearch-5.5.2,软件安装目录

/export/servers

,我采取的是集群安装,三台虚拟机,

node01:192.168.25.120,node02:192.168.25.121,node03:192.168.25.122

.elasticsearch不支持root用户启动,所以需要先建一个普通账户,用普通账户去操作elasticsearch,本人建的普通账户是hadoop,

elasticsearch安装比较简单,下载,解压,然后修改elasticsearch.yml文件,再启动就可以了.安装elasticsearch需要先安装好jdk,这里不再赘述.

#解压
tar -zxvf elasticsearch-5.5.2 -C /export/servers
修改elasticsearch.yml文件
cd /export/servers/elasticsearch-5.5.2/config
vim elasticsearch.yml
#添加以下内容
cluster.name : cluster_es #集群的名称
node.name : es_1 #当前节点代表的名字
#当前es产生的数据和日志存放的位置
path.data : /export/servers/elasticsearch-5.5.2/es_data/datas
path.logs : /export/servers/elasticsearch-5.5.2/es_data/logs
network.host : 192.168.25.120【注意:当前节点的ip】
#集群成员
discovery.zen.ping.unicast.hosts : ["192.168.25.120","192.168.25.121","192.168.25.122"]
#锁内存,不开启
bootstrap.memory_lock : false
bootstrap.system_call_filter : false #安全插件,不安装
http.cors.enabled: true  #可以使用head插件访问es
http.cors.allow-origin: "*"
xpack.security.enabled : false #不开启认证 false
##xpack.monitoring.enabled : true
           

编辑完成保存退出,将es发送到其他两台机器上

scp -r elasticsearch-5.5.2 node02:$PWD scp -r elasticsearch-5.5.2 node03:$PWD

,到另外两台机器上修改elasticsearch.yml文件的network.host 和node.name属性

#node02
vim elasticsearch.yml
node.name : es_2
network.host : 192.168.25.121
#node03
vim elasticsearch.yml
node.name : es_3
network.host : 192.168.25.122
           

修改完成后就可以启动集群了,在三台机器上都启动,进入es的安装目录,启动es

bin/elasticsearch

.

elasticsearch启动遇到的问题

elasticsearch安装好以后启动,遇到很多问题,简单记录一下.

1.Java HotSpot™ 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error=‘Cannot allocate memory’ (errno=12)

这是由于elasticsearch默认分配jvm空间大小2g,这个修改elasticsearch安装目录下config/jvm.options文件就可以了

# vim config/jvm.options
-Xms2g
-Xmx2g
修改为
-Xms1g
-Xmx1g
           

注意,三台机器都需要修改.

2.ERROR: bootstrap checks failed

2.1 max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] max number of threads [1024] for user [hadoop] is too low, increase to at least [2048]

elasticsearch-5.5.2安装,及安装遇到的问题

这个切换到root用户,编辑limits.conf 添加如下内容可以解决

vim /etc/security/limits.conf 
#添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
           

2.2 max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

这个问题,切换到root用户,修改配置sysctl.conf.

vim /etc/sysctl.conf 
#添加下面配置:
vm.max_map_count=655360
#保存退出后,执行命令:
sysctl -p
           

2.3 max number of threads [1024] for user [hadoop] is too low, increase to at least [2048]

这个问题,切换到root用户,修改limits.d下90-nproc.conf .

elasticsearch-5.5.2安装,及安装遇到的问题
vim /etc/security/limits.d/90-nproc.conf 
修改如下内容:
* soft nproc 1024
#修改为
* soft nproc 2048
           

2.4 max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]

这个问题,切换到root用户,给limits.conf添加两行配置

vim /etc/security/limits.conf
*        hard    nofile           65536
*        soft    nofile           65536
           

终于,在报了这么多错误之后,切换到hadoop用户,进入elasticsearch的安装目录,启动es,

bin/elasticsearch

,三台都启动.终于启动成功了.

elasticsearch-5.5.2安装,及安装遇到的问题

本篇博客主要参考了以下博客内容:elasticsearch5.0启动出现的错误,

Elasticsearch5.0 安装问题集锦

继续阅读