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

相关推荐

  • NGINX服务1

    I/O模型 Nginx介绍 Nginx安装 Nginx各种模块

    Linux笔记 2018-07-04
  • ansible实战应用之角色装nginx,httpd

    流程图如下: 上图表明: 1).tasks夹: .grupyml .useryml: 指定uid;gid,且最好uid和gid统一,这样好管理要;加入组中;一般来说建一个帐号是给特定的服务用的,一般来讲这个帐号 都是系统帐号;且它的shell类型,为了安全一般都是/sbin/nologin * 不确定uid号有没有人有的话,可以用#getent passwd…

    Linux笔记 2018-06-03
  • 初学linux所遇到错误详解与使用技巧

    适合小白新手,好懂易操作。

    2018-03-31
  • Web Service基础、httpd-2.2、httpd-2.4

    Web Service 传输层:提供进程地址 port number: tcp:传输控制协议,面向连接的协议,通信前需要建立虚拟链路,结束后拆除链路;端口:0-65535 udp:user datagram protocol,无连接的协议;端口:0-65535   IANA: 0-1023:特权端口,永久分配给固定应用使用 1024-41951:注…

    Linux笔记 2018-04-24
  • 文本处理工具

    简要介绍各种文本查看,分析和统计的工具

    Linux笔记 2018-04-06
  • sed的用法

    sed是一种流编辑器,它一次处理一行内容。 处理时,把当前处理的行存储在临时缓冲区(pattern space),同时输出到屏幕,接着用sed命令处理缓冲区中的内容,接着读取下一行,这样不断重复,直到文件末尾。 用法: sed -[options] [操作] inputfile -n:不输出模式空间内容到屏幕,即不自动打印 -e: 多点编辑 -f:/PATH…

    2018-04-22