ElasticSearch-5.3.1集群环境搭建

服务器(系统版本 centos7)三台(没有的话,可以在一台pc上尝试不同端口):

  1. 172.16.31.220

  2. 172.16.31.221

  3. 172.16.31.224

JDK (下载最新版本JDK,至少JDK1.8,最新版本ES需要1.8的jdk环境)

在这里插入图片描述
配置JDK1.8环境变量(自行解决。。。)

elasticsearch-5.3.1.tar.gz(下载地址:https://www.elastic.co/downloads/elasticsearch)

在220服务器/usr/local/下解压 tar -zxvf elasticsearch-5.3.1.tar.gz,修改配置文件,vim elasticsearch-5.3.1/config/elasticsearch.yml

220服务器,修改后的配置文件:
在这里插入图片描述
在这里插入图片描述
解释:

cluster.name: es-cluster-5.3.1   配置集群名称 三台服务器保持一致

node.name: node-1                配置单一节点名称,每个节点唯一标识

network.host: 0.0.0.0            设置绑定的ip地址

http.port: 9200                  端口

集群节点ip或者主机
discovery.zen.ping.unicast.hosts: ["172.16.31.220", "172.16.31.221","172.16.31.224"]   

设置这个参数来保证集群中的节点可以知道其它N个有master资格的节点。
默认为1,对于大的集群来说,可以设置大一点的值(2-4)
discovery.zen.minimum_master_nodes: 3    

下面两行配置为haad插件配置,三台服务器一致。
http.cors.enabled: true			是否支持跨域
http.cors.allow-origin: "*"		*表示支持所有域名

ok,220服务器修改完毕。
其他服务器除了节点名称和ip,其他的配置都不变

到这里集群就算配置完毕了,但是ES5.3.1不允许使用root用户运行,不然启动会报错:
Exception in thread “main” java.lang.RuntimeException: don’t run elasticsearch as root.

所以新建用户(三台服务器,都要新建)

groupadd elsearch                                   新增elsearch用户组
useradd elsearch -g elsearch -p elasticsearch       创建elsearch用户
chown -R elsearch:elsearch ./elasticsearch-5.3.1    用户目录权限

运行操作,开启三台服务
切换到elsearch用户下,su elsearch,cd /usr/local/elasticsearch-5.3.1 执行命令./bin/elasticsearch
观察运行日志:
在这里插入图片描述
可以看到集群已经成功运行,选举了node-3节点为master节点
测试,节点启动情况: curl http://172.16.31.220:9200/,集群情况安装好了head插件,即可显示
在这里插入图片描述

配置完成之后,启动的时候出现了很多的错误,错误汇总<部分问题来源于网络>:

问题一:

[2016-11-06T16:27:21,712][WARN ][o.e.b.JNANatives ] unable to install syscall filter:
Java.lang.UnsupportedOperationException: seccomp unavailable: requires kernel 3.5+ with CONFIG_SECCOMPandCONFIG_SECCOMP_FILTERcompiledinatorg.elasticsearch.bootstrap.Seccomp.linuxImpl(Seccomp.java:349) ~[elasticsearch-5.0.0.jar:5.0.0]
at org.elasticsearch.bootstrap.Seccomp.init(Seccomp.java:630) ~[elasticsearch-5.0.0.jar:5.0.0]
原因:只是一个警告,主要是因为Linux版本过低造成的。
解决方案:1、重新安装新版本的Linux系统 2、警告不影响使用,可以忽略

问题二:

ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
原因:无法创建本地文件问题,用户最大可创建文件数太小

解决方案:
切换到root用户,编辑limits.conf配置文件, 添加类似如下内容:
vi /etc/security/limits.conf
添加如下内容:
1.* soft nofile 65536
2.* hard nofile 131072
3.* soft nproc 2048
4.* hard nproc 4096
备注:* 代表Linux所有用户名称(比如 hadoop)
保存、退出、重新登录才可生效

问题三:
max number of threads [1024] for user [es] likely too low, increase to at least [2048]
原因:无法创建本地线程问题,用户最大可创建线程数太小
解决方案:切换到root用户,进入limits.d目录下,修改90-nproc.conf 配置文件。
vi /etc/security/limits.d/90-nproc.conf
找到如下内容:
#* soft nproc 1024
修改为
#* soft nproc 2048

问题四:
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,即可启动成功。

问题五:
ElasticSearch启动找不到主机或路由
原因:ElasticSearch 单播配置有问题
解决方案:
检查ElasticSearch中的配置文件
vi config/elasticsearch.yml
找到如下配置:
discovery.zen.ping.unicast.hosts: [“172.16.31.220”, “172.16.31.221”,“172.16.31.224”]
一般情况下,是这里配置有问题,注意书写格式

问题六:
org.elasticsearch.transport.RemoteTransportException: Failed to deserialize exception response from stream
原因:ElasticSearch节点之间的jdk版本不一致
解决方案:ElasticSearch集群统一jdk环境

问题七:
Unsupported major.minor version 52.0
原因:jdk版本问题太低
解决方案:更换jdk版本,ElasticSearch5.0.0支持jdk1.8.0

问题八:
bin/elasticsearch-plugin install license
ERROR: Unknown plugin license

原因:ElasticSearch5.0.0以后插件命令已经改变
解决方案:使用最新命令安装所有插件
bin/elasticsearch-plugin install x-pack

问题九:
启动异常:ERROR: bootstrap checks failed
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.1默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。详见 :https://github.com/elastic/elasticsearch/issues/22899

解决方法:在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false

问题十:
Failed to send join request to master [{node-1}{WbcP0pC_T32jWpYvu5is1A}{2_LCVHx1QEaBZYZ7XQEkMg}{10.10.11.200}{10.10.11.200:9300}], reason [RemoteTransportException[[node-1][10.10.11.200:9300][internal:discovery/zen/join]]; nested: IllegalArgumentException[can’t add node {node-2}{WbcP0pC_T32jWpYvu5is1A}{p-HCgFLvSFaTynjKSeqXyA}{10.10.11.200}{10.10.11.200:9301}, found existing node {node-1}{WbcP0pC_T32jWpYvu5is1A}{2_LCVHx1QEaBZYZ7XQEkMg}{10.10.11.200}{10.10.11.200:9300} with the same id but is a different node instance]; ]

问题原因:要是部署的时候从一个节点复制elasticsearch文件夹,其他节点可能包含被复制节点的data文件数据,需要把data文件下的文件清空

ElasticSearch-head插件在ElasticSearch-5.3.1中的安装使用:

1.安装nodejs环境
1)wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.4.7-linux-x64.tar.gz
2)tar -zxvf node-v4.4.7-linux-x64.tar.gz
3)vim /etc/profile
4)source /etc/profile
5)追加 export PATH=$PATH:/opt/node-v4.4.7-linux-x64/bin 至文件最后

测试  node --version
v4.4.7

2.安装npm
下载nmp安装包,一般nodejs包中已经包含了,设置过环境变量就可以直接使用nmp命令了,如果没有安装,先下载:
  官网地址:www.npmjs.com
  淘宝地址:https://npm.taobao.org/mirrors/npm/
  安装使用如下命令:
  node cli.js install npm -gf

3.安装grunt
1)安装grunt命令行工具grunt-cli npm install -g grunt-cli
2)安装grunt及其插件 npm install grunt --save-dev

可以使用grunt -version查看安装版本情况
然后,在220服务器上,

git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm install grunt --save

修改elasticsearch-head下Gruntfile.js文件,默认监听在127.0.0.1下9200端口
在这里插入图片描述

然后cd /usr/local/elasticsearch-head 执行grunt server
浏览器访问 http://172.16.31.220:9100/
出现一下界面:
在这里插入图片描述
ok 到此,ElasticSearch-5.3.1集群,以及head插件的安装就结束了

文章出处:链接: http://www.cnblogs.com/jstarseven/p/6803054.html.

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值