- 安装haproxy实现ha
Install the load balancer:
root@bigdata-150021:~# yum -y install haproxy
root@bigdata-150021:~# cp /etc/haproxy/haproxy.cfg /etc/haproxy/haproxy.cfg.bak
- 配置haproxy
cat /etc/haproxy/haproxy.cfg
root@bigdata-150021:~# cat /etc/haproxy/haproxy.cfg|grep -v "#"
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
maxconn 3000
timeout connect 5000
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
listen stats :1080#定义管理界面
balance
stats enable
stats uri /stats
stats refresh 30s
stats auth admin:admin
listen jdbchive :25005
option tcplog
server hiveServer1 bigdata-150022:10000 check
server hiveServer2 bigdata-150023:10000 check
listen impalashell :25003
option tcplog
server impalashell_dn1 bigdata-150021:21000 check
server impalashell_dn2 bigdata-150022:21000 check
server impalashell_dn3 bigdata-150023:21000 check
listen impalajdbc :25004
option tcplog
server impalajdbc_dn1 bigdata-150021:21050 check
server impalajdbc_dn2 bigdata-150022:21050 check
server impalajdbc_dn3 bigdata-150023:21050 check
- 启动haproxy
root@bigdata-150021:~# systemctl enable haproxy.service
root@bigdata-150021:~# systemctl start haproxy.service
- Hue集成hiveserver2和impala deamon jdbc连接
hue_safety_valve.ini
[impala]
server_host=bigdata-150021
server_port=25004
[beeswax]
server_host=bigdata-150021
server_port=25005
在此,我的Haproxy服务安装在了bigdata-150021节点上,所以此处填写bigdata-150021:25003
- Impala shell 测试
使用多个终端同时访问,并执行SQL语句,查看是否会通过HAProxy服务自动负载到其它Impala Daemon节点。
打开第一个终端访问并执行SQL