2.1 Head插件簡介
ElasticSearch-head是一個H5編寫的ElasticSearch集群操作和管理工具,,可以對集群進行傻瓜式操作,。
- 顯示集群的拓撲,并且能夠執(zhí)行索引和節(jié)點級別操作
- 搜索接口能夠查詢集群中原始json或表格格式的檢索數(shù)據(jù)
- 能夠快速訪問并顯示集群的狀態(tài)
- 有一個輸入窗口,允許任意調(diào)用RESTful API,。這個接口包含幾個選項,可以組合在一起以產(chǎn)生有趣的結(jié)果;
- 5.0版本之前可以通過plugin名安裝,,5.0之后可以獨立運行,。
2.2 Head插件安裝
(1)安裝NodeJS
[root@node1 ~]# yum install -y nodejs
(2)安裝npm
[root@node1 ~]# npm install -g cnpm --registry=https://registry.npm.
(3)使用npm安裝grunt
[root@node1 ~]# npm install -g grunt
npm WARN deprecated [email protected]: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN gentlyRm not removing /usr/bin/grunt as it wasn't installed by /usr/lib/node_modules/grunt
/usr/bin/grunt -> /usr/lib/node_modules/grunt/bin/grunt
/usr/lib
└── [email protected]
[root@node1 ~]#
[root@node1 ~]# npm install -g grunt-cli --registry=https://registry.npm. --no-proxy
/usr/bin/grunt -> /usr/lib/node_modules/grunt-cli/bin/grunt
/usr/lib
└─┬ [email protected]
├─┬ [email protected]
│ └─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └─┬ [email protected]
│ │ ├── [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ └── [email protected]
├── [email protected]
├─┬ [email protected]
│ └── [email protected]
└── [email protected]
[root@node1 ~]#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
(4)版本確認
[es@node1 ~]$ node -v
v6.12.0
[es@node1 ~]$ npm -v
3.10.10
[es@node1 ~]$ grunt -version
grunt-cli v1.2.0
[es@node1 ~]$
(5)下載head插件源碼
[es@node1 ~]$ wget https://github.com/mobz/elasticsearch-head/archive/master.zip
--2017-12-18 09:58:08-- https://github.com/mobz/elasticsearch-head/archive/master.zip
Resolving github.com (github.com)... 192.30.255.113, 192.30.255.112
Connecting to github.com (github.com)|192.30.255.113|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/mobz/elasticsearch-head/zip/master [following]
--2017-12-18 09:58:09-- https://codeload.github.com/mobz/elasticsearch-head/zip/master
Resolving codeload.github.com (codeload.github.com)... 192.30.255.120, 192.30.255.121
Connecting to codeload.github.com (codeload.github.com)|192.30.255.120|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 921421 (900K) [application/zip]
Saving to: ‘master.zip’
100%[===============================================================>] 921,421 9.64KB/s in 67s
2017-12-18 09:59:18 (13.4 KB/s) - ‘master.zip’ saved [921421/921421]
[es@node1 ~]$ ls
master.zip
[es@node1 ~]$ unzip master.zip
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
(6)下載依賴
進入elasticsearch-head-master目錄,,執(zhí)行下面命令
[es@node1 elasticsearch-head-master]$ npm install
> [email protected] install /home/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt
> node install.js
PhantomJS not found on PATH
Download already available at /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
Verified checksum of previously downloaded file
Extracting tar contents (via spawned process)
Removing /home/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt/lib/phantom
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
Writing location.js file
Done. Phantomjs binary available at /home/es/elasticsearch-head-master/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs
[email protected] /home/es/elasticsearch-head-master
└─┬ [email protected]
└─┬ [email protected]
└── [email protected]
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN [email protected] license should be a valid SPDX license expression
[es@node1 elasticsearch-head-master]$
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
如果上面命令安裝較慢或失敗,,可以嘗試國內(nèi)鏡像安裝
[es@node1 elasticsearch-head-master]$ sudo npm install -g cnpm --registry=https://registry.npm.
[sudo] password for es:
/usr/bin/cnpm -> /usr/lib/node_modules/cnpm/bin/cnpm
/usr/lib
└─┬ [email protected]
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └─┬ [email protected]
│ └── [email protected]
└─┬ [email protected]
└─┬ [email protected]
└─┬ [email protected]
└─┬ [email protected]
└─┬ [email protected]
└─┬ [email protected]
└── [email protected]
[es@node1 elasticsearch-head-master]$ cnpm install
? [6/10] Installing json-schema-traverse@^0.3.0platform unsupported [email protected] ? [email protected] ? fsevents@^1.0.0 Package require os(darwin) not compatible with your platform(linux)
[fsevents@^1.0.0] optional install error: Package require os(darwin) not compatible with your platform(linux)
? Installed 10 packages
? Linked 313 latest versions
PhantomJS not found on PATH
Download already available at /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
Verified checksum of previously downloaded file
Extracting tar contents (via spawned process)
Removing /home/es/elasticsearch-head-master/node_modules/[email protected]@phantomjs-prebuilt/lib/phantom
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/[email protected]@phantomjs-prebuilt/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /home/es/elasticsearch-head-master/node_modules/[email protected]@phantomjs-prebuilt/lib/phantom/bin/phantomjs
? Run 1 scripts
deprecate [email protected] ? http2@^3.3.4 Use the built-in module in node 9.0.0 or newer, instead
deprecate [email protected] ? coffee-script@~1.10.0 CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
anti semver [email protected] ? [email protected] ? [email protected] delcares [email protected](resolved as 0.0.33) but using ancestor(karma)'s dependency [email protected](resolved as 0.0.28)
? All packages installed (365 packages installed from npm registry, used 17s, speed 497.82kB/s, json 323(581.43kB), tarball 7.64MB)
[es@node1 elasticsearch-head-master]$
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
2.3 配置
(0)停止ElasticSearch
如果ElasticSearch已經(jīng)啟動,需要先停止
[es@node1 ~]$ jps
3261 Elasticsearch
3375 Jps
[es@node1 ~]$ kill 3261
(1)配置 ElasticSearch,,使得HTTP對外提供服務(wù)
[es@node1 elasticsearch-6.1.1]$ vi config/elasticsearch.yml
添加如下內(nèi)容
# 增加新的參數(shù),,這樣head插件可以訪問es。設(shè)置參數(shù)的時候:后面要有空格
http.cors.enabled: true
http.cors.allow-origin: "*"
(2)修改Head插件配置文件
[es@node1 elasticsearch-head-master]$ vi Gruntfile.js
找到connect:server,添加hostname一項,,如下
connect: {
server: {
options: {
hostname: 'node1',
port: 9100,
base: '.',
keepalive: true
}
}
}
2.4 啟動
(1)啟動elasticsearch
首先確認elasticsearch已經(jīng)啟動
[es@node1 elasticsearch-6.1.1]$ bin/elasticsearch -d
[es@node1 elasticsearch-6.1.1]$ jps
3451 Jps
3436 Elasticsearch
[es@node1 elasticsearch-6.1.1]$
(2)啟動head
通過命令grunt server 啟動head
[es@node1 elasticsearch-head-master]$ grunt server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://node1:9100
或者通過命令npm run start 也可以啟動head
[es@node1 elasticsearch-head-master]$ npm run start
> [email protected] start /home/es/elasticsearch-head-master
> grunt server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://node1:9100
(3)訪問9100端口
http://node1:9100/
如果出現(xiàn)“未連接”,,請修改localhost為node1,然后單擊“連接”按鈕
2.5 簡單應(yīng)用
(1)創(chuàng)建索引
[root@node1 ~]# curl -XPUT node1:9200/test
{"acknowledged":true,"shards_acknowledged":true,"index":"test"}[root@node1 ~]#
(2)查看head變化
|