在前面我们已经讲过RHCS集群管理apache,那么在这章我们来学习haproxy+pacemaker实现集群管理
实验环境
server1,server2:集群节点
server3,server4:后端服务器
一,配置haproxy
在server1:
安装haproxy,并配置主配置文件,安装我们在之前学习haproxy时已经学习过,这里就不多说了,我们直接来配置主配置文件
global
maxconn 10000
stats socket /var/run/haproxy.stat mode 600 level admin
log 127.0.0.1 local0
uid 200
gid 200
chroot /var/empty
daemon
defaults
mode http
log global
option httplog
option dontlognull
monitor-uri /monitoruri
maxconn 8000
timeout client 30s
option prefer-last-server
retries 2
option redispatch
timeout connect 5s
timeout server 5s
stats uri /admin/stats
# The public 'www' address in the DMZ
frontend public
bind 172.25.77.100:80 #添加虚拟ip
#bind *:80 name clear
#bind 192.168.1.10:443 ssl crt /etc/haproxy/haproxy.pem
#use_backend static if write
#use_backend dynamic if read
default_backend static
#errorloc 403 http://172.25.77.1:8080/index.html
# the application servers go here
backend static ##后端
balance roundrobin
server web1 172.25.77.3:80 check inter 1000
server web2 172.25.77.4:80 check inter 1000
ip addr add 172.25.77.100/24 dev eth0 #添加虚拟ip
cat /etc/security/limits.conf | tail -n 1 #查看haproxy最大接收文件大小
/etc/init.d/haproxy start #开启haproxy
ip add #查看虚拟ip是否加上了
在server1上测试负载均衡(轮询调度)
首先配置server3,server4的httpd默认发布文件
<