当前位置:网站首页>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 .
边栏推荐
- Canoe test: two ways to create CAPL test module
- Solaris 10网络服务
- [test theory] test the dimension of professional ability
- Deepmind proposed a Zuan AI, which specially outputs network attack language
- JMeter correlation technology
- Locust installation
- Post man JSON script version conversion
- What if the book written is too popular? Author of "deep reinforcement learning" at Peking University: then open the download
- Read a piece of text into the vector object, and each word is stored as an element in the vector. Convert each word in the vector object to uppercase letters. Output the converted elements in the vect
- Understanding of object
猜你喜欢
How to use diff and patch to update the source code
Huge number (C language)
Appscan installation error: unable to install from Net runtime security policy logout appscan solution
Elevator dispatching (pairing project) ②
Elevator dispatching (pairing project) ③
[Galaxy Kirin V10] [server] KVM create Bridge
[Galaxy Kirin V10] [server] set time synchronization of intranet server
Appscan installation steps
Unittest+airtest+beatiulreport combine the three to make a beautiful test report
Canoe - the second simulation project -xvihicle1 bus database design (operation)
随机推荐
Fundamentals of software testing
Canoe: what is vtsystem
/*The rewriter outputs the contents of the IA array. It is required that the type defined by typedef cannot be used in the outer loop*/
regular expression
Postman interface test
SSH原理和公钥认证
Write a program to define an array with 10 int elements, and take its position in the array as the initial value of each element.
Interview and lecture summary 1
51 data analysis post
Crawl Zhejiang industry and trade news page
Take advantage of the world's sleeping gap to improve and surpass yourself -- get up early
Student achievement management system (C language)
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?
Day06 list job
CAPL: on sysVar_ Update difference on sysvar
Installation of ES plug-in in Google browser
[Galaxy Kirin V10] [server] failed to start the network
[Galaxy Kirin V10] [desktop and server] FRP intranet penetration
VI text editor and user rights management, group management and time management
JMeter assembly point technology and logic controller