以下方法在新版本中已经废弃:
Running as a plugin of Elasticsearch (deprecated)
- for Elasticsearch 5.x, 6.x, and 7.x: site plugins are not supported. Run as a standalone server
- for Elasticsearch 2.x:
sudo elasticsearch/bin/plugin install mobz/elasticsearch-head - for Elasticsearch 1.x:
sudo elasticsearch/bin/plugin -install mobz/elasticsearch-head/1.x - for Elasticsearch 0.x:
sudo elasticsearch/bin/plugin -install mobz/elasticsearch-head/0.9
open http://localhost:9200/_plugin/head/
使用以下方式可以直接下载,操作步骤如下:
Running with built in server
git clone git://github.com/mobz/elasticsearch-head.gitcd elasticsearch-headnpm installnpm run start
This will start a local webserver running on port 9100 serving elasticsearch-head
Running with docker
- for Elasticsearch 5.x:
docker run -p 9100:9100 mobz/elasticsearch-head:5 - for Elasticsearch 2.x:
docker run -p 9100:9100 mobz/elasticsearch-head:2 - for Elasticsearch 1.x:
docker run -p 9100:9100 mobz/elasticsearch-head:1 - for fans of alpine there is
mobz/elasticsearch-head:5-alpine
其他方式参考:https://codeload.github.com/mobz/elasticsearch-head/zip/master
关于连接失败的问题:
默认情况下,elasticsearch 在端口9200上公开一个http rest API,elasticsearch-head连接到该端口。
在elasticsearch中启用CORS
当不作为Chrome扩展程序或Elasticsearch插件运行时(甚至在版本5中甚至无法运行),您必须在elasticsearch中启用CORS,否则您的浏览器将因违反同源策略而拒绝elasticsearch-head的请求。
在elasticsearch配置中;
- 加
http.cors.enabled: true - 您还必须进行设置,
http.cors.allow-origin因为默认情况下不允许使用任何原点。http.cors.allow-origin: "*"是有效值,但是由于您的集群可以从任何地方跨源交叉,因此被视为安全风险。
在配置文件elasticsearch.yml中,添加:
http.cors.enabled: true
http.cors.allow-origin: "*"
本文详细介绍了在不同版本的Elasticsearch中安装和配置Head插件的方法,包括通过内置服务器、Docker以及直接下载的方式。同时,文章还提供了解决连接失败问题的方案,特别是关于如何在Elasticsearch中启用CORS来避免同源策略带来的限制。
3296

被折叠的 条评论
为什么被折叠?



