1.首先放置jar包(源代码haproxy-1.7.8.tar.gz)
目录 /usr/local/haproxy
2.解压目录
tar -xvf haproxy-1.7.8.tar.gz
进入 haproxy-1.7.8
编译
make TARGET=linux2628 PREFIX=/usr/local/haproxy(需安装gcc不然会报错,目录需存在)
Make install PREFIX=/usr/local/haproxy
确认目录下存在编译后的文件目录
3.编译目录
将haproxy-start.sh放入sbin文件夹中
创建 conf文件夹,将配置文件放入其中
创建logs文件夹
覆盖 /etc/rsyslog.conf(rsyslog需安装)
4.运行haproxy-start.sh
查看是否已经在运行
完成后删除源码文件
操作系统一样的话
只需要编译,剩下可以复制编译后的程序目录到相应位置,不需要再一台台编译
附录:
1.haproxy-start.sh
/usr/local/haproxy/sbin/haproxy -sf $(cat /usr/local/haproxy/logs/haproxy.pid) -f /usr/local/haproxy/conf/http_proxy.cfg |
2.http_proxy.cfg
#i ##################前端配置################## default_backend end-proxy # layer7: Only GET method is valid # layer7: protect bad reply listen admin_stats |
3.rsyslog.conf
# rsyslog configuration file # For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html #### MODULES #### # The imjournal module bellow is now used as a message source instead of imuxsock. # Provides UDP syslog reception # Provides TCP syslog reception
# Where to place auxiliary files # Use default timestamp format # File syncing capability is disabled by default. This feature is usually not required, # Include all config files in /etc/rsyslog.d/ # Turn off message reception via local log socket; # File to store the position in the journal
# Log all kernel messages to the console. # Log anything (except mail) of level info or higher. # The authpriv file has restricted access. # Log all the mail messages in one place.
# Everybody gets emergency messages # Save news errors of level crit and higher in a special file. # Save boot messages also to boot.log *.* /var/log/all.log $ModLoad imudp |