3.head插件安装

head插件安装

1.准备的资料
https://download.csdn.net/download/wuzhuang12/10643242 相关数据下载

http://www.imooc.com/learn/920 相关学习视频

2.1 Head插件简介

ElasticSearch-head是一个H5编写的ElasticSearch集群操作和管理工具,可以对集群进行傻瓜式操作。

  • 显示集群的拓扑,并且能够执行索引和节点级别操作
  • 搜索接口能够查询集群中原始json或表格格式的检索数据
  • 能够快速访问并显示集群的状态
  • 有一个输入窗口,允许任意调用RESTful API。这个接口包含几个选项,可以组合在一起以产生有趣的结果;
  • 5.0版本之前可以通过plugin名安装,5.0之后可以独立运行。

2.2 Head插件安装

(1)安装NodeJS

[root@node1 ~]# yum install -y nodejs

或者自己下载tar文件解压

wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.5.0-linux-x64.tar.gz

tar -zxvf node-v4.5.0-linux-x64.tar.gz

配置下环境变量,编辑/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

  • 1

(2)安装npm

[root@node1 ~]# npm install -g cnpm --registry=https://registry.npm.taobao.org

  • 1

(3)使用npm安装grunt

  1. [root@node1 ~]# npm install -g grunt

  2. npm WARN deprecated coffee-script@1.10.0: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)

  3. npm WARN gentlyRm not removing /usr/bin/grunt as it wasn't installed by /usr/lib/node_modules/grunt

  4. /usr/bin/grunt -> /usr/lib/node_modules/grunt/bin/grunt

  5. /usr/lib

  6. └── grunt@1.0.1

  7. [root@node1 ~]#

  8. [root@node1 ~]# npm install -g grunt-cli --registry=https://registry.npm.taobao.org --no-proxy

  9. /usr/bin/grunt -> /usr/lib/node_modules/grunt-cli/bin/grunt

  10. /usr/lib

  11. └─┬ grunt-cli@1.2.0

  12. ├─┬ findup-sync@0.3.0

  13. │ └─┬ glob@5.0.15

  14. │ ├─┬ inflight@1.0.6

  15. │ │ └── wrappy@1.0.2

  16. │ ├── inherits@2.0.3

  17. │ ├─┬ minimatch@3.0.4

  18. │ │ └─┬ brace-expansion@1.1.8

  19. │ │ ├── balanced-match@1.0.0

  20. │ │ └── concat-map@0.0.1

  21. │ ├── once@1.4.0

  22. │ └── path-is-absolute@1.0.1

  23. ├── grunt-known-options@1.1.0

  24. ├─┬ nopt@3.0.6

  25. │ └── abbrev@1.1.1

  26. └── resolve@1.1.7

  27. [root@node1 ~]#

(4)版本确认

  1. [es@node1 ~]$ node -v
  2. v6.12.0
  3. [es@node1 ~]$ npm -v
  4. 3.10.10
  5. [es@node1 ~]$ grunt -version
  6. grunt-cli v1.2.0
  7. [es@node1 ~]$

(5)下载head插件源码

[es@node1 ~]$ wget https://github.com/mobz/elasticsearch-head/archive/master.zip

  1. 也可以在别的地方下载后上传到服务器
  2. [es@node1 ~]$ ls
  3. master.zip
  4. [es@node1 ~]$ unzip master.zip

(6)下载依赖

进入elasticsearch-head-master目录,执行下面命令

  1. [es@node1 elasticsearch-head-master]$ npm install

  2. phantomjs-prebuilt@2.1.16 install /home/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt

  3. node install.js

  4. PhantomJS not found on PATH

  5. Download already available at /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2

  6. Verified checksum of previously downloaded file

  7. Extracting tar contents (via spawned process)

  8. Removing /home/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt/lib/phantom

  9. Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1515165531727/phantomjs-2.1.1-linux-x86_64 -> /home/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt/lib/phantom

  10. Writing location.js file

  11. Done. Phantomjs binary available at /home/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs

  12. elasticsearch-head@0.0.0 /home/es/elasticsearch-head-master

  13. └─┬ grunt-contrib-jasmine@1.0.3

  14. └─┬ grunt-lib-phantomjs@1.1.0

  15. └── phantomjs-prebuilt@2.1.16

  16. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):

  17. npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression

  18. [es@node1 elasticsearch-head-master]$

