# yum install gcc gcc-c++ make zlib-devel bzip2-devel openssl-devel
haproxy安装:
# tar -zvxf haproxy-1.5.5.tar.gz
# cd haproxy-1.5.5
# uname -a ## 查看linux内核版本
# make TARGET=linux26 PREFIX=/usr/local/haproxy-1.5.5
# make install PREFIX=/usr/local/haproxy-1.5.5
编辑启动文件:
# vi /etc/init.d/haproxy --添加以下内容
#!/bin/sh
#
# haproxy
#
# haproxy starting and stopping the haproxy load balancer
#
# chkconfig: 345 55 45
# description: HAProxy is a free, very fast and reliable solution
# offering high availability, load balancing, and
# proxying for TCP and HTTP-based applications
# config: /etc/haproxy/haproxy.cfg
# pidfile: /var/run/haproxy.pid
# probe: true
# Source function library.
. /etc/rc.d/init.d/functions
# Define our actions
checkconfig() {
# Check the config file for errors
/usr/local/haproxy-1.5.5/sbin/haproxy -c -q -f /etc/haproxy/haproxy.conf
if [ $? -ne 0 ]; then
echo "Errors found in configuration file."
return 1
fi
# We're OK!
return 0
}
start() {
# Check config
/usr/local/haproxy-1.5.5/sbin/haproxy -c -q -f /etc/haproxy/haproxy.conf
if [ $? -ne 0 ]; then
echo "Errors found in configuration file."
return 1
fi
restart() {
/usr/local/haproxy-1.5.5/sbin/haproxy -c -q -f /etc/haproxy/haproxy.conf
if [ $? -ne 0 ]; then
echo "Errors found in configuration file."
return 1
fi
reload() {
/usr/local/haproxy-1.5.5/sbin/haproxy -c -q -f /etc/haproxy/haproxy.conf
if [ $? -ne 0 ]; then
echo "Errors found in configuration file."
return 1
fi