设为首页 收藏本站
查看: 2092|回复: 0

[经验分享] 通过nginx实现内网hadoop、hbase集群对外访问web界面

[复制链接]

尚未签到

发表于 2016-12-13 06:58:36 | 显示全部楼层 |阅读模式
转载请标明出处:http://blackwing.iyunv.com/blog/1949154
不少公司为了安全,hadoop、hbase集群都是不对外开放,只有一台入口机对外,那么当要查看hadoop、hbase集群机器状态等信息时,就没办法了。
而要实现内网机器给外网访问,要解决的问题是:
1.hadoop、hbase页面上的url替换成外网能访问的url
2.通过有限的端口、外网ip对外提供整集群访问
强大的nginx正好能解决这个问题。而nginx要替换返回的页面内容,虽然它自己有模块可以实现,但据了解只能替换一次,而网上比较常用的是第三方的替换模块nginx_substitutions_filter,其主页:
http://code.google.com/p/substitutions4nginx/

整个实现步骤为:
1. 下载nginx_substitutions_filter并解压:
根据官方的建议:
git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git

2. 下载nginx稳定版并解压:
wget http://nginx.org/download/nginx-1.4.2.tar.gz

3. 编译安装
根据自己需要选择要适应的模块,并且指定substitutions4nginx模块的路径
./configure --prefix=/usr/local/nginx --pid-path=/usr/local/nginx.pid  --with-http_dav_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module  --with-debug --add-module=/home/hadoop/nginx/third-party-md/ngx_http_substitutions_filter_module/

make
make install

4. 配置nginx.conf
#替换hbase
server {
listen       8000;      
location / {
proxy_pass http://master;
subs_filter_types text/html text/css text/xml;
subs_filter hd1:60030 192.168.1.25:8000/hd11;
subs_filter hd2:60030 192.168.1.25:8000/hd22;
}

location /hd11/ {
proxy_pass http://192.168.1.25:60030/rs-status;
}
location /hd22/ {
proxy_pass http://192.168.1.30:60030/rs-status;
}
}

#替换hadoop jt
server {
listen       8001;
location / {
proxy_pass http://master2;
subs_filter_types text/html text/css text/xml;
subs_filter hd1:50060 192.168.1.25:8001/hd11;
subs_filter hd2:50060 192.168.1.25:8001/hd22;
}

location /hd11/ {
proxy_pass http://192.168.1.25:50060/tasktracker.jsp;
}
location /hd22/ {
proxy_pass http://192.168.1.30:50060/tasktracker.jsp;
}
}
#替换hadoop nn
server {
listen       8002;
location / {
proxy_pass http://master3;
subs_filter_types text/html text/css text/xml;
subs_filter hd1:50075 192.168.1.25:8002/hd11;
subs_filter hd2:50075 192.168.1.25:8002/hd22;
}

location /hd11/ {
proxy_pass http://192.168.1.25:50075/;
}
location /hd22/ {
proxy_pass http://192.168.1.30:50075/;
}
}
upstream  master {
server 192.168.1.30:60010;
}
upstream  master2 {
server 192.168.1.25:50030;
}
upstream  master3 {
server 192.168.1.25:50070;
}

重启ng服务让配置生效。
这样就可以通过统一ng入口访问内网集群了,后面如果有需要添加的修改nginx.conf就行。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-313355-1-1.html 上篇帖子: 分析和优化云集群性能 使用可配置参数监视和调优 Hadoop 集群的性能 下篇帖子: hadoop经典系列(十二)HDFS添加删除节点并进行集群平衡
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表