ES系列2、CentOS7安裝ES head6.3.1

1.Head插件簡介

ElasticSearch-head是一個H5編寫的ElasticSearch集羣操做和管理工具,能夠對集羣進行傻瓜式操做。css

  • 顯示集羣的拓撲,而且可以執行索引和節點級別操做
  • 搜索接口可以查詢集羣中原始json或表格格式的檢索數據
  • 可以快速訪問並顯示集羣的狀態
  • 有一個輸入窗口,容許任意調用RESTful API。這個接口包含幾個選項,能夠組合在一塊兒以產生有趣的結果;
  • 5.0版本以前能夠經過plugin名安裝,5.0以後能夠獨立運行。

2.Head插件安裝

2.1安裝NodeJS

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

2.2安裝npm

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

2.3使用npm安裝grunt

[root@node1 ~]# npm install -g grunt npm WARN deprecated coffee-script@1.10.0: 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 └── grunt@1.0.1 [root@node1 ~]# 
[root@node1 ~]# npm install -g grunt-cli --registry=https://registry.npm.taobao.org --no-proxy /usr/bin/grunt -> /usr/lib/node_modules/grunt-cli/bin/grunt /usr/lib └─┬ grunt-cli@1.2.0 ├─┬ findup-sync@0.3.0 │ └─┬ glob@5.0.15 │ ├─┬ inflight@1.0.6 │ │ └── wrappy@1.0.2 │ ├── inherits@2.0.3 │ ├─┬ minimatch@3.0.4 │ │ └─┬ brace-expansion@1.1.8 │ │ ├── balanced-match@1.0.0 │ │ └── concat-map@0.0.1 │ ├── once@1.4.0 │ └── path-is-absolute@1.0.1 ├── grunt-known-options@1.1.0 ├─┬ nopt@3.0.6 │ └── abbrev@1.1.1 └── resolve@1.1.7 [root@node1 ~]# 

2.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 ~]$

3.安裝head

3.1下載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 

3.2下載依賴 

    進入elasticsearch-head-master目錄,執行下面命令:node

[es@node1 elasticsearch-head-master]$ npm install > phantomjs-prebuilt@2.1.16 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 elasticsearch-head@0.0.0 /home/es/elasticsearch-head-master └─┬ grunt-contrib-jasmine@1.0.3 └─┬ grunt-lib-phantomjs@1.1.0 └── phantomjs-prebuilt@2.1.16 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 fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression [es@node1 elasticsearch-head-master]$ 

 

若是上面命令安裝較慢或失敗,能夠嘗試國內鏡像安裝linux

[es@node1 elasticsearch-head-master]$ sudo npm install -g cnpm --registry=https://registry.npm.taobao.org [sudo] password for es: /usr/bin/cnpm -> /usr/lib/node_modules/cnpm/bin/cnpm /usr/lib └─┬ cnpm@5.1.1 ├─┬ npminstall@3.3.0 │ ├── binary-mirror-config@1.7.3 │ ├── moment@2.20.1 │ └─┬ tar@4.2.0 │ └── minizlib@1.1.0 └─┬ urllib@2.25.3 └─┬ proxy-agent@2.1.0 └─┬ pac-proxy-agent@2.0.0 └─┬ socks-proxy-agent@3.0.1 └─┬ agent-base@4.1.2 └─┬ es6-promisify@5.0.0 └── es6-promise@4.2.2 [es@node1 elasticsearch-head-master]$ cnpm install ⠸ [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) [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/_phantomjs-prebuilt@2.1.16@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/_phantomjs-prebuilt@2.1.16@phantomjs-prebuilt/lib/phantom Writing location.js file Done. Phantomjs binary available at /home/es/elasticsearch-head-master/node_modules/_phantomjs-prebuilt@2.1.16@phantomjs-prebuilt/lib/phantom/bin/phantomjs ✔ Run 1 scripts deprecate grunt-contrib-connect@1.0.2 › http2@^3.3.4 Use the built-in module in node 9.0.0 or newer, instead deprecate grunt@1.0.1 › coffee-script@~1.10.0 CoffeeScript on NPM has moved to "coffeescript" (no hyphen) 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) ✔ 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]$ 

4.配置

4.1中止ElasticSearch

若是ElasticSearch已經啓動,須要先中止git

[es@node1 ~]$ jps 3261 Elasticsearch 3375 Jps [es@node1 ~]$ kill 3261

4.2配置 ElasticSearch,使得HTTP對外提供服務

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

添加以下內容es6

# 增長新的參數,這樣head插件能夠訪問es。設置參數的時候:後面要有空格 http.cors.enabled: true http.cors.allow-origin: "*"

4.3 修改Head插件配置文件

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

找到connect:server,添加hostname一項,以下github

connect: { server: { options: { hostname: '0.0.0.0', port: 9100, base: '.', keepalive: true } } }

5.啓動

5.1啓動elasticsearch

首先確認elasticsearch已經啓動web

[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]$

5.2啓動head

經過命令grunt server啓動headsql

[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也能夠啓動headexpress

[es@node1 elasticsearch-head-master]$ npm run start > elasticsearch-head@0.0.0 start /home/es/elasticsearch-head-master > grunt server Running "connect:server" (connect) task Waiting forever... Started connect web server on http://node1:9100

5.3訪問9100端口

http://node1:9100/npm

這裏寫圖片描述
若是出現「未鏈接」,請修改localhost爲node1,而後單擊「鏈接」按鈕

這裏寫圖片描述

6 簡單應用

  6.1建立索引

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

  6.2查看head變化 這裏寫圖片描述

相關文章
相關標籤/搜索