In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to achieve Keepalive+lvs master-slave dr load balancing in LINUX". In daily operation, I believe many people have doubts about how to achieve Keepalive+lvs master-slave dr load balancing in LINUX. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to achieve Keepalive+lvs master-slave dr load balancing in LINUX". Next, please follow the editor to study!
One. Master-slave keepalive + test machine 1.1Master keepalive
1.1.1 configuring a local yum source
# mkdir / media/cdrom / / create a cdrom directory
# mkdir / etc/yum.repo.d/a / / create a directory in the yum source directory
# mv / etc/yum.repo.d/Cent* / etc/yum.repo.d/a / / copy all files starting with Cent to the a directory
# mount / dev/cdrom / media/cdrom/ / Mount the CD to the / media/cdrom/ directory
# vim / etc/yum.repo.d/local.repo / / Edit the local yum source file
[base]
Name=cets
Baseurl= file:///media/cdrom
Enabled=1
Gpgcheck=0
1.1.2 install support for keepalive package
# yum-y install openssl-devel / / install openssl-devel software using yum source
# yum-y install popt-devel / / install popt-devel software using yum source
1.1.3 compile and install keepalive
# tar zxf keepalived-1.2.13.tar.gz / / decompress the keepalived package
# cd keepalived-1.2.13 / / enter the decompressed folder
#. / configure-prefix=/-- with-kernel-dir=/usr/src/kernels/2.6.32-431.el6.x86_64 / / compile to specify the installation path
# make & & make install / / compile and install keepalived
1.1.4 modify the configuration file and enable keepalive
Native ip 192.168.1.1
# cd / etc/keepalived/ enter the home directory of keepalived software
# cp keepalived.conf keepalived.conf.bak / / back up the keepalived main configuration file
# vim keepalived.conf / / Edit keepalived main configuration file
Router_id R1 / / name the keepalived host
State MASTER / / the keepalived host type is dominant
Priority 100 / / priority 100
Virtual_ipaddress {
192.168.1.254} / / Virtual ip address
# service keepalived restart / / restart the service
# service iptables stop / / turn off the firewall
# service network restart / / restart the Nic
1.2 install from keepalive1.2.1 native yum1.2.2 support keepalive package 1.2.3 compile install keepalive1.2.4 modify configuration file and enable keepalive
Native ip 192.168.1.5
Router_id r2
State SL**E remarks: you can also use BACKUP
Priority 99
Virtual_ipaddress {
192.168.1.254}
1.3 Test Machine 1.3.1 Test Machine
Ip address 192.168.1.110
Service iptables stop
Test login 192.168.1.25
1.3.2 main on / off service test
Turn off the firewall
Turn on httpd
Restart keepalive
Edit the test page # vim / var/www/html/index.html
192.168.1.1
Down drop the main service in the test machine when accessing 192.168.1.254
1.3.2 testing from enabling and shutting down services
Turn off the firewall
Turn on httpd
Restart keepalive
# ip addr show dev eth0 View Virtual APIs
Edit the test page # vim / var/www/html/index.html
192.168.1.5
II. Master-slave keepalive+ lvs + test
2.1 main keepalive2.1.1 configuration yum Source 2.1.2 install support Pack 2.1.3 compile and install keepalive2.1.4 modify configuration File
Router_id r1
State MASTER
Priority 100
Virtual_ipaddress {
192.168.1.254}
Virtual_server 192.168.1.254 80 {
Delay_loop 6
Lb_algo rr
Lb_kind DR
Nat_mask 255.255.255.0
Persistence_timeout 50
Protocol TCP
Real_server 192.168.1.11 80 {
Weight 1
TCP_CHECK {
Connect-port 80
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
}}
}
Virtual_server 192.168.1.254 80 {
Delay_loop 6
Lb_algo rr
Lb_kind DR
Nat_mask 255.255.255.0
Persistence_timeout 50
Protocol TCP
Real_server 192.168.1.22 80 {
Weight 1
TCP_CHECK {
Connect-port 80
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
}}
}
2.1.5 install ipvsadm test to see the effect 2.2 from keepalive
1. Local yum
two。 Install the support keepalive package
3. Compile and install keepalive
4. Modify the configuration file and enable keepalive
Copy backup cp keepalive.conf keepalive.conf.bak
Native ip 192.168.1.5
Router_id r2
State SL**E
Priority 99
Virtual_ipaddress {
192.168.1.254}
Virtual_server 192.168.1.254 80 {
Delay_loop 6
Lb_algo rr
Lb_kind DR
Nat_mask 255.255.255.0
Persistence_timeout 50
Protocol TCP
Real_server 192.168.1.11 80 {
Weight 1
TCP_CHECK {
Connect-port 80
Connect_timeout 3
Nb_get_retry 3
Delay_before_retry 3
}}
}
5. Install ipvsadm
Yum-y install ipvsadm
Ipvsadm-Lnc / Ln
2.3 Node Web12.3.1 modifies ip address
192.168.1.11
2.3.2 add lo:0
# cd / etc/sysconfig/network-scripts
# cp ifcfg-lo ifcfg-lo:0
# vim ifcfg-lo:0
DEVICE=lo:0
IPADDR=192.168.1.254
NETMASK=255.255.255.255
ONBOOT=yes
Restart the service service network restart
Add as appropriate
Vi / etc/rc.local / / add VIP local access route
/ sbin/route add-host 192.168.1.254 dev lo:0
# route add-host 192.168.1.254 dev lo:0
2.3.3 adjust the / proc parameter to disable the ARP response
Vim / etc/sysctl.conf
Net.ipv4.conf.all.arp_ignore = 1
Net.ipv4.conf.all.arp_announce = 2
Net.ipv4.conf.default.arp_ignore = 1
Net.ipv4.conf.default.arp_announce = 2
Net.ipv4.conf.lo.arp_ignore = 1
Net.ipv4.conf.lo.arp_announce = 2
Sysctl-p
2.3.4 restart the httpd service to create a test web page
Vi / var/www/html/index.html
192.168.1.11 color-test web page /
# service httpd start
# chkconfig httpd on
2.4 Node web22.4.1 modifies ip address
192.168.1.22
2.4.2 add lo:0
# cd / etc/sysconfig/network-scripts
# cp ifcfg-lo ifcfg-lo:0
# vim ifcfg-lo:0
DEVICE=lo:0
IPADDR=192.168.1.254
NETMASK=255.255.255.255
ONBOOT=yes
Restart the service service network restart
Add as appropriate
Vi / etc/rc.local / / add VIP local access route
/ sbin/route add-host 192.168.1.254 dev lo:0
# route add-host 192.168.1.254 dev lo:0
2.4.3 adjust the / proc parameter to disable the ARP response
Vim / etc/sysctl.conf
Net.ipv4.conf.all.arp_ignore = 1
Net.ipv4.conf.all.arp_announce = 2
Net.ipv4.conf.default.arp_ignore = 1
Net.ipv4.conf.default.arp_announce = 2
Net.ipv4.conf.lo.arp_ignore = 1
Net.ipv4.conf.lo.arp_announce = 2
Sysctl-p
2.4.4 restart the httpd service to create a test web page
Vi / var/www/html/index.html
192.168.1.22/
# service httpd start
# chkconfig httpd on
2.5 Test Machine 2.5.1 Test Master + lvs
Configure ip 192.168.1.110
Turn off the firewall to communicate with other hosts
Log in 192.168.1.254
Master ipvsadm-Ln
2.5.2 Test from + lvs
Down loses the primary keepalive
Landing
2.5.3 Test Node
Login success Node 1 down at Test Node 2
At this point, the study on "how to achieve Keepalive+lvs master-slave dr load balancing in LINUX" is over. I hope to be able to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.