当前位置:网站首页>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 .
边栏推荐
- Using SA token to solve websocket handshake authentication
- [testing theory] thinking about testing profession
- Regular expression
- Common system modules and file operations
- Iterator generators and modules
- TS type gymnastics: illustrating a complex advanced type
- Deepmind proposed a Zuan AI, which specially outputs network attack language
- Advanced order of function
- 51 data analysis post
- Design and common methods of test case documents
猜你喜欢

Elevator dispatching (pairing project) ②
![[Galaxy Kirin V10] [server] system partition expansion](/img/49/5d3e28eab45d300bd5695e47b35e6b.jpg)
[Galaxy Kirin V10] [server] system partition expansion
![[Galaxy Kirin V10] [server] set time synchronization of intranet server](/img/f8/0847314029930840c91bce97ccd961.jpg)
[Galaxy Kirin V10] [server] set time synchronization of intranet server

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?

JMeter common configuration components and parameterization

Appscan installation steps

Article publishing experiment

Installation of ES plug-in in Google browser

Quick sort (C language)

Usage of case when then else end statement
随机推荐
Postman interface test
MFC document view framework (relationship between classes)
Snake (C language)
Write a program to judge whether the two arrays are equal, and then write a similar program to compare the two vectors.
Virtual machine configuration network
[Galaxy Kirin V10] [server] KVM create Bridge
regular expression
Common system modules and file operations
Send a request using paste raw text
Ten key performance indicators of software applications
Huge number (C language)
守护进程Xinted和日志记录Syslogd
Analysis function in SQL
Deepmind proposed a Zuan AI, which specially outputs network attack language
Canoe - the third simulation project - bus simulation-1 overview
Basic function exercises
Jemeter plug-in technology
Solaris 10网络服务
/*Write a function to open the file for input, read the contents of the file into the vector container of string class 8.9: type, and store each line as an element of the container object*/
How do microservices aggregate API documents? This wave of show~