背景:
Haproxy 版本: haproxy-1.4.24.tar.gz
Mysql 版本:5.5.31
一:Haproxy安装
tar -xzvf haproxy - 1 . 4 . 24 . tar . gz
make TARGET=linux26 PREFIX=/usr/local/haproxy
make install PREFIX=/usr/local/haproxy
二:Haproxy 配置
1).首先创建组用户
groubadd haproxy
useradd -g haproxy haproxy
id haproxy 查看用户haproxy的uid和gid
2).为需要负载均衡的mysql读库增加用户admin 密码为空
3)vim /etc/haproxy.cfg
global
log 127.0.0.1 local6
maxconn 20480
chroot /usr/local/haproxy
uid 500
gid 500
daemon
quiet
nbproc 1
pidfile /var/run/haproxy.pid
defaults
log global
mode http
maxconn 20480
option httplog
option httpclose
option dontlognull
option forwardfor
option redispatch
option abortonclose
stats refresh 30
retries 3
balance roundrobin
contimeout 5000
clitimeout 50000
timeout check 2000
srvtimeout 50000
listen mysql_proxy
bind 0.0.0.0:23306
mode tcp
option mysql-check user admin
balance roundrobin
server readb01 10.1.58.191:3306 check inter 2000 rise 2 fall 5 weight 1
server readb02 10.1.58.181:3306 check inter 2000 rise 2 fall 5 weight 1
listen haproxy_stats 10.1.58.191:80
mode http
stats enable
option httplog
maxconn 5
stats refresh 30s
stats uri /haproxy_status
stats auth admin:admin
stats realm esb\haproxy manager
三:Haproxy日志配置
vi /etc/syslog.conf
添加
local6.* /var/log/haproxy.log
vi /etc/sysconfig/syslog
修改
SYSLOGD_OPTIONS = "-r -m 0"
service syslog restart
四:启动Haproxy
/usr/local/haproxy/sbin/haproxy -f /etc/haproxy.cfg
Haproxy 版本: haproxy-1.4.24.tar.gz
Mysql 版本:5.5.31
一:Haproxy安装
tar -xzvf haproxy - 1 . 4 . 24 . tar . gz
make TARGET=linux26 PREFIX=/usr/local/haproxy
make install PREFIX=/usr/local/haproxy
二:Haproxy 配置
1).首先创建组用户
groubadd haproxy
useradd -g haproxy haproxy
id haproxy 查看用户haproxy的uid和gid
2).为需要负载均衡的mysql读库增加用户admin 密码为空
3)vim /etc/haproxy.cfg
global
log 127.0.0.1 local6
maxconn 20480
chroot /usr/local/haproxy
uid 500
gid 500
daemon
quiet
nbproc 1
pidfile /var/run/haproxy.pid
defaults
log global
mode http
maxconn 20480
option httplog
option httpclose
option dontlognull
option forwardfor
option redispatch
option abortonclose
stats refresh 30
retries 3
balance roundrobin
contimeout 5000
clitimeout 50000
timeout check 2000
srvtimeout 50000
listen mysql_proxy
bind 0.0.0.0:23306
mode tcp
option mysql-check user admin
balance roundrobin
server readb01 10.1.58.191:3306 check inter 2000 rise 2 fall 5 weight 1
server readb02 10.1.58.181:3306 check inter 2000 rise 2 fall 5 weight 1
listen haproxy_stats 10.1.58.191:80
mode http
stats enable
option httplog
maxconn 5
stats refresh 30s
stats uri /haproxy_status
stats auth admin:admin
stats realm esb\haproxy manager
三:Haproxy日志配置
vi /etc/syslog.conf
添加
local6.* /var/log/haproxy.log
vi /etc/sysconfig/syslog
修改
SYSLOGD_OPTIONS = "-r -m 0"
service syslog restart
四:启动Haproxy
/usr/local/haproxy/sbin/haproxy -f /etc/haproxy.cfg
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/28624388/viewspace-1288666/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/28624388/viewspace-1288666/