1.在HaProxy官網(wǎng)中下載最新安裝包haproxy-1.7.2.tar.gz (http://www.haproxy.org/#down)
2.解壓至ln-master:/data5/haproxy-1.7.2目錄
3.安裝:
? ? ? ? A.make? TARGET=linux31? ARCH=x86_64? PREFIX=/usr/local/haproxy (將haproxy安裝到指定目錄,TARGET指定內(nèi)核版本)
? ? ? ? B.進入/usr/local/haproxy中創(chuàng)建配置文件haproxy.cfg(若有此配置文件則不用創(chuàng)建)
? ? ? ? C.修改配置文件haproxy.cfg,配置文件詳見/usr/local/haproxy/haproxy.cfg
4.啟動haproxy:
/usr/local/haproxy/sbin/haproxy ?-f ?/usr/local/haproxy/haproxy.cfg(-f指定配置文件)
5.監(jiān)控
http://10.192.28.142:1081/haproxy-stats
6.使用
impala-shell ?-i ?ln-master:25003
注: Impala守護進程Beeswax端口21000映射到haproxy 25003
? ? ? ? Impala守護進程HiveServer2端口21050映射到haproxy 21051
haproxy.cfg配置文件如下:
global
# To have these messages end up in /var/log/haproxy.log you will
# need to:
# 1) configure syslog to accept network log events.? This is done by adding the '-r' option to the #SYSLOGD_OPTIONS in /etc/sysconfig/syslog
# 2) configure local2 events to go to the /var/log/haproxy.log file. A line like the following can be #added to /etc/sysconfig/syslog
#? ? local2.* ? ? /var/log/haproxy.log
log ? ?127.0.0.1 local0
log ? ?127.0.0.1 local1 notice
chroot ? ?/usr/local/haproxy
pidfile? ? /var/run/haproxy.pid
maxconn? ? 4000
user? ? ? ? haproxy
group? ? ? haproxy
daemon
# turn on stats unix socket
#stats socket /var/lib/haproxy/stats
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
# You might need to adjust timing values to prevent timeouts.
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 120s
timeout client ? ? 600s
timeout server ? ?600s
# This sets up the admin page for HA Proxy at port 25002.
listen stats
bind 0.0.0.0:1081
stats uri /haproxy-stats
stats realm /haproxy-admin
balance
mode http
stats enable
stats auth admin:admin
stats admin if TRUE
# This is the setup for Impala. Impala client connect to load_balancer_host:25003.
# HAProxy will balance connections among the list of servers listed below.
# The list of Impalad is listening at port 21000 for beeswax (impala-shell) or original ODBC driver.
# For JDBC or ODBC version 2.x driver, use port 21050 instead of 21000.
listen impala
bind 0.0.0.0:25003
mode tcp
option tcplog
balance leastconn
server impala1? ln-node1:21000 check
server impala2? ln-node2:21000 check
server impala3? ln-node3:21000 check
server impala4? ln-node4:21000 check
server impala5? ln-node5:21000 check
server impala6? ln-node6:21000 check
server impala7? ln-node7:21000 check
# Setup for Hue or other JDBC-enabled applications.
# In particular, Hue requires sticky sessions.
# The application connects to load_balancer_host:21051, and HAProxy balances
# connections to the associated hosts, where Impala listens for JDBC
# requests on port 21050.
listen impalajdbc
bind 0.0.0.0:21051
mode tcp
option tcplog
balance source
server impala8? ln-node1:21050 check
server impala9? ln-node2:21050 check
server impala10? ln-node3:21050 check
server impala11? ln-node4:21050 check
server impala12? ln-node5:21050 check
server impala13? ln-node6:21050 check
server impala14? ln-node7:21050 check
關于Hue中Haproxy配置請參考此鏈接。