haproxy

1.下载、解压 haproxy-1.6.11.tar.gz
2.安装 rpm-build.x86_6

注意:运行命令之后,会自动生成目录 rpmbuild

[root@server4 examples]# rpmbuild -bb haproxy.spec
error: File /root/rpmbuild/SOURCES/haproxy-1.6.11.tar.gz: No such file or directory
[root@server4 examples]# cd
[root@server4 ~]# ls
haproxy-1.6.11 nginx-1.10.1.tar.gz nginx-sticky-module-ng
haproxy-1.6.11.tar.gz nginx-1.14.0 nginx-sticky-module-ng.tar.gz
nginx-1.10.1 nginx-1.14.0.tar.gz rpmbuild
[root@server4 ~]# mv haproxy-1.6.11.tar.gz rpmbuild/SOURCES/
[root@server4 examples]# rpmbuild -bb haproxy.spec

3、安装 haproxy
[root@server4 examples]# cd /root/rpmbuild/RPMS/x86_64/
[root@server4 x86_64]# ls
haproxy-1.6.11-1.x86_64.rpm
[root@server4 x86_64]# rpm -ivh haproxy-1.6.11-1.x86_64.rpm
Preparing… ########################################### [100%]
1:haproxy ########################################### [100%]
4、修改配置文件
[root@server4 x86_64]# cd -
/root/haproxy-1.6.11/examples
[root@server4 examples]# ls
acl-content-sw.cfg debug2ansi haproxy.spec ssl.cfg
auth.cfg debug2html haproxy.vim stats_haproxy.sh
check debugfind init.haproxy transparent_proxy.cfg
check.conf errorfiles option-http_proxy.cfg
content-sw-sample.cfg haproxy.init seamless_reload.txt
[root@server4 examples]# cp content-sw-sample.cfg /etc/haproxy/haproxy.cfg

[root@server4 examples]# cd /etc/haproxy/
[root@server4 haproxy]# vim haproxy.cfg
10 global
11 maxconn 65535 ##最大链接
12 stats socket /var/run/haproxy.stat mode 600 level admin
13 log 127.0.0.1 local0
14 uid 200 ##指定用户、组
15 gid 200
16 chroot /var/empty ##
17 daemon
18 ####注意:局部改变全局,即局部变量优先
19 defaults
20 mode http ##http服务
21 log global ##日志格式
22 option httplog
23 option dontlognull
24 monitor-uri /monitoruri ##前端健康检查
25 maxconn 8000 ##默认最大链接,覆盖global
26 timeout client 30s ##客户端中断时间 30s
27 stats uri /admin/stats ##后端健康检查
28 retries 2 ##再次链接时间,2s
29 option redispatch
30 timeout connect 5s ##链接断开,5s
31 timeout server 30s ##服务断开,30s
34 # The public ‘www’ address in the DMZ
35 frontend public
36 bind *:80
37 # use_backend static if { hdr_beg(host) -i img }
38 # use_backend static if { path_beg /img /css }
39 default_backend dynamic
40
41 # the application servers go here
42 backend dynamic
43 balance roundrobin
44 server web1 172.25.12.2:80 check inter 1000
45 server web2 172.25.12.3:80 check inter 1000

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值