ES可视化插件ES-Head安装
一、下载相关软件
选择存放一个目录
下载地址:https://github.com/mobz/elasticsearch-head
终端下载方式:git clone git://github.com/mobz/elasticsearch-head.git
运行ES-Head得先安装 Node.js 环境,地址:https://nodejs.org/en/download/
非常简单直接安装pkg包即可
二、安装 npm
任意目录下运行 执行命令:sudo npm install
三、安装grunt
grunt是基于Node.js的项目构建工具,可以进行打包压缩、测试、执行等等的工作,head插件就是通过grunt启动
执行命令:sudo npm install -g grunt -cli
检查是否安装成功: grunt -version
1589858344122.jpg
四、修改 ES-Head 目录下 _site 文件夹里面的app.js 文件的连接地址
vim _site/app.js
使用 vim搜索关键字 localhost 来到如下位置 (vim搜索关键字方式,在命令行模式下输入 /localhost 后按回车即可定位到位置,然后在按 I 插入修改内容)
(function( app, i18n ) {
var ui = app.ns("ui");
var services = app.ns("services");
app.App = ui.AbstractWidget.extend({
defaults: {
base_uri: null
},
init: function(parent) {
this._super();
this.prefs = services.Preferences.instance();
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200"; //localhost改成你的ES数据源IP,9200改成端口号
if( this.base_uri.charAt( this.base_uri.length - 1 ) !== "/" ) {
// XHR request fails if the URL is not ending with a "/"
this.base_uri += "/";
}
if( this.config.auth_user ) {
var credentials = window.btoa( this.config.auth_user + ":" + this.config.auth_password );
$.ajaxSetup({
headers: {
"Authorization": "Basic " + credentials
}
});
}
this.cluster = new services.Cluster({ base_uri: this.base_uri });
this._clusterState = new services.ClusterState({
cluster: this.cluster
});
this._header = new ui.Header({ cluster: this.cluster, clusterState: this._clusterState });
this.$body = $.joey( this._body_template() );
this.el = $.joey(this._main_template());
this.attach( parent );
this.instances = {};
this.el.find(".uiApp-headerMenuItem:first").click();
if( this.config.dashboard ) {
if( this.config.dashboard === "cluster" ) {
var page = this.instances["ClusterOverview"];
page._refreshButton.set( 5000 );
}
}
},
五、启动并测试
在 elasticsearch-head-master 目录下运行命令
sudo rpm install
grunt server
出现如图所示提示
1589858127277.jpg
这里是不显示ES数据源的IP和端口的,不要以为设置错了
在浏览器中输入 http://localhost:9100 即可访问到 数据源 ES
1589858180155.jpg
PS:运行命令时记得加上 sudo,不然可能提示没有权限创建目录或文件