如果上面命令安装较慢或失败,可以尝试国内镜像安装

  1. [es@node1 elasticsearch-head-master]$ sudo npm install -g cnpm --registry=https://registry.npm.taobao.org

  2. [sudo] password for es:

  3. /usr/bin/cnpm -> /usr/lib/node_modules/cnpm/bin/cnpm

  4. /usr/lib

  5. └─┬ cnpm@5.1.1

  6. ├─┬ npminstall@3.3.0

  7. │ ├── binary-mirror-config@1.7.3

  8. │ ├── moment@2.20.1

  9. │ └─┬ tar@4.2.0

  10. │ └── minizlib@1.1.0

  11. └─┬ urllib@2.25.3

  12. └─┬ pac-proxy-agent@2.0.0

  13. └─┬ socks-proxy-agent@3.0.1

  14. └─┬ agent-base@4.1.2

  15. └─┬ es6-promisify@5.0.0

  16. └── es6-promise@4.2.2

  17. [es@node1 elasticsearch-head-master]$ cnpm install

  18. ⠸ [6/10] Installing json-schema-traverse@^0.3.0platform unsupported karma@1.3.0 › chokidar@1.7.0 › fsevents@^1.0.0 Package require os(darwin) not compatible with your platform(linux)

  19. [fsevents@^1.0.0] optional install error: Package require os(darwin) not compatible with your platform(linux)

  20. ✔ Installed 10 packages

  21. ✔ Linked 313 latest versions

  22. PhantomJS not found on PATH

  23. Download already available at /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2

  24. Verified checksum of previously downloaded file

  25. Extracting tar contents (via spawned process)

  26. Removing /home/es/elasticsearch-head-master/node_modules/_phantomjs-prebuilt@2.1.16@phantomjs-prebuilt/lib/phantom

  27. Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1515223629881/phantomjs-2.1.1-linux-x86_64 -> /home/es/elasticsearch-head-master/node_modules/_phantomjs-prebuilt@2.1.16@phantomjs-prebuilt/lib/phantom

  28. Writing location.js file

  29. Done. Phantomjs binary available at /home/es/elasticsearch-head-master/node_modules/_phantomjs-prebuilt@2.1.16@phantomjs-prebuilt/lib/phantom/bin/phantomjs

  30. ✔ Run 1 scripts

  31. deprecate grunt-contrib-connect@1.0.2 › http2@^3.3.4 Use the built-in module in node 9.0.0 or newer, instead

  32. deprecate grunt@1.0.1 › coffee-script@~1.10.0 CoffeeScript on NPM has moved to "coffeescript" (no hyphen)

  33. anti semver karma@1.3.0 › useragent@2.2.1 › tmp@0.0.x delcares tmp@0.0.x(resolved as 0.0.33) but using ancestor(karma)'s dependency tmp@0.0.28(resolved as 0.0.28)

  34. ✔ All packages installed (365 packages installed from npm registry, used 17s, speed 497.82kB/s, json 323(581.43kB), tarball 7.64MB)

  35. [es@node1 elasticsearch-head-master]$

2.3 配置

(0)停止ElasticSearch

如果ElasticSearch已经启动,需要先停止

  1. [es@node1 ~]$ jps
  2. 3261 Elasticsearch
  3. 3375 Jps
  4. [es@node1 ~]$ kill 3261

(1)配置 ElasticSearch,使得HTTP对外提供服务

[es@node1 elasticsearch-6.1.1]$ vi config/elasticsearch.yml

添加如下内容

  1. 增加新的参数,这样head插件可以访问es。设置参数的时候:后面要有空格

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

(2)修改Head插件配置文件

[es@node1 elasticsearch-head-master]$ vi Gruntfile.js

找到connect:server,添加hostname一项,如下

  1. connect: {
  2. server: {
  3. options: {
  4. hostname: '0.0.0.0',
  5. port: 9100,
  6. base: '.',
  7. keepalive: true
  8. }
  9. }
  10. }

2.4 启动

(1)启动elasticsearch

首先确认elasticsearch已经启动

  1. [es@node1 elasticsearch-6.1.1]$ bin/elasticsearch -d
  2. [es@node1 elasticsearch-6.1.1]$ jps
  3. 3451 Jps
  4. 3436 Elasticsearch
  5. [es@node1 elasticsearch-6.1.1]$

(2)启动head

通过命令grunt server启动head

[es@node1 elasticsearch-head-master]$ grunt server

  1. 需要在head的目录下运行
  2. Running "connect:server" (connect) task
  3. Waiting forever...
  4. Started connect web server on http://node1:9100

或者通过命令npm run start也可以启动head

  1. [es@node1 elasticsearch-head-master]$ npm run start
  2. elasticsearch-head@0.0.0 start /home/es/elasticsearch-head-master

  3. grunt server

  4. Running "connect:server" (connect) task
  5. Waiting forever...
  6. Started connect web server on http://node1:9100

(3)访问9100端口

http://10.105.45.32:9100/

如果出现“未连接”,请修改localhost为node1,然后单击“连接”按钮

2.5 简单应用

(1)创建索引

  1. [root@node1 ~]# curl -XPUT node1:9200/test
  2. {"acknowledged":true,"shards_acknowledged":true,"index":"test"}[root@node1 ~]#

(2)查看head变化

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 159,015评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,262评论 1 292
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,727评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,986评论 0 205
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,363评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,610评论 1 219
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,871评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,582评论 0 198
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,297评论 1 242
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,551评论 2 246
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,053评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,385评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,035评论 3 236
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,079评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,841评论 0 195
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,648评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,550评论 2 270

推荐阅读更多精彩内容