(一)设计思路
高可用:keepalived 解决方案
负载均衡:(lvs)DR做轮询,需要一个调度器,后端节点两个(部署nginx动态博客),通过一个vip去访问动态博客
后端节点需要部署动态博客作为资源供客户访问。
调度器做keepalived(dr),给调度器做一个备节点,让他俩互为主备,避免资源浪费。
这样的话就需要四台物理机,两台主备调度器,两台realserver。
(二)部署过程
(1)调度器上的部署
1. 两台调度器下载keepalived:
yum install -y keepalived
2.编辑配置文件,让两台调度器互为主备
[root@node1 keepalived]# cat /etc/keepalived/keepalived.conf! Configuration File forkeepalived
global_defs {
notification_email {
# acassen@firewall.loc
# failover@firewall.loc
# sysadmin@firewall.loc
}
# notification_email_from Alexandre.Cassen@firewall.loc
# smtp_server192.168.200.1# smtp_connect_timeout30# router_id LVS_DEVEL
# vrrp_skip_check_adv_addr
# vrrp_strict
# vrrp_garp_interval0# vrrp_gna_interval0}
vrrp_instance VI_1 {
state MASTERinterfaceens33
virtual_router_id51priority100advert_int1authentication {
auth_type PASS
auth_pass1111}
virtual_ipaddress {192.168.42.200}
}
vrrp_instanceVI_2 {
state BACKUPinterfaceens33
virtual_router_id52priority99advert_int1authentication {
auth_type PASS
auth_pass2222}
virtual_ipaddress {192.168.42.100}
}
virtual_server192.168.42.200 80{
delay_loop6lb_algo rr
lb_kind DR
protocol TCP
real_server192.168.42.172 80{
weight1HTTP_GET {
url {
path/
state_code 200}
connect_timeout3nb_get_retry3delay_before_retry3}
}
}
virtual_server192.168.42.200 80{
delay_loop6lb_algo rr
lb_kind DR
protocol TCP
real_server192.168.42.173 80{
weight1HTTP_GET {
url {
path/state_code200}
connect_timeout3nb_get_retry3delay_before_retry3}
}
}
[root@node2 ~]# cat /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
# acassen@firewall.loc
# failover@firewall.loc
# sysadmin@firewall.loc
}
# notification_email_from Alexandre.Cassen@firewall.loc
# smtp_server 192.168.200.1
# smtp_connect_timeout 30
# router_id LVS_DEVEL
# vrrp_skip_check_adv_addr
# vrrp_strict
# vrrp_garp_interval 0
# vrrp_gna_interval 0
}
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.42.200
}
}
vrrp_instance VI_2 {
state MASTER
interface ens33
virtual_router_id 52
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 2222
}
virtual_ipaddress {
192.168.42.100
}
}
virtual_server 192.168.42.200 80 {
delay_loop 6
lb_algo rr
lb_kind DR
protocol TCP
real_server 192.168.42.172 80 {
weight 1
HTTP_GET {
url {
path /
state_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
virtual_server 192.168.42.200 80 {
delay_loop 6
lb_algo rr
lb_kind DR
protocol TCP
real_server 192.168.42.173 80 {
weight 1
HTTP_GET {
url {
path /
state_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
3.调度器重启keepalived(可以做个测试,查看vip的迁移)
systemctl restart keepalived
(2)realserver部署
1. realserver部署DR
[root@node3 ~]# cd /proc/sys/net/ipv4/conf/[root@node3 conf]# ls
all calib2dc35d78a1 docker0 lo
cali748bf682dd1 calib6602a4140d ens33 tunl0
cali8e151c6d769default flannel.1[root@node3 conf]# cd all
[root@node3 all]# ls
accept_local disable_policy proxy_arp_pvlan
accept_redirects disable_xfrm route_localnet
accept_source_route force_igmp_version rp_filter
arp_accept forwarding secure_redirects
arp_announce log_martians send_redirects
arp_filter mc_forwarding shared_media
arp_ignore medium_id src_valid_mark
arp_notify promote_secondaries tag
bootp_relay proxy_arp
[root@node3 all]# echo1 >arp_ignore
[root@node3 all]# echo2 >arp_announce
[root@node3 all]# cd ..
[root@node3 conf]# ls
all calib2dc35d78a1 docker0 lo
cali748bf682dd1 calib6602a4140d ens33 tunl0
cali8e151c6d769default flannel.1[root@node3 conf]# cd lo
[root@node3 lo]# ls
accept_local disable_policy proxy_arp_pvlan
accept_redirects disable_xfrm route_localnet
accept_source_route force_igmp_version rp_filter
arp_accept forwarding secure_redirects
arp_announce log_martians send_redirects
arp_filter mc_forwarding shared_media
arp_ignore medium_id src_valid_mark
arp_notify promote_secondaries tag
bootp_relay proxy_arp
[root@node3 lo]# echo2 >arp_announce
[root@node3 lo]# echo1 >arp_ignore
[root@node3 lo]# ifconfig ens33:0 192.168.42.200/32 broadcast 192.168.42.200up
[root@node3 lo]# route add-host 192.168.42.200 dev ens33:0[root@node3 lo]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface192.168.42.200 0.0.0.0 255.255.255.255 UH 0 0 0 ens33
2. 部署LNMP架构上线动态博客(上一篇博客有就不再赘述了)
(3)浏览器访问vip:
http://192.168.42.200/wp-admin/install.php