Elasticserach6.x之Head插件安装-yellowcong

不得不说Elasticsearch是个坑,6.x的插件安装和2.x的真尼玛差别真的好大啊。下面写了详细的安装过程,以及安装过程中遇到的坑,希望大家引以为戒,在配置环境的时候,注意版本的问题,安装教程,把版本信息弄清楚。这个head插件依赖于nodejs,phantomjs

安装目录

节点服务目录
192.168.66.100:9200elasticsearch/usr/local/elastic/elasticsearch-6.0.1
nodejs/usr/local/nodejs/node-v8.9.0-linux-x64
phantomjs/usr/local/phantomjs/phantomjs-2.1.1-linux-x86_64
192.168.66.100:9100head/usr/local/elastic/plugins/elasticsearch-head-master

安装前准备

nodejs安装

安装nodejs,同时还需要安装grunt,通过修改/etc/profile来配置nodejs的环境变量不要用,所以通过软连接来配置

#管网地址
https://nodejs.org/en/download/

#我的服务器地址
http://yellowcong.qiniudn.com/node-v8.9.0-linux-x64.tar.xz

#解压,注意是 tar.xz文件
tar -xvf /usr/local/nodejs/node-v8.9.0-linux-x64.tar.xz



#建立node的软连接
ln -s /usr/local/nodejs/node-v8.9.0-linux-x64/bin/node /usr/bin/node
ln -s /usr/local/nodejs/node-v8.9.0-linux-x64/bin/npm /usr/bin/npm


#设定nodejs安装软件的代理服务器
npm config set registry https://registry.npm.taobao.org

#执行npm,安装grunt
npm install -g grunt
npm install -g grunt-cli


#建立软连接 grunt 
ln -s /usr/local/nodejs/node-v8.9.0-linux-x64/bin/grunt /usr/bin/grunt 

phantomjs安装

这个js是在head编译的时候需要

#官网下载地址
https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2

#我自己的下载地址
wget http://yellowcong.qiniudn.com/phantomjs-2.1.1-linux-x86_64.tar.bz2

# 下载好后进行解压(由于是bz2格式,要先进行bzip2解压成tar格式,再使用tar解压)
bzip2 -d phantomjs-2.1.1-linux-x86_64.tar.bz2

# 再使用tar进行解压到/usr/local/目录下边
tar -xvf phantomjs-2.1.1-linux-x86_64.tar -C /usr/local/

# 安装依赖软件
yum -y install wget fontconfig

# 最后一步就是建立软连接了(在/usr/bin/目录下生产一个phantomjs的软连接,/usr/bin/是啥目录应该清楚,不清楚使用 echo $PATH查看)
ln -s /usr/local/phantomjs/bin/phantomjs /usr/bin/ 

测试
这里写图片描述

安装head

#下载地址
wget http://yellowcong.qiniudn.com/elasticsearch-head-master.zip

#安装unzip解压工具(如果没有unzip,就需要安装这个)
yum install -y unzip 

#解压文件到 head
unzip elasticsearch-head-master.zip 

#进入head的目录
cd elasticsearch-head-master/

#安装一下这个bzip2 ,如果没有,在编译head,会报错
yum install -y bzip2

#安装(进入 elasticsearch-head-master)的目录,执行安装命令
sudo npm install

#配置head
#head的启动端口是9100
vim Gruntfile.js
options: {
    //配置0.0.0.0 表示匹配这个主机的所有ip,匹配不上的就会走这个了
        hostname:'0.0.0.0',
        port: 9100,
        base: '.',
        keepalive: true
}

#启动服务
grunt server

进入了 elasticsearch-head-master目录,然后安装
这里写图片描述

设定绑定的ip
这里写图片描述

启动head服务
这里写图片描述

启用http配置

#修改elasticsearch.yml配置文件
vim config/elasticsearch.yml

#加入下面配置
http.cors.enabled: true 
http.cors.allow-origin: "*"

访问测试
这里写图片描述

错误合集

/usr/bin/env: node: 没有那个文件或目录

这里写图片描述

没有找到node这个命令,需要建立软连接到usr/bin目录

ln -s /usr/local/nodejs/node-v8.9.0-linux-x64/bin/node /usr/bin/node

tar (child): bzip2:无法 exec: 没有那个文件或目录

Download already available at /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
Verified checksum of previously downloaded file
Extracting tar contents (via spawned process)
Error extracting archive
Phantom installation failed { Error: Command failed: tar jxf /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar (child): bzip2:无法 exec: 没有那个文件或目录
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

这里写图片描述

解决方案

#安装解压包
yum install -y bzip2

Error: EACCES: permission denied

#需要使用sudo 用管理员来安装,不然没有权限
sudo npm install

这里写图片描述

head没有连接上集群

可以发现集群没有连接上的问题
这里写图片描述

修改config/elasticsearch.yml配置

#修改elasticsearch.yml配置文件
vim config/elasticsearch.yml

#加入下面配置
http.cors.enabled: true 
http.cors.allow-origin: "*"

这里写图片描述

修改后,查看连接情况
这里写图片描述

参考文章

https://www.ibm.com/support/knowledgecenter/zh/SSFPJS_8.5.6/com.ibm.wbpm.main.doc/topics/rfps_esearch_configoptions.html

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

狂飙的yellowcong

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值