haproxy 配置

配置环境:
server1:调度器1(172.25.254.1)
server2:real server1(172.25.254.2)
server3:real server2(172.25.254.3)
一、haproxy负载均衡
1、haproxy安装

haproxy可以使用源码安装,rpm直接安装和rpmbuild安装三种方式,本次采用rpmbuild安装
1、在官网下载haproxy安装包,并解压

[root@server1 ~]# ls
haproxy-1.6.11 haproxy-1.6.11.tar.gz

1
2

2、安装rpm-build
[root@server1 ~]# yum install rpm-build -y
3、执行命令生成rpmbuild目录
[root@server1 ~]# rpmbuild -bb haproxy-1.6.11
4、进入到解压的haproxy目录下

[root@server1 haproxy-1.6.11]# cd examples/
[root@server1 examples]# ls
acl-content-sw.cfg debug2html init.haproxy
auth.cfg debugfind option-http_proxy.cfg
check errorfiles seamless_reload.txt
check.conf haproxy.init ssl.cfg
content-sw-sample.cfg haproxy.spec stats_haproxy.sh
debug2ansi haproxy.vim transparent_proxy.cfg
[root@server1 examples]# rpmbuild -bb haproxy.spec ##rpmbuild来生成rpm包
error: Failed build dependencies:
pcre-devel is needed by haproxy-1.6.11-1.x86_64 ##报错缺少pcre-devel包
[root@server1 examples]# yum install pcre-devel ##安装
[root@server1 examples]# rpmbuild -bb haproxy.spec 继续执行

1
2
3
4
5
6
7
8
9
10
11
12
13

遇到此报错意思是缺少gcc,安装即可
这里写图片描述
[root@server1 examples]# rpmbuild -bb haproxy.spec继续

[root@server1 examples]# cd /root/rpmbuild/RPMS/x86_64/ ##成功后会生成x86_64目录下 会有haproxy的rpm包,rpm-ivh安装即可
[root@server1 x86_64]# ls
haproxy-1.6.11-1.x86_64.rpm
[root@server1 x86_64]# rpm -ivh haproxy-1.6.11-1.x86_64.rpm
Preparing… ########################################### [100%]
1:haproxy ########################################### [100%]

1
2
3
4
5
6

2、负载均衡配置

1、修改配置文件

/root/haproxy-1.6.11/examples
[root@server1 examples]# ls
acl-content-sw.cfg debug2html init.haproxy
auth.cfg debugfind option-http_proxy.cfg
check errorfiles seamless_reload.txt
check.conf haproxy.init ssl.cfg
content-sw-sample.cfg haproxy.spec stats_haproxy.sh
debug2ansi haproxy.vim transparent_proxy.cfg
[root@server1 examples]# cp content-sw-sample.cfg /etc/haproxy/haproxy.cfg
[root@server1 examples]# cd /etc/ha
-bash: cd:

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值