elasticsearch 安装Head插件

ElasticSearch-Head 是一个与Elastic集群(Cluster)相交互的Web前台。

ES-Head的主要作用:

Bash

它展现ES集群的拓扑结构,并且可以通过它来进行索引(Index)和节点(Node)级别的操作
它提供一组针对集群的查询API,并将结果以json和表格形式返回
它提供一些快捷菜单,用以展现集群的各种状态

5.x以后的版本安装Head插件比较麻烦,不能像2.x的时候一条#elasticsearch/bin/plugin install mobz/elasticsearch-head   #一波搞定

安装Node.js

#由于head插件本质上还是一个nodejs的工程,因此需要安装node,使用npm来安装依赖的包。(npm可以理解为maven),官网nodejs,https://nodejs.org/en/download/

#wget https://nodejs.org/dist/v8.9.1/node-v8.9.1.tar.gz    #新版要编译时间太长了用旧版本吧
# tar zxf node-v8.9.1.tar.gz

#cd node-v8.9.1

#./configure --prefix=/usr/local/node-8.9.1 && make -j 8 && make install   #安装时间比较长,没办法,Centos7的系统要最新版本的nodejs。

# ln -s /usr/local/node-v6.10.2-linux-x64 /usr/local/node

# vim /etc/profile

Bash

############nodejs####################
export NODE_HOME=/usr/local/node
export PATH=$PATH:$NODE_HOME/bin

# source /etc/profile

# node -v

Bash

v8.9.1

# npm -v

Bash

5.5.1

下载插件包

# yum install git -y

# git clone https://github.com/mobz/elasticsearch-head.git   #下载head插件文件
# cd elasticsearch-head/
# npm install -g grunt --registry=https://registry.npm.taobao.org    

 #使用国内淘宝源安装grunt,grunt是基于Node.js的项目构建工具,可以进行打包压缩、测试、执行等等的工作,head插件就是通过grunt启动

Bash

npm WARN deprecated coffee-script@1.10.0: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
/usr/local/node-8.9.1/bin/grunt -> /usr/local/node-8.9.1/lib/node_modules/grunt/bin/grunt
+ grunt@1.0.1
added 92 packages in 10.604s

# ls -d node_modules/grunt

Bash

node_modules/grunt
#如果没产生此目录需要:#cd elasticsearch-head  && npm install grunt --save

安装Head插件

# npm install -g grunt-cli --registry=https://registry.npm.taobao.org 

# npm install  --registry=https://registry.npm.taobao.org   #安装head插件

修改配置文件

# mkdir /home/elk/plugin

# cp -rf /opt/elasticsearch-head /home/elk/plugin/head

# chown -R elk:elk /home/elk

$ vim /home/elk/plugin/head/Gruntfile.js 

Bash

connect: {
                        server: {
                                options: {
                                        port: 9100,
                                        hostname: '*',      #增加此行
                                        base: '.',
                                        keepalive: true

$ vim /home/elk/plugin/head/_site/app.js 

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.14.60:9200";     #这里改成es的IP和端口

$ cd /home/elk/plugin/head/   #一定要进入此目录下启动命令啊

$ grunt server   #服务启动了

Bash

>> Local Npm module "grunt-contrib-jasmine" not found. Is it installed?
(node:1446) ExperimentalWarning: The http2 module is an experimental API.

Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100

image.png

#访问IP:9100的端口可以看到Web页面出来了,但是还是未连接。

解决使用 Head 插件连接不上集群:

$ vim elasticsearch/config/elasticsearch.yml   #加下面两句话

Bash

http.cors.enabled: true
http.cors.allow-origin: "*"

$ /home/elk/elasticsearch/bin/elasticsearch -d   #重新启动es服务

$ pwd

Bash

/home/elk/plugin/head

$ nohup grunt server &   #重新后台运行head插件服务,这个要注意,一定要在插件也就是上方的目录的根目录下,执行此条命令才可以。

image.png

#再次访问web浏览器已经可以了。

#如果安装可kopf监控插件的话,访问链接就是:http://192.168.14.60:9200/_plugin/kopf/#!/cluster    #可以看到java的堆内存节点空间占用等等。

#https://github.com/lmenezes/elasticsearch-kopf   #有安装步骤介绍

#不过kopf已经不维护了,被cerebro所替代了,https://github.com/lmenezes/cerebro/releases   #这个链接可以选择要下载的版本。

#https://www.cnblogs.com/kevingrace/p/5919021.html   #这个链接写的很详细

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值