您的位置:首页 > 运维架构 > Nginx

elasticsearch5.x 集群管理工具head插件安装、nginx配置外网访问

2017-12-15 18:45 701 查看

一、下载安装包

下载Elasticsearch 5.x下载地址:https://www.elastic.co/downloads/elasticsearchzip和tar格式是各种系统都通用的,解压之后启动Elasticsearch即可。下载elasticsearch-head下载地址:https://github.com/mobz/elasticsearch-head,下载后解压缩。

二、安装node、npm、grunt

node下载地址nodejs.org/  (node安装可参考文章http://blog.csdn.net/kelin_liu/article/details/72729050)
$ node -v
v6.10.3
npm下载地址https://www.npmjs.com
$ 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/[/code] 
完成!
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;        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: