本地環境:Elasticsearch 6.7.1
es5以上版本安裝head需要安裝node和grunt(之前的直接用plugin命令即可安裝)
(一)從地址:https://nodejs.org/en/download/ 下載相應系統的msi,雙擊安裝
(二)安裝完成用cmd進入安裝目錄執行 node -v可查看版本號
(三) 安裝淘寶鏡像
npm install -g cnpm --registry=https://registry.npm.taobao.org
npm 和 cnpm區別
(1) 兩者之間只是 node 中包管理器的不同。
(2) npm是node官方的包管理器。cnpm是個中國版的npm,是淘寶定制的 cnpm (gzip 壓縮支持) 命令行工具代替默認的 npm。
(3)如果因為網絡原因無法使用npm下載,那cnpm這個就派上用場了。
執行 cnpm install -g grunt-cli 安裝grunt
如果報如下錯誤 :無法加載文件 C:\Users\hp\AppData\Roaming\npm\cnpm.ps1,因為在此系統上禁止運行腳本
解決方法:1.以管理員身份運行power shell 2.輸入set-ExecutionPolicy RemoteSigned 然后輸入A 回車
(四)安裝完成后執行grunt -version查看是否安裝成功,會顯示安裝的版本號
(五)開始安裝head
① 進入安裝目錄下的config目錄,修改elasticsearch.yml文件.在文件的末尾加入以下代碼
http.cors.enabled: true http.cors.allow-origin: "*" node.master: true node.data: true
然后去掉network.host: 192.168.0.1的注釋並改為network.host: 127.0.0.1,去掉node.name;http.port的注釋(也就是去掉#)
②雙擊elasticsearch.bat重啟es
③在https://github.com/mobz/elasticsearch-head中下載head插件,選擇下載zip
④解壓到指定文件夾下,E:\program\elasticsearch-6.7.1\elasticsearch-head-master進入該文件夾,修改E:\program\elasticsearch-6.7.1\elasticsearch-head-master\Gruntfile.js 在對應的位置加上hostname:'*'
注意為英文下的 單引號和逗號
⑤在E:\program\elasticsearch-6.7.1\elasticsearch-head-master 下執行cnpm install 安裝完成后執行grunt server 或者cnpm run start 運行head插件,如果不成功重新安裝grunt。成功如下
⑥瀏覽器下訪問http://localhost:9100/
安裝head插件的最簡單的方法:
直接在Chrome中安裝插件: http://sina.lt/ftSr