elasticsearch5.x 叢集管理工具head外掛安裝、nginx配置外網訪問
阿新 • • 發佈:2019-01-23
一、下載安裝包
下載Elasticsearch 5.x
zip和tar格式是各種系統都通用的,解壓之後啟動Elasticsearch即可。
下載elasticsearch-head
二、安裝node、npm、grunt
node下載地址nodejs.org/ (node安裝可參考文章http://blog.csdn.net/kelin_liu/article/details/72729050)
$ node -v
v6.10.3
$ npm -v
3.10.10
使用npm安裝grunt:
npm install –g grunt–cli
三、npm 安裝依賴
到elasticsearch-head-master目錄下,執行命令:
npm install
四、修改Elasticsearch配置檔案
編輯elasticsearch-5.x/config/elasticsearch.yml,加入以下內容:
http.cors.enabled: true
http.cors.allow-origin: "*"
啟動elasticsearch:
$ elasticsearch-5.x/bin/elasticsearch -d
五、修改Gruntfile.js
開啟elasticsearch-head-master/Gruntfile.js,找到下面connect屬性,新增hostname: ‘0.0.0.0’:
connect: { server: { options: { hostname: '0.0.0.0', port: 9100, base: '.', keepalive: true } } }
六、啟動elasticsearch-head
在elasticsearch-head-master/目錄下,執行啟動命令:
grunt server
訪問 http://127.0.0.1:9100/
此url供內網訪問.所以我們利用nginx 配置外網訪問head
七、配置nginx
域名替換成自己的。為了安全,這裡加了nginx 的auth_basic認證。
重啟nginx,訪問 http://elastic.liukelin.top/head/
完成!
5.x後的 elasticsearch 自帶外掛不包含/_plugin/head/,而是使用node另起服務
如果是2.x elasticsearch 直接 $elasticsearch/bin/plugin -install mobz/elasticsearch-head安裝外掛,執行http://localhost:9200/_plugin/head/ 即可,nginx配置也只需配置:
location / {
proxy_pass http://127.0.0.1:9200/;
include proxy_params;
}