说明
smartbimpp部署了多副本集群,但是jdbc的url地址只能填一个服务器的ip地址,当这个配置的服务器宕机了,此时smartbimpp将无法正常访问。
解决方案
使用nginx。
smartbimpp的url连接,也是http连接,所以可以通过nginx,转发smartbimpp的请求,实现负载均衡。
通过nginx的check模块,动态检测后端smartbimpp的健康状态。
部署流程
部署smartbimpp多副本集群,可以参考⬝ 部署smartbiMPP集群多副本集群_keeper
部署nginx
解压nginx
解压nginx安装包
# tar -zxvf nginx.tar.gz -C /usr/local
配置nginx
编辑nginx.conf
# vi /usr/local/nginx/conf/nginx.conf
配置mpp集群的ip地址和端口信息
nginx.conf配置示例说明
worker_processes auto; events { worker_connections 10240; } http { include mime.types; default_type application/octet-stream; log_format json #定义日志格式,收集日志信息 '{"@timestamp":"$time_iso8601",' '"slbip":"$remote_addr",' '"clientip":"$http_x_forwarded_for",' '"serverip":"$server_addr",' '"size":$body_bytes_sent,' '"responsetime":$request_time,' '"host":"$host",' '"method":"$request_method",' '"requesturi":"$request_uri",' '"url":"$uri",' '"upstream_addr":"$upstream_addr",' '"upstream_status":"$upstream_status",' '"upstream_cache_status":"$upstream_cache_status",' '"upstream_response_time":"$upstream_response_time",' '"appversion":"$HTTP_APP_VERSION",' '"referer":"$http_referer",' '"agent":"$http_user_agent",' '"status":"$status",' '"devicecode":"$HTTP_HA"}'; access_log logs/proxy_access_js.log json; sendfile on; keepalive_timeout 65; upstream smartbiupstream_smartbimpp { server 10.1.59.126:8123; server 10.1.59.108:8123; check interval=3000 rise=2 fall=5 timeout=1000 type=http; check_http_send "HEAD / HTTP/1.0\r\n\r\n"; check_http_expect_alive http_2xx http_3xx; } server { listen 8088; server_name 10.10.204.150; location / { proxy_pass http://smartbiupstream_smartbimpp/; } } }
启动nginx
启动nginx服务
# cd /usr/local/nginx/sbin # ./nginx
停止nginx
停止nginx服务
# cd /usr/local/tengine/sbin # ./nginx -s stop
配置smartbi的高速缓存库
数据连接 > 高速缓存库 ,进入高速缓存库的配置项,url填写nginx服务器的ip和端口,在连接字符串最后面添加参数 "&clusterReplicaName=smartbi_cluster_1S_2R" ,如下图所示。