ELK-2-Head插件

本文档详细介绍了如何在ElasticSearch上安装和配置Head插件,包括下载源码、修改配置文件以允许跨域访问,并提供测试步骤。通过此教程,读者可以学会如何在非默认端口上运行Head插件,并连接到远程ElasticSearch服务器进行数据可视化管理。
摘要由CSDN通过智能技术生成

ElasticSearch教程——安装Head插件

基础环境

1.本博客是建立在上篇博客ELK安装-1之上

2.需要安装git,理论上也可以通过本地下载然后传输到相应服务器上

3.需要安装nodejs,运行elasticsearch-head会用到grunt,而grunt需要npm包管理器,所以nodejs是必须要安装的。

说明:elasticsearch-head是一个elasticsearch的集群管理、数据可视化、增删查改、查询语句可视化的工具,它是完全由html5编写的独立网页程序。elasticsearch5.0之后,elasticsearch-head不做为插件放在其plugins目录下了,所以可以单独部署一台服务器,没必要和elasticsearch部署在同一台机器,这就需要在下面的文章中配置对应的跨域访问。

一、下载

root权限下执行如下操作

yum install epel-release
yum install nodejs npm
 
 
cd /usr/elasticsearch/
git clone git://github.com/mobz/elasticsearch-head.git

安装依赖包

cd /usr/elasticsearch/elasticsearch-head

cnpm install   //执行后会生成node_modules文件夹

如果遇到异常cnpm不是内部或外部命令 cnpm: command not found,则运行如下脚本,使用淘宝镜像包

npm install cnpm -g --registry=https://registry.npm.taobao.org
配置下环境变量,编辑/etc/profile添加

export NODE_HOME=/usr/local/node-v4.5.0-linux-x64
export PATH=$PATH:$NODE_HOME/bin/
export NODE_PATH=$NODE_HOME/lib/node_modules

执行 source /etc/profile
npm install -g grunt
npm install -g grunt-cli --registry=https://registry.npm.taobao.org --no-proxy 
在执行 cnpm install 

二、修改配置文件

1.修改Gruntfile.js

cd /usr/elasticsearch/elasticsearch-head

vim Gruntfile.js

在该文件中添加如下,务必注意不要漏了添加“,”号,这边的hostname:’*’,表示允许所有IP可以访问,此处也可以修改端口号


server: {
                                 options: {
                                        hostname: '*',
                                        port: 9100,
                                        base: '.',
                                        keepalive: true
                                }
                        }

在这里插入图片描述
2.修改elasticsearch-head默认连接地址

cd /usr/elasticsearch/elasticsearch-head/_site

vi app.js

做如下修改,将ip地址修改为对应的服务器的ip地址
将localhost修改为ESdeIP地址
    修改前:this.base_uri = this.config.base_uri;
    修改后: this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://you ip address:9200";

这边有个问题就是这个文件的内容很大,肉眼一时无法定位,所以要用到搜索,在vi app.js后不要进入编辑模式,使用如下脚本进行搜索“this.base_uri”
/this.base_uri

在这里插入图片描述3.修改ElasticSearch配置文件并启动ElasticSearch

这边需要修改elasticsearch的配置文件elasticsearch.yml,以允许跨域访问,在文末追加如下代码即可

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

修改完毕后重新启动ElasticSearch(注意不能使用root权限启动,具体参考第一篇博文)

systemctl restart elasticsearch.service
    或者
cd /usr/elasticsearch/elasticsearch-7.13.4/
./bin/elasticsearch

启动elasticsearch-head

/usr/elasticsearch/elasticsearch-head

node_modules/grunt/bin/grunt server

三、测试

访问elasticsearch-head

在浏览器输入网址:http://elasticsearch-head的服务器ip:9100,出现如下页面则表示配置成功

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值