当前位置:网站首页>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
边栏推荐
- Install HR schema, example, and Scott schema on Oracle and MySQL
- Excel delete blank lines
- 【加密周报】加密市场有所回温?寒冬仍未解冻 盘点上周加密市场发生的重大事件
- Please tell me if there is any way to increase the write out rate when the Flink SQL client is in the sink table. When synchronizing through sink table
- Error handling response: Error: Syntax error, unrecognized expression: .c-container /deep/ .c-contai
- OA项目之我的会议(查询)
- Kotlin variables and constants
- Flutter compilation fails
- QT note 1
- I am 35 years old.
猜你喜欢

Code cloud change remote warehouse command

QT note 2
![[time complexity, space complexity]](/img/f2/f82c7e0a6ab9f893023c2ddbac3431.png)
[time complexity, space complexity]

OA项目之我的会议(查询)

CV learning notes (optical flow)

Sub Chocolate & paint area

Why reserve a capacitor station on the clock output?
![[freeswitch development practice] use SIP client Yate to connect freeswitch for VoIP calls](/img/8b/d5792a00fc5798d3d960f1f1b1088e.png)
[freeswitch development practice] use SIP client Yate to connect freeswitch for VoIP calls

Excel delete blank lines
![[GUI] swing package (window, pop-up window, label, panel, button, list, text box)](/img/05/8e7483768a4ad2036497cac136b77d.png)
[GUI] swing package (window, pop-up window, label, panel, button, list, text box)
随机推荐
Redis advanced
[abstract base class inheritance, DOM, event - learning summary]
基于Raft共识协议的KV数据库
2022年收益率最高的理财产品是哪个?
The data read by Flink Oracle CDC is always null. Do you know
CV learning notes (optical flow)
I am 35 years old.
Kotlin function
Daily Note (11) -- word formula input arbitrary matrix
After MySQL 8 OCP (1z0-908), hand in your homework
Oracle 19C OCP 1z0-082 certification examination question bank (42-50)
Flutter WebView jitter
Storage of drawings (refined version)
基于C#实现的文件管理文件系统
Oracle 19C OCP 1z0-082 certification examination question bank (36-41)
2022/7/18 exam summary
The full name of flitter IDFA is identity for advertisers, that is, advertising identifiers. It is used to mark users. At present, it is most widely used for advertising, personalized recommendation,
The second lesson is the construction of development environment
Mycat2 sub database and sub table
Oracle 19C OCP 1z0-082 certification examination question bank (24-29)