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

Lvs+nginx+tomcat_1 and tomcat_2+redis of lvs (lvs dr mode)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Premise: lvs+nginx+tomcat_1 and tomcat_2+redis environments have been installed, please refer to (slight changes, for example, tomcat_1 and tomcat_2 are installed on two machines, instead of multiple instances on a single machine, you can change them slightly) http://blog.csdn.net/zhang123456456/article/details/73437710

Environment description: in order to save resources, there are multiple services configured on the same virtual machine, due to different ports, does not affect the use.

Os: centos 6.7

Lvs: 10.219.24.23

Nginx: 10.219.24.26:80

Tomcat_1: 10.219.24.21:80

Tomcat_2: 10.219.24.23:80

Redis: 10.219.24.23:6379

After the installation and configuration of all the above environments, the lvs dr mode is finally configured. Only the last lvs dr configuration record is recorded here.

1.-- ditecter server (front-end server) bind vip

[root@mysql03 ~] # ifconfig eth0:1 10.219.24.66 Universe 8 up

[root@mysql03] # route add-host 10.219.24.66 dev eth0:1

[root@mysql03 ~] # ifconfig

Eth0 Link encap:Ethernet HWaddr 00:0C:29:79:F4:02

Inet addr:10.219.24.26 Bcast:10.255.255.255 Mask:255.0.0.0

Inet6 addr: fe80::20c:29ff:fe79:f402/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:11815 errors:0 dropped:0 overruns:0 frame:0

TX packets:15001 errors:0 dropped:0 overruns:0 carrier:0

Collisions:0 txqueuelen:1000

RX bytes:1170750 (1.1 MiB) TX bytes:3612189 (3.4 MiB)

Eth0:1 Link encap:Ethernet HWaddr 00:0C:29:79:F4:02

Inet addr:10.219.24.66 Bcast:10.255.255.255 Mask:255.0.0.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

2.-- real server modifies kernel parameters to hide real server's vip (all real server servers need to operate)

[root@mysql ~] # echo "1" > / proc/sys/net/ipv4/conf/lo/arp_ignore

[root@mysql ~] # echo "1" > / proc/sys/net/ipv4/conf/all/arp_ignore

[root@mysql ~] # echo "2" > / proc/sys/net/ipv4/conf/all/arp_announce

[root@mysql ~] # echo "2" > / proc/sys/net/ipv4/conf/lo/arp_announce

-- real server binds vip (all real server servers need to operate)

[root@mysql ~] # ifconfig lo:1 10.219.24.66 netmask 255.255.255.255 broadcast 10.255.255.255 up

[root@mysql] # route add-host 10.219.24.66 dev lo:1

3. Add a cluster service to the lvs server

Ipvsadm-A-t 10.219.24.66 80-s rr

-- add Real Server to the specified cluster service

Ipvsadm-a-t 10.219.24.66 VR 80-r 10.219.24.21 VR 80-g

Ipvsadm-a-t 10.219.24.66 purl 80-r 10.219.24.23 purl 80-g

Note:-r: specify RS, which can contain {IP [: port]}. Only LVS types that support port mapping (NAT) allow different ports to be used here than in the cluster service.

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