当前位置:网站首页>keepalived双机热备
keepalived双机热备
2022-07-26 08:36:00 【星辰为谁变】
1、实现keepalived+LVS-DR高可用的负载均衡web群集
keepalived的作用:
支持故障自动切换
支持节点健康状态检查

2、keepalived的安装与配置(在主、备份服务器上)
yum -y install keepalived ipvsadm
systemctl enable keepalived (开机自启)
修改内核参数文件,关闭ICMP重定向
vim /etc/sysctl.conf
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.ens33.send_redirects = 0
sysctl -p主服务器keepalived.conf的配置
vim /etc/keepalived/keepalived.conf
(以下为修改)
router_id LVS_DEVEL1 (本路由器(服务器)的名称)
state MASTER (热备状态,MASTER表示主服务器)
interface ens33 (承载VIP地址的物理接口)
virtual_router_id 51 (虚拟路由器的ID号,每个热备组保持一致)
priority 100 (优先级,数值越大优先级越高)
virtual_ipaddress {
200.0.0.100 (指定漂移地址,可以有多个)
}
virtual_server 200.0.0.100 80 { (虚拟服务器地址((ViP)、端口)
delay_loop 15 (健康检查的间隔时间(秒))
lb_algo rr (轮询(rr)调度算法)
lb_kind DR (直接路由((DR)群集工作模式)
nat_mask 255.255.255.0
! persistence_timeout 50 (连接保持时间(秒),若启用请去掉!号)
protocol TCP
real_server 200.0.0.4 80 { (第二个Web节点的地址)
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 200.0.0.4 80 { (第三个Web节点的地址)
weight 1
TCP_CHECK {
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
备份服务器keepalived.conf的配置
vim /etc/keepalived/keepalived.conf
router_id LVS_DEVEL2
vrrp_instance VI_1 {
state BACKUP
interface ens33
virtual_router_id 51
priority 90
其余配置与主服务相同启动服务
systemctl start keepalived
systemctl enable keepalived
3、web1和web2服务器配置
ifcfg-lo:0配置群集ip地址200.0.0.100,子网掩码为255.255.255.255
cd /etc/sysconfig/network-scripts
cp ifcfg-lo ifcfg-lo:0
vim ifcfg-lo:0
DEVICE=lo:0
IPADDR=200.0.0.100
NETMASK=255.255.255.255
ONBOOT=yes
ifup lo:0
vim /etc/rc.local
/sbin/route add -host 200.0.0.100 dev lo:0
route add -host 200.0.0.100 dev lo:0关闭部分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安装HTTP创建测试网页
yum -y install httpd
vim /var/www/html/index.html
<h1>1111111<h1> (web1配置)
<h1>2222222<h1> (web2配置)
systemctl restart httpd
systemctl enable httpd
边栏推荐
- When developing flutter, idea_ ID cannot solve the problem
- KV database based on raft consensus protocol
- Run file command
- Code cloud change remote warehouse command
- Fluent uses protobuf
- Kotlin function
- QT note 2
- Foundry tutorial: writing scalable smart contracts in various ways (Part 1)
- Analysis on the query method and efficiency of Oracle about date type
- Daily Note (11) -- word formula input arbitrary matrix
猜你喜欢

Excel find duplicate lines

What are the contents of Oracle OCP and MySQL OCP certification exams?

Prefix infix suffix expression (written conversion)

The second lesson is the construction of development environment

【FreeSwitch开发实践】自定义模块创建与使用

6、 Pinda general permission system__ pd-tools-log

OA项目之我的会议(会议排座&送审)

Kotlin variables and constants

Registration of finite element learning knowledge points

基于Raft共识协议的KV数据库
随机推荐
A summary of practical websites that won't brighten people's eyes
有限元学习知识点备案
What are the contents of Oracle OCP and MySQL OCP certification exams?
P3743 kotori的设备
QT uses QSS to make a beautiful login interface (hand-in-hand teaching)
Foundry教程:使用多种方式编写可升级的智能合约(上)
基于Raft共识协议的KV数据库
2022 national vocational college skills competition "network security" competition question file upload penetration test answer flag
Pxe原理和概念
Flutter text is left aligned with no blank space in the middle
Poor English, Oracle OCP or MySQL OCP exam can also get a high score of 80 points
Oracle 19C OCP 1z0-082 certification examination question bank (19-23)
Mysql/mariadb (Galera multi master mode) cluster construction
[freeswitch development practice] user defined module creation and use
The data read by Flink Oracle CDC is always null. Do you know
Redis进阶
Human computer interaction software based on C language
【FreeSwitch开发实践】使用SIP客户端Yate连接FreeSwitch进行VoIP通话
基于C语言设计的换乘指南打印系统
[GUI] swing package (window, pop-up window, label, panel, button, list, text box)