当前位置:网站首页>Lvs+kept realizes four layers of load and high availability
Lvs+kept realizes four layers of load and high availability
2022-07-04 11:01:00 【Brother Xing plays with the clouds】
A new project will be launched recently , Requires soft load , Originally decided to use nginx Acting as a reverse agent , But after loading nginx in the future , Find out nginx Unable to display css、js, It's still under study , However, due to the urgency of the project , So the classic architecture is still used LVS+Keepalived To achieve .
Environmental Science :
LVS-01 192.168.199.117 MASTER
LVS-02 192.168.199.118 BACKUP
WEB-01 192.168.199.113
WEB-02 192.168.199.114
VIP 192.168.199.119
Compilation and installation LVS
ln -s/usr/src/kernels/2.6.18-308.el5-x86_64/ /usr/src/linux
wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz
tar zxf ipvsadm-1.26.tar.gz
cd ipvsadm-1.26
make
Found an error , The error results are as follows :
make[1]: *** [libipvs.o] Error1
make[1]: Leaving directory`/root/tools/ipvsadm-1.26/libipvs'
make: *** [libs] Error 2
Inquiry , There are many kinds of statements , None of them solved my problem :
1、 Some say that you need to do kernel soft links ln-s /usr/src/kernels/2.6.18-308.el5-x86_64/ /usr/src/linux
2、 Some say they want yuminstall gcc-*
3、 What's more, it's yum installlibnl* popt*
The above method may be applicable to the actual environment , But it doesn't work on my machine . For a long time , Consult experts , Check again http://www.linuxvirtualserver.org/Documents.html Official documents , Finally, it is considered that the version does not match the kernel , Sum up as follows 2 spot :
1、 ipvsadm-1.26 Version fit kernel 2.6.28-rc3 And later
2、 Choose the right one ipvsadm after , Also choose the corresponding keepalived, Otherwise, start keepalived after , No, realserver list . The general display is like this :
IP Virtual Server version 1.2.1(size=4096)
Prot LocalAddress:PortScheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
Okay , Problem found , To operate , Download the lower version of ipvsadm, My kernel version is 2.6.18-308.el5-x86_64, use ipvsadm-1.24 Test ok ,keepalived The version is keepalived-1.1.15, The specific operation is as follows :
install LVS
ln -s/usr/src/kernels/2.6.18-308.el5-x86_64/ /usr/src/linux
wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz
tar zxvf ipvsadm-1.24.tar.gz
cd ipvsadm-1.24
make
make install
cd ..
ipvsadm –version
install keepalived
wget http://www.keepalived.org/software/keepalived-1.1.15.tar.gz
tar zxfkeepalived-1.1.15.tar.gz
cd keepalived-1.1.15
./configure
make
make install
cp/usr/local/etc/rc.d/init.d/keepalived /etc/init.d/
cp/usr/local/etc/sysconfig/keepalived /etc/sysconfig/
mkdir /etc/keepalived/
cp/usr/local/etc/keepalived/keepalived.conf /etc/keepalived/
cp /usr/local/sbin/keepalived/usr/sbin/
/etc/init.d/keepalived start
thus , Installation completed , The following configuration file .
LVS-01 above keepalived Configuration file for , The main and standby are basically the same , The difference is the red part
vim /etc/keepalived/keepalived.conf
! Configuration File forkeepalived
global_defs {
router_id LVS-01 #routeid
}
vrrp_instance LVS {
state MASTER # Prepared as BACKUP
interface eth0
virtual_router_id 251
priority 100 # The value of the standby node is smaller than that of the primary node
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.199.119
}
}
virtual_server 192.168.199.11980 {
delay_loop 6
lb_algo wrr
lb_kind DR
persistence_timeout 60 # Conversation retention
protocol TCP
real_server 192.168.199.113 80 {
weight 1
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 192.168.168.199.114 80 {
weight 1
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
start-up keealived
/etc/init.d/keepalived restart
Check if there is VIP
[[email protected] ipvsadm-1.26]#ip add
1: lo:<LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:70:47:f4 brdff:ff:ff:ff:ff:ff
inet 192.168.199.117/24 brd 192.168.199.255scope global eth0
inet 192.168.199.119/32 scope global eth0
inet6 fe80::20c:29ff:fe70:47f4/64 scopelink
valid_lft forever preferred_lft forever
3: sit0: <NOARP> mtu 1480qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
Check if there is realserver list
[[email protected] ipvsadm-1.26]#ipvsadm -Ln
IP Virtual Server version 1.2.1(size=4096)
Prot LocalAddress:PortScheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.199.119:80 wrr
-> 192.168.199.113:80 Route 1 0 0
-> 192.168.199.114:80 Route 1 0 0
Finally, don't forget , Yes realserver The above configuration VIP and ARP Inhibition , Just use the script , As follows :
[[email protected] tools]# cat realserver.sh
#!/bin/sh
[ -f"/etc/init.d/functions" ] && . /etc/init.d/functions
VIP=(
192.168.199.119
)
start(){
#bind VIP
for ((i=0;i<${#VIP[*]};i++))
do
/sbin/ifconfig lo:i {VIP[
done
#ARP restrain
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
}
stop(){
for ((i=0;i<${#VIP[*]};i++))
do
/sbin/ifconfig lo:i {VIP[
done
echo "0">/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "0">/proc/sys/net/ipv4/conf/lo/arp_announce
echo "0">/proc/sys/net/ipv4/conf/all/arp_ignore
echo "0">/proc/sys/net/ipv4/conf/all/arp_announce
}
case "$1" in
start)
start
if [ $? -eq 0 ];then
action "ipvs start sucess" /bin/true
else
action "ipvs start failed "/bin/false
fi
;;
stop)
stop
if [ $? -eq 0 ];then
action "ipvs stop sucess" /bin/true
else
action "ipvs stop failed "/bin/false
fi
;;
*)
echo "USAGE:$0{start|stop}"
esac
After execution , see VIP
[[email protected] tools]# ip add
1: lo:<LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet 192.168.199.119/32 brd 192.168.199.119scope global lo:0
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:41:7c:7e brdff:ff:ff:ff:ff:ff
inet 192.168.199.114/24 brd 192.168.199.255scope global eth0
inet6 fe80::20c:29ff:fe41:7c7e/64 scopelink
valid_lft forever preferred_lft forever
3: sit0: <NOARP> mtu 1480qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
The rest is fault simulation and testing , I won't write more here .
边栏推荐
- Dictionaries and collections
- Analysis function in SQL
- JMeter correlation technology
- Fundamentals of software testing
- 本地Mysql忘记密码的修改方法(windows)[通俗易懂]
- Oracle11g | getting started with database. It's enough to read this 10000 word analysis
- 51 data analysis post
- Introduction to canoe automatic test system
- Canoe - the second simulation engineering - xvehicle - 2 panel design (operation)
- Jemeter plug-in technology
猜你喜欢
Ten key performance indicators of software applications
Analysis function in SQL
Discussion | has large AI become autonomous? Lecun, chief scientist of openai
[Galaxy Kirin V10] [server] system partition expansion
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
Canoe - the third simulation project - bus simulation - 2 function introduction, network topology
Send a request using paste raw text
Elevator dispatching (pairing project) ④
20 kinds of hardware engineers must be aware of basic components | the latest update to 8.13
Climb Phoenix Mountain on December 19, 2021
随机推荐
MBG combat zero basis
XMIND installation
Analysis function in SQL
[Galaxy Kirin V10] [desktop] printer
Fundamentals of software testing
2、 Operators and branches
Canoe - the third simulation project - bus simulation - 3-1 project implementation
Getting started with window functions
Network connection (II) three handshakes, four waves, socket essence, packaging of network packets, TCP header, IP header, ACK confirmation, sliding window, results of network packets, working mode of
For and while loops
Regular expression
Capl: timer event
Const's constant member function after the function; Form, characteristics and use of inline function
How to deal with the relationship between colleagues
Using Lua to realize 99 multiplication table
JMeter common configuration components and parameterization
VI text editor and user rights management, group management and time management
Elevator dispatching (pairing project) ①
2022 AAAI fellow release! Yan Shuicheng, chief scientist of sail, and Feng Yan, Professor of Hong Kong University of science and technology, were selected
Basic function exercises