安装haproxy
[root@centos04 ~]# yum -y install pcre-devel zlib-devel bzip2-devel
配置haproxy
[root@centos04 haproxy-1.4.24]# make TARGET=linux26
安装haproxy
root@centos04 haproxy-1.4.24]# make install
生成主配置文件
[root@centos04 haproxy-1.4.24]# mkdir /etc/haproxy
[root@centos04 haproxy-1.4.24]# cpexamples/haproxy.cfg /etc/haproxy/
优化命令
[root@centos04 haproxy-1.4.24]# ln -s /usr/local/sbin/haproxy /usr/sbin/
生成服务配置文件
[root@centos04 haproxy-1.4.24]# cp examples/haproxy.init /etc/init.d/haproxy
[root@centos04 haproxy-1.4.24]# chmod +x /etc/init.d/haproxy
添加系统服务设置开机自动启动
[root@centos04 ~]# chkconfig --add haproxy
[root@centos04 ~]# chkconfig --level 35 haproxy on
配置haproxy负载均衡
创建服务启动临时目录
[root@centos04 ~]# mkdir /usr/share/haproxy/
启动服务
[root@centos04 ~]# systemctl start haproxy
监听haproxy端口
root@centos04 ~]# netstat -anptu | grep 80
验证