【云计算】Elasticsearch安装与部署解析
小标 2018-12-13 来源 : 阅读 1060 评论 0

摘要:本文主要向大家介绍了【云计算】Elasticsearch安装与部署解析,通过具体的内容向大家展现,希望对大家学习云计算有所帮助。

本文主要向大家介绍了【云计算】Elasticsearch安装与部署解析,通过具体的内容向大家展现,希望对大家学习云计算有所帮助。


1、Elasticsearch 安装部署


1.1 准备工作及下载


** 1)创建一个es专门的用户(必须),因为es不能用root用户启动。**


useradd es -m
passwd 
mkdir -p /export/servers/es
mkdir -p /export/data/es
mkdir -p /export/logs/es
chown -R es /export/servers/es
chown -R es /export/data/es
chown -R es /export/logs/es


2)切换到es用户下,下载安装包


su es
cd <到es的home目录>
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.0.0.tar.gz
tar -zxvf elasticsearch-6.0.0.tar.gz -C /export/servers/es/


3)修改配置文件


cd /export/servers/es/elasticsearch-6.0.0/config
rm elasticsearch.yml
vi elasticsearch.yml
-
cluster.name: myes
node.name: node03 
path.data: /export/data/es 
path.logs: /export/logs/es 
network.host: 192.168.140.130
http.port: 9200 
discovery.zen.ping.unicast.hosts: ["node02"] 
bootstrap.memory_lock: false
bootstrap.system_call_filter: false


4)修改jvm内存大小


vi jvm.options 
-
-Xms512m
-Xmx512m


1.2 解决启动时报错


5) 启动命令注意啦,同学们!这里是后台启动,要发现错误的话,去logs目录下查看。


nohup /export/servers/es/elasticsearch-6.0.0/bin/elasticsearch >/dev/null 2>&1 &


6)查看错误信息


tail -100f /export/logs/es/myes.log 


核心错误信息


[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [1024] for user [es] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk


7)解决办法


1)max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
原因:无法创建本地文件问题,用户最大可创建文件数太小
解决方案:切换到root用户,编辑limits.conf配置文件, 添加类似如下内容:
vi /etc/security/limits.conf
添加如下内容: 注意*不要去掉了
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

备注:* 代表Linux所有用户名称(比如 hadoop)
需要保存、退出、重新登录才可生效。

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

3)max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
原因:最大虚拟内存太小
每次启动机器都手动执行下。
root用户执行命令:
[root@localhost ~]# sysctl -w vm.max_map_count=262144

4)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.4.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

以上问题解决后,es启动成功了,但又遇到了新的问题,本地机器无法访问虚拟机的服务,两个原因:
1)9200被限制为本机访问,需要在es的配置文件elasticsearch.yml中新增配置:
   network.bind_host:0.0.0.0
2)关闭虚拟机防火墙

解决了这个两个问题后,本地能够顺利访问虚拟机的ES服务了。


注意,以上虚拟内存的更改,每次重启系统之后都要重新设置


ysctl -w vm.max_map_count=262144


8)解决完了之后,再次启动服务(先杀后启)。


ps -ef|grep elasticsearch|grep bootstrap |awk '{print $2}' |xargs kill -9
nohup /export/servers/es/elasticsearch-6.0.0/bin/elasticsearch >/dev/null 2>&1 &


1.3 访问es


9)在Google Chrome浏览器中,访问以下地址:


//node03:9200/pretty


得到以下内容


{
 "name" : "node03",
 "cluster_name" : "myes",
 "cluster_uuid" : "Ir-WWjS8R0KirRVwcjlLlw",
 "version" : {
  "number" : "6.0.0",
  "build_hash" : "8f0685b",
  "build_date" : "2017-11-10T18:41:22.859Z",
  "build_snapshot" : false,
  "lucene_version" : "7.0.1",
  "minimum_wire_compatibility_version" : "5.6.0",
  "minimum_index_compatibility_version" : "5.0.0"
  },
 "tagline" : "You Know, for Search"
}


1.4 安装插件 可视化插件(可选)


严重参考这个文档,感谢!10)安装nodejshead是es的一个可视化插件由于head运行在node.js上,我们需要安装nodejs注意:在root用户下执行


yum install -y gcc-c++ make
# curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
# yum install -y nodejs
cd /export/software/
rz nodejs-5.12.0-1nodesource.el6.x86_64.rpm
rpm -ivh nodejs-5.12.0-1nodesource.el6.x86_64.rpm 
yum install –y git
cd /export/servers/
git clone https://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install -g grunt --registry=https://registry.npm.taobao.org
npm install
npm install grunt --save


11)修改配置文件在Gruntfile.js中添加一行代码


vi /export/servers/elasticsearch-head/Gruntfile.js
找到以下代码:
connect: {
             server: {
                 options: {
                     hostname: '192.168.140.130',
                     port: 9100,
                     base: '.',
                     keepalive: true
                 }
             }
         }
添加一行:
hostname: '192.168.140.130',


在app.js中修改hostname


更改前://localhost:9200
更改后://192.168.140.130:9200


修改elasticsearch.yml文件


su es
vi /export/servers/es/elasticsearch-6.0.0/config/elasticsearch.yml 
-添加一下代码
# 是否支持跨域
http.cors.enabled: true
# *表示支持所有域名
http.cors.allow-origin: "*"


12)重启es服务


注意:使用es用户启动
ps -ef|grep elasticsearch|grep bootstrap |awk '{print $2}' |xargs kill -9
nohup /export/servers/es/elasticsearch-6.0.0/bin/elasticsearch >/dev/null 2>&1 &


13)启动可视化界面启动elasticsearch-head插件


注意:使用root用户启动
/export/servers/elasticsearch-head/node_modules/grunt/bin/grunt server
-
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on //192.168.140.130:9100


访问elasticsearch-head界面


打开Google Chrome访问 
//192.168.140.130:9100/


          

本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标大数据云计算大数据安全频道!

本文由 @小标 发布于职坐标。未经许可,禁止转载。
喜欢 | 0 不喜欢 | 0
看完这篇文章有何感觉?已经有0人表态,0%的人喜欢 快给朋友分享吧~
评论(0)
后参与评论

您输入的评论内容中包含违禁敏感词

我知道了

助您圆梦职场 匹配合适岗位
验证码手机号,获得海同独家IT培训资料
选择就业方向:
人工智能物联网
大数据开发/分析
人工智能Python
Java全栈开发
WEB前端+H5

请输入正确的手机号码

请输入正确的验证码

获取验证码

您今天的短信下发次数太多了,明天再试试吧!

提交

我们会在第一时间安排职业规划师联系您!

您也可以联系我们的职业规划师咨询:

小职老师的微信号:z_zhizuobiao
小职老师的微信号:z_zhizuobiao

版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
 沪公网安备 31011502005948号    

©2015 www.zhizuobiao.com All Rights Reserved