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

What is the principle and implementation of DR?

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

Share

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

This article introduces the principle and implementation of DR to you, the content is very detailed, interested friends can refer to, hope to be helpful to you.

The principles of DR model are as follows:

When the user request arrives at Director Server, the requested Datagram will first go to the PREROUTING chain in kernel space. In this case, the source IP of the message is CIP, and the destination IP is VIP

PREROUTING check found that the destination IP of the packet is native, and the packet is sent to the INPUT chain

IPVS compares whether the service requested by the packet is a cluster service. If so, modify the source MAC address in the request message to the MAC address of DIP, modify the destination MAC address to the MAC address of RIP, and then send the packet to the POSTROUTING chain. At this time, the source IP and destination IP are not modified, only the MAC address of the source MAC address is DIP, and the destination MAC address is the MAC address of RIP.

Because DS and RS are in the same network, they are transmitted through layer 2. The POSTROUTING chain checks that the destination MAC address is the MAC address of RIP, and the packet will be sent to Real Server.

RS receives the request message when it discovers that the MAC address of the request message is its own MAC address. After the processing is completed, the response message is transmitted to the eth0 network card through the lo interface and then sent out. In this case, the source IP address is VIP and the destination IP is CIP

The response message is finally delivered to the client.

Implementation of DR Model

IP allocation

Dirdirector DIP:192.168.177.210 (eth0) VIP:192.168.177.220 (eth0:0)

Real server1 RIP1:192.168.177.121 (eth0) VIP:192.168.177.220 (lo:0)

Real server2 RIP2:192.168.177.122 (eth0) VIP:192.168.177.220 (lo:0)

1. Configuration on real server

Bind IP address on lo network card

Ifconfig lo:0 192.168.177.220 broadcast 192.168.177.220 netmask 255.255.255.255 up

Add a route (the VIP address is given by the lo Nic)

Route add-host 192.168.177.220 lo:0

Modify kernel parameters so that VIP addresses on real server do not respond to ARP messages sent by other hosts

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

Install the http service and start

Yum install httpd

Echo RS1 > / var/www/html/index.html

/ etc/init.d/httpd restart

2. Configuration on director

Bind VIP on eth0

Ifconfig eth0:0 192.168.177.220 up

Add a route (make the data of VIP address go out through eth0)

Route add-host 192.168.177.220 dev eth0:0

Enable routing forwarding function

Echo 1 > / proc/sys/net/ipv4/ip_forward

Create a service

Ipvsadm-A-t 192.168.177.220 80-s wrr

Add real server to the service

Ipvsadm-a-t 192.168.177.220 80-r 192.168.177.211 80-g-w 3

Ipvsadm-a-t 192.168.177.220 purl 80-r 192.168.177.212 purl 80-g-w 1

Configuration complete

Note: the kernel parameters arp_ignore and arp_announce are modified on real server to prevent VIP on lo0 from responding to ARP messages sent by other hosts and to avoid IP address conflicts.

TUN configuration is similar to DR model configuration, except that real server and director are no longer in the same network

On the principle and implementation of DR is how to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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