yum install haproxy -y
vi /etc/haproxy/haproxy.cfg
<code>
global
log 127.0.0.1 local3
log-send-hostname public-haproxy-primary
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 512000
user haproxy
group haproxy
daemon
#first configure
# turn on stats unix socket
stats socket /var/lib/haproxy/stats level admin
#second configure
# turn on stats unix socket
nbproc 8
cpu-map 1 0
cpu-map 2 1
cpu-map 3 2
cpu-map 4 3
cpu-map 5 4
cpu-map 6 5
cpu-map 7 6
cpu-map 8 7
# turn on stats unix socket
stats socket /var/lib/haproxy/stats.1 level admin process 1
stats socket /var/lib/haproxy/stats.2 level admin process 2
stats socket /var/lib/haproxy/stats.3 level admin process 3
stats socket /var/lib/haproxy/stats.4 level admin process 4
stats socket /var/lib/haproxy/stats.5 level admin process 5
stats socket /var/lib/haproxy/stats.6 level admin process 6
stats socket /var/lib/haproxy/stats.7 level admin process 7
stats socket /var/lib/haproxy/stats.8 level admin process 8
defaults
mode http
log global
option httplog
option forwardfor
option dontlognull
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 100m
timeout server 100m
timeout http-keep-alive 30s
timeout check 10s
maxconn 512000
#-------------------------------------------------------------------------
#frontend
#-------------------------------------------------------------------------
frontend main
bind *:80
bind *:443 ssl crt /etc/pki/tls/private/xxx.pem crt /etc/pki/tls/private/xxx.pem
default_backend app
#-------------------------------------------------------------------------
#backend
#-------------------------------------------------------------------------
backend app
balance roundrobin
option httpchk OPTIONS * HTTP/1.1\r\nHost:\ www
server app-node1 ip:80 check
server app-node2 ip:80 check
server app-node3 ip:80 check
</code>
/etc/init.d/haproxy start
其它配置
listen game-proxy-server
bind :30001-39999,:50001-58999,:843
mode tcp
server game-servers x.x.x.x
故障判断和操作:
1、首先检查端口是否能telnet通,查看虚拟ip绑定在那台机器上,ip a
2、查看keepalived,haproxy日志
3、重启keepalived,haproxy
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。