Elasticsearch5.x集群安装及问题汇总

Elasticsearch5.x集群安装及问题汇总


1.安装JDK

Elasticsearch是基于Java开发是一个Java程序,运行在Jvm中,所以第一步要安装JDK

yum install -y java-1.8.0-openjdk-devel

2.下载elasticsearch

ELasticsearch的官方站点
如果需要下载最新的版本,进入官网下载即可。可以下载到本地电脑然后再导入CentOS中,也可以直接在CentOS中下载。

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

3.解压缩文件三份

这里写图片描述

4.修改配置文件

进入es文件conf目录,修改elasticsearch.yml
主要有一下几点:

-----------------------------node-master-------------------------------
//集群名称
cluster.name: es-cluster
//节点名称
node.name: node-master
//本机ip
network.host: 192.168.30.60
//端口
http.port: 9200
//集群通讯端口
transport.tcp.port: 9300
//集群host
discovery.zen.ping.unicast.hosts: ["192.168.30.60:9300","192.168.30.60:9301","192.168.30.60:9302"]
http.cors.enabled: true 
http.cors.allow-origin: "*"
//脑裂
discovery.zen.minimum_master_nodes: 3
-----------------------------node-master-------------------------------

-----------------------------node-1-------------------------------

cluster.name: es-cluster
node.name: node-1
network.host: 192.168.30.60
http.port: 9201
transport.tcp.port: 9301
discovery.zen.ping.unicast.hosts: ["192.168.30.60:9300","192.168.30.60:9301","192.168.30.60:9302"]
http.cors.enabled: true 
http.cors.allow-origin: "*"
discovery.zen.minimum_master_nodes: 3
-----------------------------node-1-------------------------------

-----------------------------node-2-------------------------------
cluster.name: es-cluster
node.name: node-2
network.host: 192.168.30.60
http.port: 9202
transport.tcp.port: 9302
discovery.zen.ping.unicast.hosts: ["192.168.30.60:9300","192.168.30.60:9301","192.168.30.60:9302"]
http.cors.enabled: true 
http.cors.allow-origin: "*"
discovery.zen.minimum_master_nodes: 3
-----------------------------node-2-------------------------------

5.启动各个服务

进入每个es文件下面的bin目录

./elasticsearch   //启动服务

6.错误总结

6.1 root用户不能启动es

解决办法:创建新用户,并赋权,然后登陆新用户,执行启动命令

//创建用户组
groupadd elasticsearch
//创建用户
useradd elasticsearch -g elasticsearch
//给当前新用户赋予es文件夹的权限
chown -R elasticsearch:elasticsearch /usr/local/elasticsearch-5.6.0/
//使用新用户登陆
cd /usr/local/elk/elasticsearch-5.2.1/bin/
//重新执行
./elasticsearch

6.2 当前用户没有es文件夹的权限

问题:
Caused by: java.nio.file.AccessDeniedException: 
/usr/local/elasticsearch-5.6.0/elasticsearch-5.6.0-node1/config/elasticsearch.yml

//报错提示当前用户没有es目录的权限

//使用root用户登陆   给当前新用户赋予es文件夹的权限
chown -R elasticsearch:elasticsearch /usr/local/elasticsearch-5.6.0/

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

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

解决方法:切换到root用户,进入vi /etc/security/limits.conf ,增加配置(保存后注意切回普通用户的时候才能生效,sudo 修改的不能立即生效):

用户名 soft nofile 819200  
用户名 hard nofile 819200  

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

问题:

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

解决:切换到root用户修改配置sysctl.conf

vi /etc/sysctl.conf 

添加下面配置:

vm.max_map_count=655360

并执行命令:

sysctl -p

然后,重新启动elasticsearch,即可启动成功。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值