1. Head插件介绍
Elasticsearch-head是一个H5编写的ElasticSearch集群操作和管理工具H, 能够很方便的查看集群状态以及查询数据,在Elasticseach5.0版本之前,Head可以通过plugins进行安装,但是在5.x及更高的版本是独立运行的,对于Head的安装有多种方式,在此只描述关于用node进行启动的方式。
其他具体方式查看链接: https://github.com/mobz/elasticsearch-head
2. 安装步骤
在elasticsearch5.x之后head不在支持插件安装,变为了一个单独可运行的服务。安装具体步骤如下:
2.1 下载Elasticsearch-Head插件并解压
下载: sudo wget https://codeload.github.com/mobz/elasticsearch-head/zip/master
解压: unzip master
进入解压后的文件夹目录: cd elasticsearch-head-master
2.2 安装node
sudo apt-get install nodejs
2.3 安装npm
sudo apt-get install npm
2.4. 安装grunt和grunt-cli
sudo npm install -g grunt
sudo npm install -g grunt-cli
2.5 安装head需要的一些依赖并且启动
(1) 安装模块依赖
sudo npm install
(2) 启动head
在启动head之前需要修改两个地方的文件配置
- 修改head的连接地址(目录为elasticsearch-head/_site/app.js):
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";
将其中的localhost修改为elasticsearch的对应ip地址,我在这里用域名代替ip
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://qishuiyi.cn:9200";
- 修改服务器的监听地址(目录为elasticsearch-head/Gruntfile.js)
-
connect: {
-
server: {
-
options: {
-
port: 9100,
-
base: '.',
-
keepalive: true
-
}
-
}
-
}
在原有的配置之上加上hostname: '*'
-
connect: {
-
server: {
-
options: {
-
hostname: '*',
-
port: 9100,
-
base: '.',
-
keepalive: true
-
}
-
}
-
}
- 因为head是单独启动的,还需要修改elasticseach的配置文件elasticsearch.yml, 修改对应的ip以及跨域的设置
-
network .host: 0 .0 .0 .0
-
http .cors .enabled: true
-
http .cors .allow-origin: "*"
启动head插件
npm start
注意:elasticseach 和 elasticseach-head都要开着