head 客戶端能夠很方便在上面建立索引,類型,文檔,還有查詢,使用它管理elasticsearch 提升效率.java
在安裝head 客戶端以前必須安裝node.js 環境,由於它是用node.js 編寫的.node
在/usr/local/src 下載 : wget https://npm.taobao.org/mirrors/node/v10.8.0/node-v10.8.0-linux-x64.tar.xzlinux
解壓 tar -xvf node-v10.8.0-linux-x64.tar.xz git
mv node-v6.10.0-linux-x64 /usr/local/nodejs github
配置下環境變量,編輯/etc/profile添加web
export NODE_HOME=/usr/local/nodejs/node-v10.8.0-linux-x64
export PATH=$PATH:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modulesnpm
執行 source /etc/profile瀏覽器
而後驗證安裝是否成功:安全
[root@localhost ~]# node -v
v10.8.0bash
Grunt-cli 只是一個命令行工具
wget https://github.com/mobz/elasticsearch-head/archive/master.zip
解壓:unzip master.zip
而後進入elasticsearch-head-master 目錄
修改elasticsearch-head-master文件下的Gruntfile.js文件中,在options節點下添加一行"hostname: '0.0.0.0',"
connect: { server: { options: { hostname: '0.0.0.0', port: 9100, base: '.', keepalive: true } } }
在 elasticsearch-head-master 目錄下開始安裝
npm install -g cnpm --registry=https://registry.npm.taobao.org
cnpm install
安裝成功後,最後修改elasticsearch的elasticsearch.yml
增長參數,使head插件能夠訪問es
http.cors.enabled: true http.cors.allow-origin: "*"
具體緣由看看github官網的介紹:
鏈接到elasticsearch 默認狀況下,elasticsearch在9200端口上公開一個http rest API, elasticsearch head會鏈接到該端口。 在elasticsearch啓用歌珥 當不做爲elasticsearch的插件運行時(版本5中甚至不可能),必須在elasticsearch中啓用CORS,不然瀏覽器會拒絕看起來不安全的請求。 在elasticsearch配置; 添加http.cors。啓用:真 您還必須設置http.cors。容許原點,由於默認狀況下不容許原點。http.cors。allow-origin:「*」是有效值,可是它被認爲是一種安全風險,由於您的集羣能夠從任何地方跨origin打開。
在 elasticsearch-head-master 路徑下執行
grunt server
(node:3089) ExperimentalWarning: The http2 module is an experimental API. Running "connect:server" (connect) task Waiting forever... Started connect web server on http://localhost:9100
輸出上面信息表明已經啓動成功了,能夠在瀏覽器上輸入地址 http://localhost:9100 訪問