Elasticsearch 5.3.x 使用 Head 插件
0、前言
時(shí)光荏苒,ES轉(zhuǎn)眼間就從2.X跳到了5.X。。。
憶往昔崢嶸歲月,奈何ES社區(qū)太活躍,版本跳的比房?jī)r(jià)還快啊。。。
?
話(huà)說(shuō)回來(lái),需要部署一套Elasticsearch 5.2.1 即本月最新推出的ES新力作,發(fā)現(xiàn)很多用法已經(jīng)不一樣了。。。
?
本次首先說(shuō)Head插件的安裝:?
1、安裝插件head
| 1 2 3 4 5 6 7 8 9 10 11 | # 去github上下載head git clone git://github.com/mobz/elasticsearch-head.git # 由于head基于nodejs所以安裝它 yum -y?install?nodejs npm npm?install?grunt-cli npm?install?grunt grunt -version # 修改配置文件 cd?elasticsearch-head vim _site/app.js # 修改 『http://localhost:9200』字段到本機(jī)ES端口與IP |
2、啟動(dòng)head
| 1 2 3 | cd?elasticsearch-head grunt server # 打開(kāi)瀏覽器 http://localhost:9100 |
3、出現(xiàn)問(wèn)題
head主控頁(yè)面是可以顯示的,但是顯示連接失敗
“集群健康值: 未連接”
4、解決方案
修改elasticsearch.yml文件
| 1 2 3 4 | vim $ES_HOME$/config/elasticsearch.yml # 增加如下字段 http.cors.enabled:?true http.cors.allow-origin:?"*" |
重啟es和head即可
5、CORS是什么(這個(gè)格式我真服了博客園了)
?
wiki上的解釋是?Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources ,即跨域訪(fǎng)問(wèn)。
這個(gè)字段默認(rèn)為false,在Elasticsearch安裝集群之外的一臺(tái)機(jī)上用Sense、Head等監(jiān)控插件訪(fǎng)問(wèn)Elasticsearch是不允許的。這個(gè)字段最早可以追溯到1.4.x版本,而非5.x特有。
具體這個(gè)http.cors.x字段還有哪些用途和用法,見(jiàn)下表:
?
| http.cors.enabled | 是否支持跨域,默認(rèn)為false |
| http.cors.allow-origin | 當(dāng)設(shè)置允許跨域,默認(rèn)為*,表示支持所有域名,如果我們只是允許某些網(wǎng)站能訪(fǎng)問(wèn),那么可以使用正則表達(dá)式。比如只允許本地地址。?/https?:\/\/localhost(:[0-9]+)?/ |
| http.cors.max-age | 瀏覽器發(fā)送一個(gè)“預(yù)檢”O(jiān)PTIONS請(qǐng)求,以確定CORS設(shè)置。最大年齡定義多久的結(jié)果應(yīng)該緩存。默認(rèn)為1728000(20天) |
| http.cors.allow-methods | 允許跨域的請(qǐng)求方式,默認(rèn)OPTIONS,HEAD,GET,POST,PUT,DELETE |
| http.cors.allow-headers | 跨域允許設(shè)置的頭信息,默認(rèn)為X-Requested-With,Content-Type,Content-Length |
| http.cors.allow-credentials | 是否返回設(shè)置的跨域Access-Control-Allow-Credentials頭,如果設(shè)置為true,那么會(huì)返回給客戶(hù)端。 |
參考博文:http://www.cnblogs.com/zklidd/p/6433123.html
本文轉(zhuǎn)自1321385590 51CTO博客,原文鏈接:http://blog.51cto.com/linux10000/1944405,如需轉(zhuǎn)載請(qǐng)自行聯(lián)系原作者
總結(jié)
以上是生活随笔為你收集整理的Elasticsearch 5.3.x 使用 Head 插件的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 汉诺塔非递归算法
- 下一篇: 全球黑客盛会:2008年黑帽大会要闻摘要