
- Install Haproxy
CentOS/RHEL 5 , 32 bit:
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
CentOS/RHEL 5 , 64 bit:
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
CentOS/RHEL 6 , 32 bit:
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
CentOS/RHEL 6 , 64 bit:
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum -y install haproxy - Configure Haproxy
vi /etc/haproxy/haproxy.cfgglobal
log 127.0.0.1 local0
log 127.0.0.1 local1 debug
maxconn # Total Max Connections.
daemon
nbproc # Number of processing cores.
defaults
log global
mode http
option httplog
option dontlognull
retries
option redispatch
maxconn
timeout server
timeout connect
timeout client
timeout queue 1000s # [HTTP Site Configuration]
listen http_web 10.10.0.112:
mode http
balance roundrobin # Load Balancing algorithm
option httpchk
option forwardfor
server server1 23.253.48.253: weight maxconn check
server server2 208.43.40.162: weight maxconn check # [Change HAProxy Stats URL]
listen stats 10.10.0.112:
mode http
log global
balance roundrobin maxconn timeout server
timeout connect
timeout client
timeout queue 1000s stats enable
stats hide-version
stats refresh 30s
stats show-node
stats realm Haproxy\ Statistics
stats auth admin:password
stats uri /ha-statshaproxy Code
开启防火墙 1936 端口
- 重启相关服务
service iptables restart
service haproxy restart
chkconfig haproxy on - 后台查看网站:
http://10.10.0.112:1936/ha-stats or http://10.10.0.112:1936/stats - 参考链接:
http://tecadmin.net/install-and-configure-haproxy-on-centos/