Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

General description of lvs virtual load balancer CVM

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The following gives you an overview of lvs virtual load balancer CVM, hoping to give you some help in practical application. Load balancer involves many things, not many theories, and there are many books on the Internet. Today, we will use the accumulated experience in the industry to do an answer.

1. General description of lvs virtual load balancer CVM

Mainly related to software packages: ipvsadm and keepalived (or heartbeat)

1.24.tar.gz (available on linux installation disk)

Host: linux red-had 6.4

Host related instructions:

Vip 10.4.127.160 externally exposed ip port

Master 10.4.121.212 controls load balancing

Backup 10.4.120.166 load balance backup

Rtsp1 10.4.120.165 realserver

Rtsp2 10.4.120.163 realserver

Note requirements: server time requires synchronization

Command:

Modify time synchronization configuration file: vi / etc/ntp.conf adds server 10.4.121.166 # # 10.4.121.166 as time server

Start the time synchronization service: service ntpd start

Ntpd-p configure to view the host pair table

Time synchronization problem: error 1.Server dropped: Strata too high

Reason: NTP server is not in sync with itself or its server.

Handling: NTP Server modification / etc/ntp.conf

Server 127.127.1.0

Fudge 127.127.1.0 stratum 8

Error 2.Server dropped: no data

Reason: check ntp server's firewall

Processing: service iptables stop

Note: ntpd can only fine-tune the time. If the time difference between the server is too large, you need to use ntpdate 10.4.121.166 to adjust it, and then start the service for real-time fine-tuning.

II. Environmental preparation on maser

1, install keepalived

# tar-zxvf keepalived-1.1.15.tar.gz

# cd keepalived-1.1.15

. / configure-sysconf=/etc-prefix=/usr/local/keepalived

# make & & make install

2. Set keepalived to start in service mode.

Set up as a service and boot:

Cp / usr/local/keepalived/sbin/keepalived / usr/sbin/

/ etc/rc.d/init.d/keepalived status

Chkconfig-add keepalived

Chkconfig keepalived on

# cp / usr/local/etc/rc.d/init.d/keepalived / etc/rc.d/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/

# service keepalived start | stop

3, configure keepalived

Vim / etc/keepalived/keepalived.conf

! Configuration File for keepalived

Global_defs {

Notification_email {

}

Notification_email_from

Smtp_server smtp.163.com

Smtp_connect_timeout 30

Router_id LVS_DEVEL

Lvs_id lvs01

}

Vrrp_instance VI_1 {

State MASTER

Interface eth0

Lvs_sync_daemon_interface eth0

Virtual_router_id 50 # # Master-slave consistency

Priority 100

Advert_int 1

Authentication {

Auth_type PASS

Auth_pass 1111

}

Virtual_ipaddress {

10.4.127.160 # # vip

}

}

Virtual_server 10.4.127.160 8042 {

Delay_loop 2

Lb_algo rr

Lb_kind DR

Persistence_timeout 50

Protocol TCP # for RTSP, the test fails under quicktime. Keepalived cannot fail to automatically eliminate the switching sub-example.

Real_server 10.4.120.165 8042 {

Weight 1

TCP_CHECK {

Connect_timeout 3

Nb_get_retry 3

Delay_before_retry 3

Connect_port 8042

}

}

Real_server 10.4.120.163 8042 {

Weight 1

TCP_CHECK {

Connect_timeout 3

Nb_get_retry 3

Delay_before_retry 3

Connect_port 8042

}

}

}

-after starting keepalived

[root@9data2 keepalived] # ipvsadm-Ln

IP Virtual Server version 1.2.1 (size=4096)

Prot LocalAddress:Port Scheduler Flags

-> RemoteAddress:Port Forward Weight ActiveConn InActConn

TCP 10.4.121.212:8042 rr persistent 600

-> 10.4.120.165pur8042 Route 10 5

-> 10.4.120.163 8042 Route 100

Add the following script to two rtsp servers 10.4.120.165Universe 10.4.120.163

# vim / etc/init.d/realserver.sh

#! / bin/bash

SNS_VIP=10.4.127.160

. / etc/rc.d/init.d/functions

Case "$1" in

Start)

Ifconfig lo:0 $SNS_VIP netmask 255.255.255.255 broadcast $SNS_VIP

/ sbin/route add-host $SNS_VIP dev lo:0

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

Sysctl-p > / dev/null 2 > & 1

Echo "RealServer Start OK"

Stop)

Ifconfig lo:0 down

Route del $SNS_VIP > / dev/null 2 > & 1

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

Echo "RealServer Stoped"

*)

Echo "Usage: $0 {start | stop}"

Exit 1

Esac

Exit 0

Empowerment:

# chmod 755 / etc/init.d/realserver.sh

# sh / etc/init.d/realserver.sh start

4. Backup attention

Only master is done here, and similar operations like backup only need to be modified slightly.

Question:

Keepalived_vrrp: bogus VRRP packet received on eth0!

Keepalived_vrrp: VRRP_Instance (VI_1) ignoring received

Resolve:

Modify the value of virtual_route_id in / etc/keepalived/keepalived.conf

such as

Virtual_router_id 60 master and slave should be changed. The default is 51. Restart keepalived.

Change 1.lvs_id to lvs02

Change 2.state to BUCKUP

3.priority is changed to 100, as long as it is smaller than MASTER.

4. The virtual_router_id of master and slave is the same.

After reading the above description of lvs virtual load balancer CVM, if there is anything else you need to know, you can find out what you are interested in in the industry information or find our professional and technical engineers for answers. Technical engineers have more than ten years of experience in the industry.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report