当前位置:网站首页>Lvs+kept (DR mode) learning notes
Lvs+kept (DR mode) learning notes
2022-07-07 06:58:00 【Network stupid pig】
1. sketch
In the medium-sized projects of the Internet , A single server is often unable to meet the performance requirements of the business itself , At this time, it will expand in parallel , Spread the load among several servers ( colony ). Generally, clusters are DNS polling ,LVS,nginx Load balancing .
The main purposes of the cluster include the following three points : High availability 、 Scalable 、 Load balancing .
A complete cluster architecture , You need to include the following three functions : Load balancing 、 Fault isolation 、 Failed to switch
Load balancing : According to the set algorithm , Through the load balancer (Director) Forward external requests to servers in each cluster (Real server)
Fault isolation : When one or more servers in the cluster (Real server) In case of failure or failure to provide services , The cluster can remove them from the forwarding queue , To ensure that user access will not be incorrectly forwarded to servers that cannot be provided (Real server) Handle . And when the server fails (Real server) When it returns to normal , It can rejoin the forwarding queue of the cluster .
Failed to switch : Failed to switch master (Master) The key is to remove the load balancer (Director) A single point of question , Once the load balancer (Director) failure , Standby machine (Slave) Can replace the master (Master) Load Balancer (Director) Accept user requests , And when the main load balancer (Director) When it comes back to normal , Able to take over user requests again ( Depending on the configuration )
LVS yes Linux Virtual Linux Abbreviation , namely Linux Virtual server , Is a commonly used server cluster system , This function has been widely integrated in Linux The kernel .
Keepalived Is a server detection status software , It can provide fault isolation and failover functions for clusters
ipvsadm It is LVS Management tools , Ability to add , modify , Delete , Check the configuration and forwarding status of the current cluster
In the use of Keepalived The scheme , As long as the system is installed ipvsadm command , Just go through Keepalived The configuration file of can realize all configurations of the cluster .
This time mainly introduces DR Cluster configuration in mode ,DR Direct routing , Load Balancer (Director) Only negative forwarding of user requests , The request response is provided by the server (Real server) Provide directly .
The following is a simple architecture diagram

2. install
2.1.ipvsadm install
yum install ipvsadm2.2.Keepalived install
yum install keepalived2.3.LVS Support view
uname -r
# see linux Kernel version ,2.4 It has been integrated ,2.4 Please recompile the kernel before ( Now there is no 2.4 Before )3. To configure
Preset environment :
Load Balancer A:
ip Address : 192.168.1.12
colony VIP:192.168.1.100
Real server B:
ip Address :192.168.1.13
Multicast address :192.168.1.100
Real server C:
ip Address :192.168.1.14
Multicast address :192.168.1.100
Real server configuration :
Real servers do not need to install any software , Just configure it like an ordinary non clustered server
# You can write the following commands shell Script , And in /etc/rc.local It is configured to execute automatically every time you start up
# Be careful : Must be bound to the loopback network card (lo)
# down To make the script repeatable
ifconfig lo:0 192.168.1.100 broadcast 192.168.1.100 netmask 255.255.255.255 down
ifconfig lo:0 192.168.1.100 broadcast 192.168.1.100 netmask 255.255.255.255 up
# This step is very important , In practical applications, multiple real servers in the cluster use the same multicast address , Therefore, it is necessary to suppress ARP radio broadcast
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce### Please note that : The physical machine / The virtual machine lo Return address , broadcast, netmask Wait to compare !!!
After successful execution , Input ifconfig You should see the following results :
lo:0: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 192.168.1.100 netmask 255.255.255.255
loop txqueuelen 0 (Local Loopback)Because of inhibition ARP radio broadcast , Input ping 192.168.1.100 It should be the following result :
PING 192.168.1.100 (192.168.1.100) 56(84) bytes of data. --- 192.168.1.100 ping statistics --- 6 packets transmitted, 0 received, 100% packet loss, time 5042ms
unable ping through
Load balancer configuration
Keepalived Default profile location /etc/keepalived/keepalived.conf
The configuration is as follows :
virtual_server 192.168.1.100 80 { delay_loop 6 lb_algo rr # rr Polling lb_kind DR # DR Pattern nat_mask 255.255.255.255 #persistence_timeout 600 # Session holding time protocol TCP real_server 192.168.1.13 80 { #weight 100 # stay wlc Load balancing algorithm takes effect # Real server status check TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } real_server 192.168.1.14 80 { #weight 100 # stay wlc Load balancing algorithm takes effect # Real server status check TCP_CHECK { connect_timeout 3 nb_get_retry 3 delay_before_retry 3 connect_port 80 } } }
Input keepalived -D Command to start keeplived
see keepalived Running state ( The normal startup is three processes )
ps aux | grep "keepalived"
see keepalived Run log
tail /var/log/message
Check the configuration results ( Under normal circumstances, you can see that the configured information has been loaded correctly )
ipvsadm -L
边栏推荐
- MYSQL binlog相关命令
- leetcode 509. Fibonacci Number(斐波那契数字)
- Please tell me how to monitor multiple schemas and tables by listening to PgSQL
- 2022年全国所有A级景区数据(13604条)
- 快速定量,Abbkine 蛋白质定量试剂盒BCA法来了!
- 基于JS的迷宫小游戏
- Config分布式配置中心
- Redhat5 installing vmware tools under virtual machine
- Learning records on July 4, 2022
- Linear algebra (1)
猜你喜欢
![[GNN] graphic gnn:a gender Introduction (including video)](/img/b3/0855885dafa7afaa7375b8d2195974.png)
[GNN] graphic gnn:a gender Introduction (including video)

Abnova循环肿瘤DNA丨全血分离,基因组DNA萃取分析

品牌电商如何逆势增长?在这里预见未来!
![[noi simulation] regional division (conclusion, structure)](/img/7d/4c66cd0a30e52ccd167b6138fcb4df.png)
[noi simulation] regional division (conclusion, structure)

当前发布的SKU(销售规格)信息中包含疑似与宝贝无关的字

Answer to the first stage of the assignment of "information security management and evaluation" of the higher vocational group of the 2018 Jiangsu Vocational College skills competition

Data of all class a scenic spots in China in 2022 (13604)

MySQL的主从复制原理

项目实战 五 拟合直线 获得中线
![Stack and queue-p79-10 [2014 unified examination real question]](/img/7f/e5bba2f64bb77e1781076361c32f01.jpg)
Stack and queue-p79-10 [2014 unified examination real question]
随机推荐
服装门店如何盈利?
MOS tube parameters μ A method of Cox
Maze games based on JS
Postgresql中procedure支持事务语法(实例&分析)
请问 flinksql对接cdc时 如何实现计算某个字段update前后的差异 ?
How can clothing stores make profits?
MySQL installation
Installing redis and windows extension method under win system
场馆怎么做体育培训?
偏执的非合格公司
Prompt for channel security on the super-v / device defender side when installing vmmare
Abnova 膜蛋白脂蛋白体技术及类别展示
Tkinter window selects PCD file and displays point cloud (open3d)
LM11丨重构K线构建择时交易策略
大咖云集|NextArch基金会云开发Meetup来啦
What books can greatly improve programming ideas and abilities?
一条慢SQL拖死整个系统
DHCP路由器工作原理
LVS+Keepalived(DR模式)学习笔记
Take you to brush (niuke.com) C language hundred questions (the first day)