1.yum安装
yum install net-tools vim tree screen lsof tcpdump nc mtr nmap gcc glibc gcc-c++ make haproxy keepalived nginx
2.haproxy.cfg配置文件
global
maxconn 100000
chroot /var/lib/haproxy
user haproxy
group haproxy
daemon
nbproc 1
pidfile /var/run/haproxy.pid
log 127.0.0.1 local3 info
defaults
option http-keep-alive
maxconn 100000
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
listen stats
mode http
bind 0.0.0.0:8888
stats enable
stats uri /haproxy-status
stats auth haproxy:haproxy
frontend main
bind 192.168.168.32:80
mode http
option httplog
log global
default_backend backend_test
backend backend_test
option forwardfor header X-REAL-IP
option httpchk HEAD / HTTP/1.0
balance source #源IP roundrobin轮询
server web-node1 192.168.168.32:8080 check inter 2000 rise 30 fall 15
server web-node2 192.168.168.33:8080 check inter 2000 rise 30 fall 15
3.启动
systemctl start haproxy
nginx请自己配置
http://192.168.1.1:8888/haproxy-status
原文地址:http://blog.51cto.com/yangxiongchun/2344981