一、简介:
elasticsearch-head是一个用于浏览ElasticSearch集群并与其进行交互的Web项目
https://github.com/mobz/elasticsearch-head
二、安装
sudo elasticsearch/bin/plugin install mobz/elasticsearch-head
sudo elasticsearch/bin/plugin -install mobz/elasticsearch-head/1.x
sudo elasticsearch/bin/plugin -install mobz/elasticsearch-head/0.9
(Chrome扩展程序)
https://chrome.google.com/webstore/detail/elasticsearch-head/ffmkiejjmecolpfloofpjologoblkegm/
[root@gameServer local]# su payment [payment@gameServer local]$ cd ~/elasticSearch/ [payment@gameServer elasticSearch]$ ll 总用量 28388 drwxr-xr-x. 9 payment payment 4096 6月 6 10:21 elasticsearch-6.2.4-1 drwxr-xr-x. 9 payment payment 4096 6月 6 14:13 elasticsearch-6.2.4-2 drwxr-xr-x. 9 payment payment 4096 6月 6 14:13 elasticsearch-6.2.4-3 -rw-rw-r--. 1 payment payment 29056810 5月 15 12:56 elasticsearch-6.2.4.tar.gz [payment@gameServer elasticSearch]$ git clone git://github.com/mobz/elasticsearch-head.git Initialized empty Git repository in /home/payment/elasticSearch/elasticsearch-head/.git/ remote: Counting objects: 4224, done. remote: Total 4224 (delta 0), reused 0 (delta 0), pack-reused 4224 Receiving objects: 100% (4224/4224), 2.16 MiB | 875 KiB/s, done. Resolving deltas: 100% (2329/2329), done. [payment@gameServer elasticSearch]$
#使用淘宝的镜像库进行下载,速度很快 npm config set registry https://registry.npm.taobao.org
我这里不建议使用:我在使用过程中、出现了找不到包
我用的官网的
npm config set registry http://registry.cnpmjs.org
[payment@gameServer elasticsearch-head]$ npm config set registry http://registry.cnpmjs.org [payment@gameServer elasticsearch-head]$ [payment@gameServer elasticsearch-head]$ npm install npm WARN deprecated http2@3.3.7: Use the built-in module in node 9.0.0 or newer, instead npm WARN deprecated coffee-script@1.10.0: CoffeeScript on NPM has moved to "coffeescript" (no hyphen) > phantomjs-prebuilt@2.1.16 install /home/payment/elasticSearch/elasticsearch-head/node_modules/phantomjs-prebuilt > node install.js PhantomJS not found on PATH Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2 Saving to /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2 Receiving... [=======================================-] 98% Received 22866K total. Extracting tar contents (via spawned process) Removing /home/payment/elasticSearch/elasticsearch-head/node_modules/phantomjs-prebuilt/lib/phantom Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1528505043238/phantomjs-2.1.1-linux-x86_64 -> /home/payment/elasticSearch/elasticsearch-head/node_modules/phantomjs-prebuilt/lib/phantom Writing location.js file Done. Phantomjs binary available at /home/payment/elasticSearch/elasticsearch-head/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs npm notice created a lockfile as package-lock.json. You should commit this file. npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) added 382 packages in 44.016s [payment@gameServer elasticsearch-head]$ [payment@gameServer elasticsearch-head]$ npm run start > elasticsearch-head@0.0.0 start /home/payment/elasticSearch/elasticsearch-head > grunt server (node:9942) ExperimentalWarning: The http2 module is an experimental API. Running "connect:server" (connect) task Waiting forever... Started connect web server on http://localhost:9100
修改配置:并且后台启动
[payment@gameServer elasticsearch-head]$ pwd /home/payment/elasticSearch/elasticsearch-head [payment@gameServer elasticsearch-head]$ vim Gruntfile.js # 找到并修改如下配置 connect: { server: { options: { port: 9100, base: '.', keepalive: true, hostname: '*' } } } [payment@gameServer elasticsearch-head]$ vim _site/app.js # 找到如下配置并修改: this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://172.17.63.15:9200"; [payment@gameServer elasticsearch-head]$ npm run start &
三、ElasticSeatch修改配置(已经配置的忽略此步)
连接到elasticsearch
默认情况下,elasticsearch会在弹性搜索头连接的端口9200上公开一个http rest API。
在elasticsearch中启用CORS
当不作为elasticsearch的插件运行时,您必须在elasticsearch中启用CORS,否则您的浏览器将拒绝跨域。
在elasticsearch配置中;
http.cors.enabled: true
- 您还必须设置,
http.cors.allow-origin
因为默认情况下不允许跨域。是允许配置的,但由于这样配置的任何地方都可以访问,所以有安全风险。
http.cors.enabled: true http.cors.allow-origin: "*"
四、测试head插件(选择你对应的安装方式)
修改链接地址:链接集群 你可以看到节点信息 以及状态
文章来源: 四、安装ElasticSearch Head插件