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)
上一篇 2018-07-23 15:37
下一篇 2018-07-23 19:22

相关推荐

  • linux练习题以及用户和组管理

    Linux练习题 列出当前系统上的所有已经登录的用户的用户名,注意:同一个用户登录多次,则只显示一次即可 取出最后登录到当前系统的用户的相关信息 取出当前系统上被用户当作默认shell的最多的那个shell 将/etc/passwd/中的第三个字段数值最大的后10个用户信息全部改为大写后保存至/tmp/maxusers中。 取出当前主机的IP地址,提示:对i…

    2018-05-26
  • nginx各模块介绍和应用

     ngx_http_access_module模块: 实现基于ip的访问控制功能 (1)、allow address | CIDR | unix: | all; (2)、deny address | CIDR | unix: | all; http, server, location, limit_except 2.ngx_http_auth_basic_m…

    Linux笔记 2018-07-02
  • 正则表达式简单明了的学法

    以下的内容都是在centos6.9或centos7中做过后得出的一些个人看法,希望大家多多交流,有误的地方请及时指正

    2018-04-07
  • linux基础篇

    1、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。
    2、bash的工作特性之命令执行状态返回值和命令行展开所涉及的内容及其示例演示。
    3、请使用命令行展开功能来完成以下练习:
    (1)、创建/tmp目录下的:a_c, a_d, b_c, b_d
    (2)、创建/tmp/mylinux目录下的:
    mylinux/
    ├── bin
    ├── boot
    │ └── grub
    ├── dev
    ├── etc
    │ ├── rc.d
    │ │ └── init.d
    │ └── sysconfig
    │ └── network-scripts
    ├── lib
    │ └── modules
    ├── lib64
    ├── proc
    ├── sbin
    ├── sys
    ├── tmp
    ├── usr
    │ └── local
    │ ├── bin
    │ └── sbin
    └── var
    ├── lock
    ├── log
    └── run

    2018-05-20
  • N31第六周作业

    本周(7.23–7.29)第六周 1、简述osi七层模型和TCP/IP五层模型 OSI 七层模型 1、应用层:OSI 参考模型中最靠近用户的一层,为计算机用户提供应用接口,也为用户直接提供各种网络服务。我们常见应用层的网络服务协议有:HTTP,HTTPS,FTP,POP3、SMTP等。 2、表示层:提供各种用于应用层数据的编码和转换功能,确保一个…

    Linux笔记 2018-08-01