红联Linux门户
Linux帮助

RedHat6.4安装Elasticsearch5.2.0

发布时间:2017-03-06 14:58:42来源:linux网站作者:mvpboss1004
elastic的5.2.0版本最近刚刚发布,相比之前版本变动很大,而且其中的所有组件(包括Elasticsearch、Kibana、X-Pack等)都统一到了5.2.0版本。为避免兼容性问题,建议所有组件都使用5.2.0版本。
本文使用环境:elastic 5.2.0套件+RedHat 6.4 64bit,也适用于CentOS。
 
1.下载安装
官网提供了多种安装方式以及详细的安装步骤,这里建议采用下载安装包离线安装的方式,下载链接为:elasticsearch-5.2.0.rpm(https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.0.rpm)。
原因:
国内到官网的网速奇慢无比,而现实中elasitc往往要部署在多台服务器上,采用yum的方式安装每装一台都要花很长时间;
生产环境中,服务器往往不允许访问外网。
下载完成后,rpm -i elasticsearch-5.2.0.rpm即可安装。
 
2.配置
建议修改如下配置。Elasticsearch的日志信息记录在/var/log/elasticsearch下,以集群名开头的文件。如果启动失败,可以查看日志查找原因。
2.1./etc/security/limits.conf
修改以下选项:
* soft nofile 65536
* hard nofile 65536
否则会报以下错误:
bootstrap checks failed
max file descriptors [5000] for elasticsearch process is too low, increase to at least [65536]
2.2./etc/elasticsearch/elasticsearch.yml
cluster.name: CThun:集群名,可修改为业务系统的名字。
node.name: 99.1.36.164:节点名,可修改为IP或主机名便于进行标识。
path.data: /opt/app/data/elasticsearch:数据存放路径,由于数据量非常大,建议放到专用的分区及文件夹,这里是个例子。
另外,elasticsearch安装时会新建elasticsearch用户,并以此用户启动服务,所以不要忘了给此用户授权:
chown -R elasticsearch /opt/app/data/elasticsearch
否则会报以下错误:
java.lang.IllegalStateException: Failed to created node environment
...
...
Caused by: java.nio.file.AccessDeniedException: /opt/app/data/elasticsearch/nodes
network.host: 0.0.0.0:绑定端口,默认为localhost,建议改为0.0.0.0,否则其他机器无法访问到该机器。
discovery.zen.ping.unicast.hosts: ["99.1.36.164"]:master节点清单。
bootstrap.system_call_filter: false:系统调用过滤器,建议禁用该项检查,因为很多检查项需要Linux 3.5以上的内核,而市面上大多数的Linux发行版都未使用Linux 3.5。否则会报以下错误:
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
 
3.启动服务
建议以服务形式启动:
chkconfig --add elasticsearch
service elasticsearch start
启动成功后,访问http://99.1.36.164:9200,即可打开页面。
 
4.使用X-Pack插件
X-Pack插件提供了访问控制、加密、监控等多个功能,强烈建议在生产环境中使用X-Pack插件。下载链接为:x-pack-5.2.0.zip(https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-5.2.0.zip)
假如下载在/root/x-pack-5.2.0.zip,安装很简单:
service elasticsearch stop
/usr/share/elasticsearch/bin/elasticsearch-plugin install file:///root/x-pack-5.2.0.zip
service elasticsearch start
再次访问http://99.1.36.164:9200,默认用户名elastic,密码changeme。可以通过以下方式修改:
curl -XPUT -u elastic '99.1.36.164:9200/_xpack/security/user/elastic/_password' -d '{
"password" : "your_passwd"
}'
未注册的X-Pack只有15天试用期,访问以下链接注册一个Basic license,可以获得一年的试用期:Registration(https://license.elastic.co/registration)
下载license文件并导入:
curl -XPUT -u elastic 'http://99.1.36.164:9200/_xpack/license?acknowledge=true' -d @license.json
 
本文永久更新地址:http://www.linuxdiyf.com/linux/28959.html