当前位置:网站首页>【集群】LVS+keepalived高可用集群
【集群】LVS+keepalived高可用集群
2022-06-11 07:29:00 【雪碧不要气】
前言
本博客内容仅为记录博主思路,仅供参考,一切以自己实践结果为准。
一、LVS+keepalived
1.0 架构概况
| 作用 | IP地址 | 安装服务 |
|---|---|---|
| 主负载均衡器 | 192.168.13.10 | ipvsadm/keepalived |
| 节点服务器1 | 192.168.13.20 | httpd |
| 节点服务器2 | 192.168.13.30 | httpd |
| 备用负载均衡器 | 192.168.13.40 | ipvsadm/keepalived |
1.2 节点服务器
yum install -y httpd
cd /etc/sysconfig/network-scripts/
cp ifcfg-lo ifcfg-lo:0
vim ifcfg-lo:0
DEVICE=lo:0
IPADDR=192.168.13.100
NETMASK=255.255.255.255
ONBOOT=yes
vim /etc/rc.local
route add -host 192.168.13.100 dev lo:0
chmod +x /etc/rc.d/rc.local
vim /etc/sysctl.conf
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
sysctl -p
echo '<h1>This is the first test web1!</h1>' > /var/www/html/index.html
systemctl start httpd
#另一个节点服务器重复此操作
1.2 主负载均衡服务器
yum install -y ipvsadm keepalived
cd /etc/keepalived
vim keepalived.conf
10行:smtp_server 127.0.0.1
12行:router_id LVS_01
13-16行:删除
#vrrp热备份模块#
17行:interface ens33
19行(priority 100上方插入):nopreempt
27行:192.168.13.100
28-29行:删除
#virtual虚拟服务器模块#
31行:192.168.13.100 80
34行:lb_kind DR
35行:persistence_timeout 0
36行:protocol TCP
38行:real_server 192.168.13.20 80 {
39行:weight 1
40行:TCP_CHECK {
41行:connect_port 80
42行:connect_timeout 3
43行:nb_get_retry 3
44行:delay_before_retry 3
45行:}
46行:}
47-55行:38,46 co 46
#将上面9行节点服务器配置复制下来,改一下节点服务器IP地址即可
56行:}
56行以下:全部删除
systemctl start keepalived
scp keepalived.conf 192.168.13.40:`pwd`
ipvsadm-save > /etc/sysconfig/ipvsadm
systemctl restart keepalived
ipvsadm -ln
1.3 备负载均衡服务器
yum install -y ipvsadm keepalived
cd /etc/keepalived/
vim keepalived.conf
12行:router_id LVS_02
16行:state BACKUP
20行:priority 90
systemctl start keepalived
ipvsadm-save > /etc/sysconfig/ipvsadm
systemctl start ipvsadm
systemctl restart keepalived
ipvsadm -ln
1.4 测试
- 1、网页访问192.168.13.100,产生负载均衡效果
- 2、主负载:systemctl stop keepalived,VIP地址跳到备用负载均衡器(ip addr查看)
二、负载均衡器配置文件模板
! Configuration File for keepalived
global_defs {
notification_email {
[email protected].loc
[email protected].loc
[email protected].loc
}
notification_email_from Alexandre.[email protected].loc
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_01
}
vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
nopreempt
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.13.100
}
}
virtual_server 192.168.13.100 80 {
delay_loop 6
lb_algo rr
lb_kind DR
persistence_timeout 0
protocol TCP
real_server 192.168.13.20 80 {
weight 1
TCP_CHECK{
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.13.30 80 {
weight 1
TCP_CHECK{
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
三、结语
- 心态要好
边栏推荐
- JVM learning record (VII) -- class loading process and parental delegation model
- MFC auxiliary CString string splicing
- 【编译原理】05-语法制导的语义计算——基于翻译模式的语义计算
- Matrix tree theorem
- 如果要存 IP 地址,用什么数据类型比较好?99%人都会答错!
- P5431 [template] multiplicative inverse 2
- Aiop introduction
- 【AtCoder2387】+/- Rectangle
- [STL source code analysis] summary notes (7): ingenious deque
- 10 advanced concepts that must be understood in learning SQL
猜你喜欢

Sdl-2 thread logic

Raspberry pie builds a full-featured NAS server (07): manage your library & read as you please

Post-processing of ffmpeg miscellaneous notes

@JsonProperty注解
![[analysis of STL source code] summary note (4): behind the scenes hero allocator](/img/b9/cf53fd8f933042ff65844d61eca55e.jpg)
[analysis of STL source code] summary note (4): behind the scenes hero allocator
![P5431 [template] multiplicative inverse 2](/img/63/1cb95a55c9ce9b92d6d55381d0215b.jpg)
P5431 [template] multiplicative inverse 2
![20200730 T3 small B farm [maximum perimeter empty rectangle (monotone stack + line segment tree)] &](/img/90/99356e679a52890a0b88068d082bbe.jpg)
20200730 T3 small B farm [maximum perimeter empty rectangle (monotone stack + line segment tree)] & "ROI 2017 day 2" learning track

Use definite integral to calculate triangle area
![[Oracle database] mammy tutorial day04 Sorting Query](/img/79/9db26aa2d9dbb5514427edf03004f4.png)
[Oracle database] mammy tutorial day04 Sorting Query

【编译原理】05-语法制导的语义计算——基于翻译模式的语义计算
随机推荐
C+tinycthread implementation thread
1190. invert the substring between each pair of parentheses
Building a full-featured NAS server with raspberry pie (06): built-in file synchronization tool for penetration
The rotation of the earth and the moon (II)
MFC debugger OutputDebugString override
SQLZOO刷题记录-3
20200730 T3 small B farm [maximum perimeter empty rectangle (monotone stack + line segment tree)] & "ROI 2017 day 2" learning track
JVM tuning
群晖DS918创建m.2 固态硬盘SSD读写缓存
【CF#693 (Div. 3)】B. Fair Division
【AtCoder2307】Tree Game(博弈)
Sdl-4 PCM playback
Summary of written test questions of shopee 2021 autumn recruitment
【LeetCode】-- 17. Letter combination of telephone number
【CF】 A. New Year Candles
软件测试周刊(第75期):唯有平视,才能看见真实的自己。
MS office level II wrong question record [7]
Compound RateModel合约解析
【NOIP2016 D1T3】换教室(期望DP+Floyd)(究极思维陷阱!)
P5431 [template] multiplicative inverse 2