haproxy部署
部署主从两台haproxy服务器
安装haproxy
设置haproxy配置⽂件并重启服务
Haproxy-1配置⽂件内容:
global
log 127.0.0.1 local1
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
defaults
mode http
log global
option dontlognull
retries 3
maxconn 3000
contimeout 50000
clitimeout 50000
srvtimeout 50000
listen stats
bind *
:
1314
stats enable
stats hide-version
stats uri /haproxystats
stats realm Haproxy\ stats
stats auth admin
:
admin
stats admin if TRUE
frontend web
option httplog
option http-server-close
option forwardfor except 127.0.0.0/8
#option redispatch
mode http
bind *
:
80
default_backend httpservers
backend httpservers
balance roundrobin
server redis01 172.16.124.155
:
6001 check maxconn 2000
server redis01 172.16.124.155
:
6002 check maxconn 2000
server redis02 172.16.124.156
:
6003 check maxconn 2000
server redis02 172.16.124.156
:
6004 check maxconn 2000
server redis03 172.16.124.157
:
6005 check maxconn 2000
server redis03 172.16.124.157
:
6006 check maxconn 2000
Haproxy02配置⽂件内容:
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
defaults
mode http
log global
option dontlognull
retries 3
maxconn 3000
contimeout 50000
clitimeout 50000
srvtimeout 50000
listen stats
bind *
:
1314
stats enable
stats hide-version
stats uri /haproxystats
stats realm Haproxy\ stats
stats auth admin
:
admin
stats admin if TRUE
frontend web
option httplog
option http-server-close
option forwardfor except 127.0.0.0/8
#option redispatch
mode http
bind *
:
80
default_backend httpservers
backend httpservers
balance roundrobin
server redis01 172.16.124.155
:
6001 check maxconn 2000
server redis01 172.16.124.155
:
6002 check maxconn 2000
server redis02 172.16.124.156
:
6003 check maxconn 2000
server redis02 172.16.124.156
:
6004 check maxconn 2000
server redis03 172.16.124.157
:
6005 check maxconn 2000
server redis03 172.16.124.157
:
6006 check maxconn 2000
浏览器访问测试登陆查看代理服务信息
登陆查看代理服务信息
keepalived部署
部署主从两台keepalived服务
安装keepalived
配置keepalived配置⽂件并重启服务
#MASTER配置文件内容:
! Configuration File for keepalived
global_defs {
router_id director1
}
vrrp_instance VI_1 {
state MASTER
nopreempt
interface eth0
virtual_router_id 80
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.16.124.200
}
}
#BACKUP配置文件内容:
! Configuration File for keepalived
global_defs {
router_id director1
}
vrrp_instance VI_1 {
state BACKUP
nopreempt
interface eth0
virtual_router_id 80
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.16.124.200
}
}
查看IP地址
测试
测试访问vip