当前位置:网站首页>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 .
边栏推荐
- F12 clear the cookies of the corresponding web address
- [Galaxy Kirin V10] [desktop] login system flash back
- Network connection (III) functions and similarities and differences of hubs, switches and routers, routing tables and tables in switches, why do you need address translation and packet filtering?
- Terms related to hacker technology
- Article publishing experiment
- PHP programming language (1) - operators
- re. Sub() usage
- [Galaxy Kirin V10] [server] soft RAID configuration
- Write a program that uses pointers to set all elements of an int array to 4.18: 0.
- [Galaxy Kirin V10] [desktop] can't be started or the screen is black
猜你喜欢
[test theory] test process management
Personal thoughts on the development of game automation protocol testing tool
Canoe - the third simulation project - bus simulation-1 overview
[Galaxy Kirin V10] [server] soft RAID configuration
Ten key performance indicators of software applications
Canoe the second simulation engineering xvehicle 3 CAPL programming (operation)
TS type gymnastics: illustrating a complex advanced type
Post man JSON script version conversion
Notes on writing test points in mind mapping
Discussion | has large AI become autonomous? Lecun, chief scientist of openai
随机推荐
Summary of automated testing framework
Locust learning record I
Swagger and OpenAPI
array_ The contains() function uses
Canoe: the difference between environment variables and system variables
[Galaxy Kirin V10] [desktop] printer
Capl: timer event
How to use diff and patch to update the source code
Recursive method to achieve full permutation (C language)
Failed to configure a DataSource: ‘url‘ attribute is not specified... Bug solution
2022 AAAI fellow release! Yan Shuicheng, chief scientist of sail, and Feng Yan, Professor of Hong Kong University of science and technology, were selected
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
Article publishing experiment
/*Rewrite the program, find the value of the element, and return the iterator 9.13: pointing to the found element. Make sure that the program works correctly when the element you are looking for does
Communication layer of csframework
Interview and lecture summary 1
Fundamentals of database operation
Advanced order of function
[Galaxy Kirin V10] [desktop] cannot add printer
20 minutes to learn what XML is_ XML learning notes_ What is an XML file_ Basic grammatical rules_ How to parse