keepalived+lvs(DR)

目录

一,作用

二,调度器配置

1,安装keepalived

[2, 安装ipvsadm](#2, 安装ipvsadm)

[3, 配置keepalived](#3, 配置keepalived)

[4. 查看lvs节点状态](#4. 查看lvs节点状态)

[5, web节点配置](#5, web节点配置)

[1.1 调整ARP参数](#1.1 调整ARP参数)

[1.2 配置虚拟IP地址](#1.2 配置虚拟IP地址)

1.3添加回环路由

1.4安装nginx并写入文件

[1.5 网站查看](#1.5 网站查看)

6,断掉主测试备


一,作用

使用keepalived解决lvs的单点故障

高可用集群

二,调度器配置

1,安装keepalived

yum install -y keepalived

2, 安装ipvsadm

yum install -y ipvsadm

modprobe ip_vs

lsmod |grep ip_vs

3, 配置keepalived

! Configuration File for keepalived

global_defs {

router_id LVS_DEVEL1

}

vrrp_instance VI_1 {

state MASTER

interface ens33

virtual_router_id 51

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.115.200

}

}

virtual_server 192.168.115.200 80 {

delay_loop 6

lb_algo rr

lb_kind DR

#persistence_timeout 50

protocol TCP

real_server 192.168.115.4 80 {

weight 1

HTTP_GET {

url {

path /

}

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

}

}

real_server 192.168.115.5 80 {

weight 1

HTTP_GET {

url {

path /

}

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

}

}

}

! Configuration File for keepalived

global_defs {

router_id LVS_DEVEL2

}

vrrp_instance VI_1 {

state BACKUP

interface ens33

virtual_router_id 51

priority 90

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.115.200

}

}

virtual_server 192.168.115.200 80 {

delay_loop 6

lb_algo rr

lb_kind DR

persistence_timeout 50

protocol TCP

real_server 192.168.115.4 80 {

weight 1

HTTP_GET {

url {

path /

}

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

}

}

real_server 192.168.115.5 80 {

weight 1

HTTP_GET {

url {

path /

}

connect_timeout 3

nb_get_retry 3

delay_before_retry 3

}

}

}

重启服务

4. 查看lvs节点状态

ipvsadm -ln

5, web节点配置

1.1 调整ARP参数

vim /etc/sysctl.conf

net.ipv4.conf.all.arp_ignore=1

net.ipv4.conf.all.arp_announce=2

net.ipv4.conf.default.arp_ignore=1

net.ipv4.conf.default.arp_announce = 2

net.ipv4.conf.lo.arp_ignore = 1

net.ipv4.conf.lo.arp_announce=2

sysctl -p

1.2 配置虚拟IP地址

cd /etc/sysconfig/network-scripts/

cp ifcfg-lo ifcfg-lo:0

vim ifcfg-lo:0

1.3添加回环路由

route add -host 192.168.115.200/32 dev lo:0

1.4安装nginx并写入文件

1.5 网站查看

6,断掉主测试备

在备调度器上查看虚拟ip是否更改过来

相关推荐
棒棒的唐43 分钟前
armbian平台ubuntu环境下telnet安装及启动,给pantherX2增加一个应急通道
linux·运维·armbian·telnetd
bug攻城狮44 分钟前
CentOS 7 设置静态 IP 地址
linux·tcp/ip·centos
纳切威1 小时前
CentOS 7部署Zabbix5.0
linux·运维·centos·zabbix
sunshine-sm1 小时前
CentOS Steam 9安装 MySQL 8
linux·运维·服务器·数据库·mysql·centos·centos stream
bug攻城狮1 小时前
CentOS 7 快速检查软件包是否已安装的5种方法
linux·运维·centos
尚久龙2 小时前
安卓学习 之 用户登录界面的简单实现
android·运维·服务器·学习·手机·android studio·安卓
DONG9992 小时前
ubuntu 22 安装轻量级桌面Xfce并使用xrdp远程桌面连接
linux·运维·ubuntu
呆萌小新@渊洁3 小时前
linux升级系统,重启出现Minimal BASH-like line editingis supported
linux·服务器
東雪蓮☆3 小时前
从零开始掌握 Web 与 Nginx:入门详解
运维·服务器·前端·nginx
ajassi20003 小时前
开源 C++ QT Widget 开发(十四)多媒体--录音机
linux·c++·qt·开源