前提:
- Elasticsearch 服务要安装好
参考:https://blog.csdn.net/qq_35618489/article/details/87860292
- linux下面要安装git
参考:https://blog.csdn.net/qq_35618489/article/details/87862961
- linux下面安装node
参考:https://blog.csdn.net/qq_35618489/article/details/87863518
简单方法安装:
下载elastichsearch-head插件
Head是elasticsearch的集群管理工具,可以用于数据的浏览和直询
(1)elasticsearch-head是一款开源软件,被托管在github上面,所以如果我们要使用它,必须先安装git,通过git获取elasticsearch-head
(2)运行elasticsearch-head会用到grunt,而grunt需要npm包管理器,所以nodejs是必须要安装的
(3)elasticsearch5.0之后,elasticsearch-head不做为插件放在其plugins目录下 了。使用git拷贝elasticsearch-head到本地
cd /usr/local/
git clone git://github.com/mobz/elasticsearch-head.git
(4)安装elasticsearch-head依赖包
[root@localhost elasticsearch-head]# cd /usr/local/wjx/
[root@localhost wjx]# cnpm install -g grunt-cli
Downloading grunt-cli to /usr/local/wjx/node-v10.15.1/lib/node_modules/grunt-cli_tmp
Copying /usr/local/wjx/node-v10.15.1/lib/node_modules/grunt-cli_tmp/_grunt-cli@1.3.2@grunt-cli to /usr/local/wjx/node-v10.15.1/lib/node_modules/grunt-cli
Installing grunt-cli's dependencies to /usr/local/wjx/node-v10.15.1/lib/node_modules/grunt-cli/node_modules
[1/5] grunt-known-options@~1.1.0 installed at node_modules/_grunt-known-options@1.1.1@grunt-known-options
[2/5] interpret@~1.1.0 installed at node_modules/_interpret@1.1.0@interpret
[3/5] nopt@~4.0.1 installed at node_modules/_nopt@4.0.1@nopt
[4/5] v8flags@~3.1.1 installed at node_modules/_v8flags@3.1.2@v8flags
[5/5] liftoff@~2.5.0 installed at node_modules/_liftoff@2.5.0@liftoff
All packages installed (124 packages installed from npm registry, used 5s(network 5s), speed 166.94kB/s, json 110(132.48kB), tarball 723.76kB)
[grunt-cli@1.3.2] link /usr/local/wjx/node-v10.15.1/bin/grunt@ -> /usr/local/wjx/node-v10.15.1/lib/node_modules/grunt-cli/bin/grunt
[root@localhost wjx]# cd elasticsearch-head/
[root@localhost elasticsearch-head]# cnpm install
? Installed 11 packages
? Linked 0 latest versions
? Run 0 scripts
? All packages installed (used 37ms(network 30ms), speed 0B/s, json 0(0B), tarball 0B)
(5)修改Gruntfile.js
[root@localhost wjx]# cd /usr/local/wjx/elasticsearch-head/
[root@localhost elasticsearch-head]# ls
Dockerfile Gruntfile.js LICENCE plugin-descriptor.properties _site
Dockerfile-alpine grunt_fileSets.js node_modules proxy src
elasticsearch-head.sublime-project index.html package.json README.textile test
[root@localhost elasticsearch-head]# vim Gruntfile.js
在connect-->server--> options下面添加: hostname:' *’ , 允许所有IP可以访问
(6)修改elasticsearch-head默认连接地址
[root@localhost elasticsearch-head]# cd /usr/local/wjx/elasticsearch-head/_site/
[root@localhost _site]# ls
app.css app.js base fonts i18n.js index.html lang vendor.css vendor.js
[root@localhost _site]# vi app.js
将this.base_ uri = this.config.base uri II this.prefs.get(" app-base uri") II "http://localhost:9200";中的localhost修改成你es的服务器ip
(7)配置elasticsearch允许跨域访问
打开elasticsearch的配置文件elasticsearch.yml,在文件末尾追加下面两行代码即可:
[root@localhost elasticsearch-head]# cd /usr/local/wjx/elasticsearch/elasticsearch-6.6.1/config/
[root@localhost config]# vim elasticsearch.yml
添加下面两句话到最下面
http.cors.enabled: true
http.cors.allow-origin: "*"
(9)启动elasticsearch
[root@localhost bin]# su es
[es@localhost bin]$ cd /usr/local/wjx/elasticsearch/elasticsearch-6.6.1/bin/
[es@localhost bin]$ ./elasticsearch
(10)启动elasticsearch-head
[root@localhost /]# cd /usr/local/wjx/elasticsearch-head/node_modules/grunt/bin/
[root@localhost bin]# ls
grunt
[root@localhost bin]# ./grunt server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100
(11)访问 elasticsearch-head
输入地址:http://192.168.162.128:9100/
Elasticsearch-head安装完成