KeepAlive高可用双主lvs-dr模型集群

1.环境:

RS1  :  192.168.0.117

RS2 :192.168.0.118

VS1 :192.168.0.106

VS2 :  192.168.0.114

VIP1:192.168.0.90     VIP2:192.168.0.99

2.在RS上安装httpd服务:yum install httpd

编辑网页:

vi /var/www/html/index.html

192.168.0.117

vi /var/www/html/index.html

192.168.0.118

3.在RS上配置VIP,两台RS上都要配置

echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 >/proc/sys/net/ipv4/conf/all/arp_announce
echo 2 >/proc/sys/net/ipv4/conf/lo/arp_announce
ifconfig  lo:0  192.168.0.90 netmask  255.255.255.255  broadcast  192.168.0.90  up
ifconfig  lo:1  192.168.0.99 netmask  255.255.255.255  broadcast  192.168.0.99  up
route add  -host  192.168.0.90  dev  ens33
route add  -host  192.168.0.99  dev  ens33
4.启动httpd服务
systemctl start httpd
5.在VS中配置vs的高可用以及VS集群服务
VS1:

global_defs {

notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id centos7-1
vrrp_mcast_group4 224.0.101.23
}

vrrp_instance myr1 {
state BACKUP
interface ens33
virtual_router_id 51
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.90/24 dev ens33
}

}

vrrp_instance myr2 {
state MASTER
interface ens33
virtual_router_id 52
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.99/24 dev ens33
}
}

virtual_server 192.168.0.90 80{
delay_loop 6
lb_algo wrr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 192.168.0.117 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.0.118 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

virtual_server 192.168.0.99 80{
delay_loop 6
lb_algo wrr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 192.168.0.117 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.0.118 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

VS2:

global_defs {

notification_email {
root@localhost
}
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id centos7-2
vrrp_mcast_group4 224.0.101.23
}

vrrp_instance myr1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.90/24 dev ens33
}
}

vrrp_instance myr2 {
state BACKUP
interface ens33
virtual_router_id 52
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.99/24 dev ens33
}
}

virtual_server 192.168.0.90 80{
delay_loop 6
lb_algo wrr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 192.168.0.117 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.0.118 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

virtual_server 192.168.0.99 80{
delay_loop 6
lb_algo wrr
lb_kind DR
protocol TCP
sorry_server 127.0.0.1 80
real_server 192.168.0.117 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.0.118 80{
weight 1
HTTP_GET{
url{
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

6.在vs上配置sorry_server
yum install httpd
vs2上
vi /var/www/html/index.html
Driector2:sorry_server
vs1上
vi /var/www/html/index.html
Driector1:sorry_server

7.启动keepalived

systemctl  start keepalived

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/103771

(0)
DPingDPing
上一篇 2018-07-23
下一篇 2018-07-23

相关推荐

  • Linux基本指令

    hostname  完整主机名cat +文件路径  可查看文件信息cat /etc/shells  显示所有shelluname -r    查看内核版本ls cpu   查看cpu信息free命令  查看内存 后面加-k是显示的内存以kb为单位,-m(MB),-g(GB),-h显示易读单位lsblk  查看硬盘dmesg  查看计算机启动的一些相关信息dm…

    2018-07-22
  • redis

    分布式存储一定是每个节点只存储一部分数据。

    2018-07-20
  • Linux系统上命令的使用格式

    命令的语法通用格式: ~]# COMMAND OPTIONS ARGUMENTS ifconfig命令格式 ifconfig [interface] [options] | address   Echo命令格式 echo [options] …[string]… tty命令格式 tty [options] startx命令格…

    Linux笔记 2018-05-13
  • LVS-NAT与LVS-DR模型实战

    LVS-NAT、LVS-DR实验

    2018-06-24
  • ansible进阶小技巧

    用ansible写playbook的朋友可能会发现,当配置工作很多时,如果在中间过程出错了,修改后想重新执行,前面的一大堆步骤让人感觉很烦躁。虽然提供了“retry”文件,但是却只是根据host来判断重新执行,仍然不够方便;又或者,中间的某些步骤特别耗时,比如下载一个很大的数据包,每次执行特别浪费时间,想要特别的跳过。怎么办?我猜你就是把不需要的部分给注释掉…

    Linux笔记 2018-06-03
  • 命令行展开案例

    [Azuth@azuth ~]$ mkdir /home/Azuth/tmp/{a,b}_{c,d}[Azuth@azuth ~]$ ll /home/Azuth/tmp/total 0drwxrwxr-x. 2 Azuth Azuth 6 May 20 20:35 a_cdrwxrwxr-x. 2 Azuth Azuth 6 May 20 20:35 a_…

    Linux笔记 2018-05-20