hive通过nginx实现HA高可用
1. nginx的安装
1.1 下载上传
http://nginx.org/en/download.html
1.2 linux上安装c++编译环境
yum install -y zlibyum install gcc-c++ openssl openssl-devel zlib-devel pcre pcre-devel zlib zlib-devel
1.3 解压并编译
注意:这里一定要带上--with-stream,因为我们要使用stream模块
./configure --prefix=/opt/local/nginx/ --with-stream
make && make install
1.4 启动
在指定的目录/opt/local/nginx会生成编译后的nginx
启动命令:sbin/nginx
如果是非root账号启动时要注意普通用户没有权限启动1024以下端口,在root账号下使用如下命令解决:
setcap cap_net_bind_service=+eip /opt/local/nginx/sbin/nginx
2. nginx的配置
打开conf/nginx.conf,添加stream配置,和http同层,并且注释掉http配置。
这里是通过访问nginx那台服务器的10010端口,然后通过连接到其他3台hiveserver2服务上,这样可以保证任何1-2个节点的hiveServer服务宕机的情况下仍然可以使用。
stream {
log_format proxy '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
access_log logs/access.log proxy ;
open_log_file_cache off;
upstream beeline {
server hadoop200:10000;
server hadoop201:10000;
server hadoop202:10000;
}
server {
listen 10010;
proxy_pass beeline;
proxy_connect_timeout 10s;
proxy_timeout 24h;
}
}
20220728优化:
使用dbveaver连接过程中,经常发现一段时间不使用,就需要手工重新连接。这个时间非常短,可能在几分钟左右。
于是增加了以下两个参数待观察:
proxy_connect_timeout 10s; # 连接超时
proxy_timeout 24h; # 代理超时
3.连接测试
分别56,57,58 3个节点启动hiveserver2服务,然后通过dbeaver测试。
本文来自博客园,作者:硅谷工具人,转载请注明原文链接:https://www.cnblogs.com/30go/p/16257818.html