P. 1
Red Hat Enterprise Linux-5-Virtual Server Administration-En-US

Red Hat Enterprise Linux-5-Virtual Server Administration-En-US

|Views: 0|Likes:
Published by Asif Changezi

More info:

Published by: Asif Changezi on Oct 05, 2012
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less





Red Hat Enterprise Linux 5 Virtual Server Administration

Linux Virtual Server (LVS) for Red Hat Enterprise Linux

Virtual Server Administration

Red Hat Enterprise Linux 5 Virtual Server Administration Linux Virtual Server (LVS) for Red Hat Enterprise Linux Edition 5

Copyright © 2009 Red Hat, Inc. The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version. Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law. Red Hat, Red Hat Enterprise Linux, the Shadowman logo, JBoss, MetaMatrix, Fedora, the Infinity Logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries. Linux® is the registered trademark of Linus Torvalds in the United States and other countries. Java® is a registered trademark of Oracle and/or its affiliates. XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries. MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries. All other trademarks are the property of their respective owners. 1801 Varsity Drive Raleigh, NC 27606-2072 USA Phone: +1 919 754 3700 Phone: 888 733 4281 Fax: +1 919 754 3701

Building a Linux Virtual Server (LVS) system offers highly-available and scalable solution for production services using specialized routing and load-balancing techniques configured through the PIRANHA. This book discusses the configuration of high-performance systems and services with Red Hat Enterprise Linux and LVS for Red Hat Enterprise Linux 5.

Introduction v 1. Document Conventions ................................................................................................... vi 1.1. Typographic Conventions ..................................................................................... vi 1.2. Pull-quote Conventions ........................................................................................ vii 1.3. Notes and Warnings ........................................................................................... viii 2. Feedback ..................................................................................................................... viii 1. Linux Virtual Server Overview 1 1.1. A Basic LVS Configuration ............................................................................................ 1 1.1.1. Data Replication and Data Sharing Between Real Servers ................................... 3 1.2. A Three-Tier LVS Configuration ..................................................................................... 3 1.3. LVS Scheduling Overview ............................................................................................. 4 1.3.1. Scheduling Algorithms ....................................................................................... 5 1.3.2. Server Weight and Scheduling ........................................................................... 6 1.4. Routing Methods .......................................................................................................... 6 1.4.1. NAT Routing ..................................................................................................... 7 1.4.2. Direct Routing ................................................................................................... 7 1.5. Persistence and Firewall Marks ..................................................................................... 9 1.5.1. Persistence ....................................................................................................... 9 1.5.2. Firewall Marks ................................................................................................... 9 1.6. LVS — A Block Diagram ............................................................................................ 10 1.6.1. LVS Components ............................................................................................. 11 2. Initial LVS Configuration 2.1. Configuring Services on the LVS Routers .................................................................... 2.2. Setting a Password for the Piranha Configuration Tool .............................................. 2.3. Starting the Piranha Configuration Tool Service ......................................................... 2.3.1. Configuring the Piranha Configuration Tool Web Server Port ........................... 2.4. Limiting Access To the Piranha Configuration Tool .................................................... 2.5. Turning on Packet Forwarding .................................................................................... 2.6. Configuring Services on the Real Servers .................................................................... 3. Setting Up LVS 3.1. The NAT LVS Network ................................................................................................ 3.1.1. Configuring Network Interfaces for LVS with NAT ............................................... 3.1.2. Routing on the Real Servers ............................................................................ 3.1.3. Enabling NAT Routing on the LVS Routers ........................................................ 3.2. LVS via Direct Routing ............................................................................................... 3.2.1. Direct Routing and arptables_jf .................................................................. 3.2.2. Direct Routing and iptables .......................................................................... 3.3. Putting the Configuration Together ............................................................................... 3.3.1. General LVS Networking Tips ........................................................................... 3.4. Multi-port Services and LVS ........................................................................................ 3.4.1. Assigning Firewall Marks .................................................................................. 3.5. Configuring FTP ......................................................................................................... 3.5.1. How FTP Works .............................................................................................. 3.5.2. How This Affects LVS Routing .......................................................................... 3.5.3. Creating Network Packet Filter Rules ................................................................ 3.6. Saving Network Packet Filter Settings ......................................................................... 4. Configuring the LVS Routers with Piranha Configuration Tool 4.1. Necessary Software ................................................................................................... 4.2. Logging Into the Piranha Configuration Tool .............................................................. 4.3. CONTROL/MONITORING ........................................................................................... 4.4. GLOBAL SETTINGS .................................................................................................. 4.5. REDUNDANCY .......................................................................................................... 13 13 14 14 15 15 16 16 17 17 17 18 19 19 20 21 22 22 23 23 24 24 25 25 27 29 29 29 30 31 33 iii

....................... 4. 4.... The VIRTUAL SERVER Subsection ................................. EDIT MONITORING SCRIPTS Subsection ................6........2.................................8....... 4......6...................................... Using LVS with Red Hat Cluster B.................... Synchronizing sysctl .........6.............. Revision History Index 35 36 38 41 43 43 44 44 44 47 49 51 iv ......1..............................................................................1.............. 4......Virtual Server Administration 4.. REAL SERVER Subsection ................................ Synchronizing Configuration Files ....6.......... VIRTUAL SERVERS ..........3....... Starting LVS .......2........... 4....................cf .... 4... 4.........................7....... A................................................. Synchronizing Network Packet Filtering Rules ................3..........7............. Synchronizing lvs......................................................................................................................................................................... 4.........7....7........

and managing Red Hat Cluster software. This document is organized as follows: • Chapter 1. configuring. Using LVS with Red Hat Cluster For more information about Red Hat Enterprise Linux 5. configuration and administration of Red Hat Enterprise Linux 5. The audience of this document should have advanced working knowledge of Red Hat Enterprise Linux and understand the concepts of clusters. configuring. configuring. Setting Up LVS • Chapter 4. refer to the following resources: • Red Hat Cluster Suite Overview — Provides a high level overview of the Red Hat Cluster Suite. LVS provides load balancing through specialized routing techniques that dispatch traffic to a pool of servers. and server computing. • Global File System 2: Configuration and Administration — Provides information about installing. • Red Hat Enterprise Linux Deployment Guide — Provides information regarding the deployment. and maintaining Red Hat GFS (Red Hat Global File System). This document does not include information about installing. • Logical Volume Manager Administration — Provides a description of the Logical Volume Manager (LVM). configuring. Information about that is in a separate document. v . Initial LVS Configuration • Chapter 3. refer to the following resources: • Red Hat Enterprise Linux Installation Guide — Provides information regarding installation of Red Hat Enterprise Linux 5. configuring and managing Red Hat Cluster components. For more information about Red Hat Cluster Suite for Red Hat Enterprise Linux 5.Introduction This document provides information about installing. • Using GNBD with Global File System — Provides an overview on using Global Network Block Device (GNBD) with Red Hat GFS. • Configuring and Managing a Red Hat Cluster — Provides information about installing. • Using Device-Mapper Multipath — Provides information about using the Device-Mapper Multipath feature of Red Hat Enterprise Linux 5. and maintaining Red Hat GFS2 (Red Hat Global File System 2). and managing Red Hat Virtual Linux Server (LVS) components. storage. • Global File System: Configuration and Administration — Provides information about installing. • Red Hat Cluster Suite Release Notes — Provides information about the current release of Red Hat Cluster Suite. Linux Virtual Server Overview • Chapter 2. including information on running LVM in a clustered environment. Configuring the LVS Routers with Piranha Configuration Tool • Appendix A.

org/liberation-fonts/ vi . functions. Typographic Conventions Four typographic conventions are used to call attention to specific words and phrases. file names and paths. class names. 1 1. The second highlights two key combinations (each a set of three keycaps with each set pressed simultaneously). including application names. variable names and returned values mentioned within a paragraph will be presented as above. The first paragraph highlights the particular keycap to press.1. 1. Press Ctrl+Alt+F2 to switch to the first virtual terminal. check-box and radio button labels. The Liberation Fonts set is also used in HTML editions if the set is installed on your system. Note: Red Hat Enterprise Linux 5 and later includes the Liberation Fonts set by default. file for files. dialog box text. In PDF and paper editions. including shell commands. For example: File-related classes include filesystem for file systems. Proportional Bold This denotes words or phrases encountered on a system. The above includes a file name. Also used to highlight keycaps and key combinations. in mono-spaced bold. In the Buttons tab. are as follows. methods.redhat. a shell command and a keycap. and the circumstances they apply to.Introduction Red Hat Cluster Suite documentation and other Red Hat documents are available in HTML.com/docs/. this manual uses typefaces drawn from the Liberation Fonts set. and dir for directories. If source code is discussed. menu titles and sub-menu titles. Each class has its own associated set of permissions. Key combinations can be distinguished from keycaps by the hyphen connecting each part of a key combination. alternative but equivalent typefaces are displayed. Mono-spaced Bold Used to highlight system input. For example: Choose System → Preferences → Mouse from the main menu bar to launch Mouse Preferences. For example: Press Enter to execute the command. enter the cat my_next_bestselling_novel command at the shell prompt and press Enter to execute the command. For example: To see the contents of the file my_next_bestselling_novel in your current working directory. click the Left-handed mouse check box and click 1 https://fedorahosted. labeled buttons. PDF. If not. all presented in mono-spaced bold and all distinguishable thanks to context. Press Ctrl+Alt+F1 to return to your X-Windows session. and RPM versions on the Red Hat Enterprise Linux Documentation CD and online at http:// www. Document Conventions This manual uses several conventions to highlight certain words and phrases and draw attention to specific pieces of information. These conventions.

jca. For example: Publican is a DocBook publishing system. application-specific menu names. the addition of italics indicates replaceable or variable text. Aside from standard usage for presenting the title of a work.com and your username on that machine is john. If the remote machine is example.name. choose Search → Find… from the Character Map menu bar. italics denotes the first use of a new and important term. type the name of the character in the Search field and click Next. Pull-quote Conventions Terminal output and source code listings are set off visually from the surrounding text. import javax. Doubleclick this highlighted character to place it in the Text to copy field and then click the Copy button. Output sent to a terminal is set in mono-spaced roman and presented thus: books books_tests Desktop Desktop1 documentation downloads drafts images mss notes photos scripts stuff svgs svn Source-code listings are also set in mono-spaced roman but add syntax highlighting as follows: package org.Pull-quote Conventions Close to switch the primary mouse button from the left to the right (making the mouse suitable for use in the left hand).ex1. type ssh john@example.book. For example. either for text you enter when issuing a command or for text displayed by the system. system-wide menu names and items. to remount the /home file system. type ssh username@domain.2. and buttons and text found within a GUI interface. use the rpm -q package command. To insert a special character into a gedit file. vii . Mono-spaced Bold Italic or Proportional Bold Italic Whether mono-spaced bold or proportional bold. For example: To connect to a remote machine using ssh.naming. version and release. Now switch back to your document and choose Edit → Paste from the gedit menu bar.jboss.com. Note the words in bold italics above — username. To see the version of a currently installed package. 1. The above text includes application names. The mount -o remount file-system command remounts the named file system.name at a shell prompt. Italics denotes text you do not input literally or displayed text that changes depending on circumstance. Next.InitialContext. Each word is a placeholder. domain. all presented in proportional bold and all distinguishable by context. file-system. package. choose Applications → Accessories → Character Map from the main menu bar. It will return a result as follows: package-version-release. The character you sought will be highlighted in the Character Table. the command is mount -o remount /home.

3. Feedback If you spot a typo. If you have a suggestion for improving the documentation. Ignoring warnings will most likely cause data loss. Important Important boxes detail things that are easily missed: configuration changes that only apply to the current session. If you have found an error.println("Created Echo"). EchoHome home = (EchoHome) ref. 2. or services that need restarting before an update will apply.com/bugzilla/) against the component Documentation-cluster.lookup("EchoBean"). Notes and Warnings Finally. we know exactly which version of the guide you have. Please submit a report in Bugzilla (http://bugzilla. but you might miss out on a trick that makes your life easier.echo('Hello') = " + echo.println("Echo. System. } } 1. or if you have thought of a way to make this manual better. please include the section number and some of the surrounding text so we can find it easily. Note Notes are tips. Be sure to mention the manual's identifier: Virtual_Server_Administration(EN)-5 (2010-02-08T16:55) By mentioning this manual's identifier. Ignoring a note should have no negative consequences.echo("Hello")).create(). we use three visual styles to draw attention to information that might otherwise be overlooked. System. try to be as specific as possible. Echo echo = home. we would love to hear from you.redhat. Warning Warnings should not be ignored.out. shortcuts or alternative approaches to the task at hand.out. Object ref = iniCtx.Introduction public class ExClient { public static void main(String args[]) throws Exception { InitialContext iniCtx = new InitialContext(). Ignoring a box labeled 'Important' will not cause data loss but may cause irritation and frustration. viii .

2. The backup LVS router monitors the active LVS router and takes over from it in case the active LVS router fails. For this example the active router is using Network Address Translation or NAT to direct traffic from the Internet to a variable number of real servers on the second layer. • To check the integrity of the services on each real server.Chapter 1. the real servers in this example are connected to a dedicated private network segment and pass all public traffic back and forth through the active LVS router. LVS runs on a pair of equally configured computers: one that is an active LVS router and one that is a backup LVS router. A Basic LVS Configuration Figure 1. Linux Virtual Server Overview Linux Virtual Server (LVS) is a set of integrated software components for balancing the IP load across a set of real servers. enabling them to regulate traffic between the two networks. “LVS Scheduling Overview” • Section 1. “A Basic LVS Configuration” • Section 1. Therefore. 1 . The active LVS router serves two roles: • To balance the load across the real servers. “Routing Methods” • Section 1. To the outside world.1. and consists of the following sections: • Section 1. On the first layer are two LVS routers — one active and one backup.1. one interface on the Internet and one on the private network.4. the servers appears as one entity.5. “A Three-Tier LVS Configuration” • Section 1. Each of the LVS routers has two network interfaces.1. “Persistence and Firewall Marks” • Section 1. This chapter provides an overview of LVS components and functions. which in turn provide the necessary services.6. “LVS — A Block Diagram” 1. “A Basic LVS Configuration” shows a simple LVS configuration consisting of two layers.3.

the private interface. Periodically. the LVS routers exchange heartbeat messages through the primary external public interface and. the backup router takes over the VIP addresses serviced by the failed router using a technique known as ARP spoofing — where the backup LVS router announces itself as the destination for IP packets addressed 2 . the administrator can also call external executables. in a failover situation.3. “LVS Scheduling Overview”. each virtual server can be associated with a separate device per service. The role of the active router is to redirect service requests from virtual IP addresses to the real servers. thus maintaining a presence at that IP address (also known as floating IP addresses). Should the backup node fail to receive a heartbeat message within an expected interval. the active router stops sending jobs to that server until it returns to normal operation. VIP addresses may be aliased to the same device which connects the LVS router to the Internet. This is a publicly-routable address the administrator of the site associates with a fully-qualified domain name. it initiates a failover and assumes the role of the active router. A VIP address migrates from one LVS router to the other during a failover.com. HTTP traffic can be handled on eth0:1. The redirection is based on one of eight supported loadbalancing algorithms described further in Section 1. The backup router performs the role of a standby system. A Basic LVS Configuration Service requests arriving at the LVS routers are addressed to a virtual IP address. if eth0 is connected to the Internet. such as www. To aid in detecting the health of services that require dynamic data. such as HTTPS or SSL. Alternatively. and is assigned to one or more virtual servers. Refer to Section 4. than multiple virtual servers can be aliased to eth0:1. For example. The active router also dynamically monitors the overall health of the specific services on the real servers through simple send/expect scripts. Only one LVS router is active at a time.6. If a service on a real server malfunctions. or VIP. During failover. “VIRTUAL SERVERS” for more information on configuring a virtual server using the Piranha Configuration Tool. For instance.Chapter 1. and FTP traffic can be handled on eth0:2. A virtual server is a service configured to listen on a specific virtual IP.1.example. Linux Virtual Server Overview Figure 1.

adding a third layer is preferable.Data Replication and Data Sharing Between Real Servers to the failed node. When the failed node returns to active service. the administrator has two basic options: • Synchronize the data across the real server pool • Add a third layer to the topology for shared data access The first option is preferred for servers that do not allow large numbers of users to upload or change data on the real servers.1. A Three-Tier LVS Configuration Figure 1. However. For instance. For a configuration with a high load. “A Basic LVS Configuration” is best for serving data which does not change very frequently — such as static webpages — because the individual real servers do not automatically sync data between each node. Each of the real servers then accesses a shared data source over the network.1.1. 3 .1. the backup node assumes its hotbackup role again. The simple.2. the page is posted to all of the servers simultaneously. 1. “A Three-Tier LVS Configuration” shows a typical three-tier LVS topology. the system administrator can use programs such as rsync to replicate changed data across all nodes at a set interval. In this example. If the configuration allows large numbers of users to modify data. such as an e-commerce website. this type of data synchronization does not optimally function if the configuration is overloaded with users constantly uploading files or issuing database transactions. two-layered configuration used in Figure 1. 1. a three-tier topology is the ideal solution.1. Also.1. Configuring Real Servers to Synchronize Data There are many ways an administrator can choose to synchronize data across the pool of real servers. 1. Data Replication and Data Sharing Between Real Servers Since there is no built-in component in LVS to share the same data between the real servers. the active LVS router routes the requests from the Internet to the pool of real servers.2. shell scripts can be employed so that if a Web engineer updates a page.

IP-level load balancing on the real server pool. such as Round-Robin DNS where the hierarchical nature of DNS and the caching by client machines can lead to load imbalances. but failing to use a highly available solution would introduce a critical single point of failure. 4 .Chapter 1. LVS load balancing is superior to less flexible methods. This flexibility is due to the variety of scheduling algorithms an administrator can choose from when configuring LVS. 1. LVS Scheduling Overview One of the advantages of using LVS is its ability to perform flexible. Additionally. Linux Virtual Server Overview Figure 1. The third tier in the above example does not have to use Red Hat Cluster Manager. using an active-active configuration with Red Hat Cluster Manager. where accessible data is stored on a central. A Three-Tier LVS Configuration This configuration is ideal for busy FTP servers. the low-level filtering employed by the LVS router has advantages over application-level request forwarding because balancing loads at the network packet level causes minimal computational overhead and allows for greater scalability. This topology is also recommended for websites that access a central. administrators can configure one high-availability cluster to serve both of these roles simultaneously.3. highly available server and accessed by each real server via an exported NFS directory or Samba share. highly available database for transactions.2. Additionally.

3. Refer to Section 1. If a group of servers have different capabilities.6. LVS round-robin scheduling also does not suffer the imbalances caused by cached DNS queries. Round-Robin Scheduling Distributes each request sequentially around the pool of real servers. The IPVS table is constantly updated by a utility called ipvsadm — adding and removing cluster members depending on their availability. making it a better choice if there is a high degree of variation in the request load. The addition of weighting makes this algorithm ideal when the real server pool contains hardware of varying capacity.Scheduling Algorithms Using scheduling. Weighted round-robin scheduling is a preferred choice if there are significant differences in the capacity of real servers in the pool. the more heavily weighted server may answer more than its share of requests. weighted least-connection scheduling is a better choice. least-connection is a type of dynamic scheduling algorithm. However. Using this algorithm. The scheduling mechanism for LVS is provided by a collection of kernel patches called IP Virtual Server or IPVS modules. “Server Weight and Scheduling” for more on weighting real servers. which is designed to work well with multiple servers on a single IP address. it is possible to create a group of real servers using a variety of hardware and software combinations and the active router can evenly load each real server. if the request load varies dramatically. Because it keeps track of live connections to the real servers through the IPVS table. To track and route packets to the real servers efficiently. 1. “Server Weight and Scheduling” for more on weighting real servers. an administrator-assigned weight factor when routing service requests. Using this form of scheduling. This scheduling model resembles round-robin DNS but is more granular due to the fact that it is network-connection based and not host-based.3. Refer to Section 1. Weighted Least-Connections (default) Distributes more requests to servers with fewer active connections relative to their capacities. IPVS builds an IPVS table in the kernel. Capacity is indicated by a user-assigned weight. Using assigned weights gives arbitrary priorities to individual machines. Weighted Round-Robin Scheduling Distributes each request sequentially around the pool of real servers but gives more jobs to servers with greater capacity.1. optionally. which is then adjusted upward or downward by dynamic load information.2.2. These modules enable layer 4 (L4) transport layer switching. This table is used by the active LVS router to redirect requests from a virtual server address to and returning from real servers in the pool. “The VIRTUAL SERVER Subsection”. It is best suited for a real server pool where each member node has roughly the same capacity. all the real servers are treated as equals without regard to capacity or load. Scheduling Algorithms The structure that the IPVS table takes depends on the scheduling algorithm that the administrator chooses for any given virtual server. For instructions on how to assign scheduling algorithms refer to Section 4.3. the active router can take into account the real servers' activity and. which is then adjusted upward or downward by dynamic load information. Least-Connection Distributes more requests to real servers with fewer active connections. 5 .1. Capacity is indicated by a user-assigned weight factor. Red Hat Enterprise Linux provides the following scheduling algorithms listed below. To allow for maximum flexibility in the types of services you can cluster and how these services are scheduled.

Chapter 1. For example. 1. Locality-Based Least-Connection Scheduling with Replication Scheduling Distributes more requests to servers with fewer active connections relative to their destination IPs. Requests are then routed to the server in this subset with the lowest number of connections. Linux Virtual Server Overview Locality-Based Least-Connection Scheduling Distributes more requests to servers with fewer active connections relative to their destination IPs. Weights work as a ratio relative to one another. For instance. servers A and B evenly distributes the abandoned load. This algorithm is also designed for use in a proxy-cache server cluster. then the server with a weight of 5 gets 5 connections for every 1 connection the other server gets. if one real server has a weight of 1 and the other server has a weight of 5. It routes the packets for an IP address to the server for that address unless that server is above its capacity and has a server in its half load. Routing Methods Red Hat Enterprise Linux uses Network Address Translation or NAT routing for LVS. Destination Hash Scheduling Distributes requests to the pool of real servers by looking up the destination IP in a static hash table.3. It differs from LocalityBased Least-Connection Scheduling by mapping the target IP address to a subset of real server nodes. This algorithm is designed for LVS routers with multiple firewalls. the LVS router sees it has zero connections and floods the server with all incoming requests until it is on par with servers A and B. This algorithm is designed for use in a proxy-cache server cluster. To prevent this phenomenon. This weight is an integer value which is factored into any weight-aware scheduling algorithms (such as weighted leastconnections) and helps the LVS router more evenly load hardware with different capabilities. 6 . If all the nodes for the destination IP are above capacity. 1.4. Source Hash Scheduling Distributes requests to the pool of real servers by looking up the source IP in a static hash table.2. in which case it assigns the IP address to the least loaded real server. If server C goes down for any reason. once server C comes back online. administrators can make the virtual server a quiesce server — anytime a new real server node comes online. suppose there are three servers in the real server pool. it can cause temporary imbalances when a real server is introduced to the real server pool and the virtual server is scheduled using weighted least-connections. which allows the administrator tremendous flexibility when utilizing available hardware and integrating the LVS into an existing network. server C. However. The most loaded node is then dropped from the real server subset to prevent over-replication. Servers A and B are weighted at 1 and the third. it replicates a new server for that destination IP address by adding the real server with the least connections from the overall pool of real servers to the subset of real servers for that destination IP. is weighted at 2. The default value for a real server weight is 1. Server Weight and Scheduling The administrator of LVS can assign a weight to each node in the real server pool. Although adding weight to varying hardware configurations in a real server pool can help load-balance the cluster more efficiently. This algorithm is designed for use in a proxy-cache server cluster. the least-connections table is reset to zero and the LVS router routes requests as if all the real servers were newly added to the cluster.

1. All of the real servers located on the private network use the floating IP for the NAT router as their default route to communicate with the active LVS router so that their abilities to respond to requests from the Internet is not impaired. having more than two NICs is not a requirement. This process is called IP masquerading because the actual IP addresses of the real servers is hidden from the requesting clients. NAT Routing Figure 1. The NIC for the Internet has a real IP address on eth0 and has a floating IP address aliased to eth0:1. Using this topology. “LVS Implemented with NAT Routing”. The main disadvantage is that the LVS router may become a bottleneck in large cluster deployments because it must process outgoing as well as incoming requests.NAT Routing 1. the LVS router's public LVS floating IP address and private NAT floating IP address are aliased to two physical NICs.3. the virtual interface facing the Internet and the private facing virtual interface are taken-over by the backup LVS router simultaneously. In this example. The real server then processes the request and returns the packets to the LVS router which uses network address translation to replace the address of the real server in the packets with the LVS routers public VIP address. the real servers may be any kind of machine running various operating systems.1.2. Direct Routing Building an LVS setup that uses direct routing provides increased performance benefits compared to other LVS networking topologies. The NIC for the private network interface has a real IP address on eth1 and has a floating IP address aliased to eth1:1. LVS Implemented with NAT Routing In the example. Figure 1. Using this NAT routing. illustrates LVS utilizing NAT routing to move requests between the Internet and a private network.3. the active LVS router receives the request and routes it to the appropriate server. While it is possible to associate each floating IP address to its own physical device on the LVS router nodes. In the event of failover. there are two NICs in the active LVS router. Direct routing allows the real servers to process and route packets 7 .4.4.

which is cleared periodically (usually every 15 minutes) and refilled with IP/MAC associations. 1.4. Network routers typically send requests to their destination by relating IP addresses to a machine's MAC address with ARP. bypassing the LVS routers. a client on the Internet sends a request to an IP address. Direct Routing and the ARP Limitation While there are many advantages to using direct routing in LVS. The real server processes the request and sends the response directly to the client. there are limitations as well.Chapter 1. In typical situations. which can become a bottleneck under heavy network load. ARP requests are broadcast to all connected machines on a network. This method of routing allows for scalability in that real servers can be added without the added burden on the LVS router to route outgoing packets from the real server to the client. and the machine with the correct IP/MAC address combination receives the packet. Linux Virtual Server Overview directly to a requesting user rather than passing all outgoing packets through the LVS router. the virtual IP address 8 . LVS Implemented with Direct Routing In the typical direct routing LVS setup. Figure 1.4.1. the LVS router receives incoming server requests through the virtual IP (VIP) and uses a scheduling algorithm to route the request to the real servers. Direct routing reduces the possibility of network performance issues by relegating the job of the LVS router to processing incoming packets only. The most common issue with LVS via direct routing is with Address Resolution Protocol (ARP).2. The issue with ARP requests in a direct routing LVS setup is that because a client request to an IP address must be associated with a MAC address for the request to be handled. The IP/MAC associations are stored in an ARP cache.

Persistence and Firewall Marks of the LVS system must also be associated to a MAC as well. However, since both the LVS router and the real servers all have the same VIP, the ARP request will be broadcast ed to all the machines associated with the VIP. This can cause several problems, such as the VIP being associated directly to one of the real servers and processing requests directly, bypassing the LVS router completely and defeating the purpose of the LVS setup. To solve this issue, ensure that the incoming requests are always sent to the LVS router rather than one of the real servers. This can be done by using either the arptables_jf or the iptables packet filtering tool for the following reasons: • The arptables_jf prevents ARP from associating VIPs with real servers. • The iptables method completely sidesteps the ARP problem by not configuring VIPs on real servers in the first place. For more information on using arptables or iptables in a direct routing LVS environment, refer to Section 3.2.1, “Direct Routing and arptables_jf” or Section 3.2.2, “Direct Routing and iptables”.

1.5. Persistence and Firewall Marks
In certain situations, it may be desirable for a client to reconnect repeatedly to the same real server, rather than have an LVS load balancing algorithm send that request to the best available server. Examples of such situations include multi-screen web forms, cookies, SSL, and FTP connections. In these cases, a client may not work properly unless the transactions are being handled by the same server to retain context. LVS provides two different features to handle this: persistence and firewall marks.

1.5.1. Persistence
When enabled, persistence acts like a timer. When a client connects to a service, LVS remembers the last connection for a specified period of time. If that same client IP address connects again within that period, it is sent to the same server it connected to previously — bypassing the load-balancing mechanisms. When a connection occurs outside the time window, it is handled according to the scheduling rules in place. Persistence also allows the administrator to specify a subnet mask to apply to the client IP address test as a tool for controlling what addresses have a higher level of persistence, thereby grouping connections to that subnet. Grouping connections destined for different ports can be important for protocols which use more than one port to communicate, such as FTP. However, persistence is not the most efficient way to deal with the problem of grouping together connections destined for different ports. For these situations, it is best to use firewall marks.

1.5.2. Firewall Marks
Firewall marks are an easy and efficient way to a group ports used for a protocol or group of related protocols. For instance, if LVS is deployed to run an e-commerce site, firewall marks can be used to bundle HTTP connections on port 80 and secure, HTTPS connections on port 443. By assigning the same firewall mark to the virtual server for each protocol, state information for the transaction can be preserved because the LVS router forwards all requests to the same real server after a connection is opened. Because of its efficiency and ease-of-use, administrators of LVS should use firewall marks instead of persistence whenever possible for grouping connections. However, administrators should still 9

Chapter 1. Linux Virtual Server Overview add persistence to the virtual servers in conjunction with firewall marks to ensure the clients are reconnected to the same server for an adequate period of time.

1.6. LVS — A Block Diagram
LVS routers use a collection of programs to monitor cluster members and cluster services. Figure 1.5, “LVS Components” illustrates how these various programs on both the active and backup LVS routers work together to manage the cluster.

Figure 1.5. LVS Components The pulse daemon runs on both the active and passive LVS routers. On the backup router, pulse sends a heartbeat to the public interface of the active router to make sure the active router is still properly functioning. On the active router, pulse starts the lvs daemon and responds to heartbeat queries from the backup LVS router. Once started, the lvs daemon calls the ipvsadm utility to configure and maintain the IPVS routing table in the kernel and starts a nanny process for each configured virtual server on each real server. Each nanny process checks the state of one configured service on one real server, and tells the lvs daemon if the service on that real server is malfunctioning. If a malfunction is detected, the lvs daemon instructs ipvsadm to remove that real server from the IPVS routing table. If the backup router does not receive a response from the active router, it initiates failover by calling send_arp to reassign all virtual IP addresses to the NIC hardware addresses (MAC address) of the backup node, sends a command to the active router via both the public and private network interfaces to shut down the lvs daemon on the active router, and starts the lvs daemon on the backup node to accept requests for the configured virtual servers. 10

LVS Components

1.6.1. LVS Components
Section, “pulse” shows a detailed list of each software component in an LVS router. pulse
This is the controlling process which starts all other daemons related to LVS routers. At boot time, the daemon is started by the /etc/rc.d/init.d/pulse script. It then reads the configuration file / etc/sysconfig/ha/lvs.cf. On the active router, pulse starts the LVS daemon. On the backup router, pulse determines the health of the active router by executing a simple heartbeat at a userconfigurable interval. If the active router fails to respond after a user-configurable interval, it initiates failover. During failover, pulse on the backup router instructs the pulse daemon on the active router to shut down all LVS services, starts the send_arp program to reassign the floating IP addresses to the backup router's MAC address, and starts the lvs daemon. lvs
The lvs daemon runs on the active LVS router once called by pulse. It reads the configuration file / etc/sysconfig/ha/lvs.cf, calls the ipvsadm utility to build and maintain the IPVS routing table, and assigns a nanny process for each configured LVS service. If nanny reports a real server is down, lvs instructs the ipvsadm utility to remove the real server from the IPVS routing table. ipvsadm
This service updates the IPVS routing table in the kernel. The lvs daemon sets up and administers LVS by calling ipvsadm to add, change, or delete entries in the IPVS routing table. nanny
The nanny monitoring daemon runs on the active LVS router. Through this daemon, the active router determines the health of each real server and, optionally, monitors its workload. A separate process runs for each service defined on each real server. /etc/sysconfig/ha/lvs.cf
This is the LVS configuration file. Directly or indirectly, all daemons get their configuration information from this file. Piranha Configuration Tool
This is the Web-based tool for monitoring, configuring, and administering LVS. This is the default tool to maintain the /etc/sysconfig/ha/lvs.cf LVS configuration file. send_arp
This program sends out ARP broadcasts when the floating IP address changes from one node to another during failover. Chapter 2, Initial LVS Configuration reviews important post-installation configuration steps you should take before configuring Red Hat Enterprise Linux to be an LVS router.


12 .

issue the following command: /sbin/chkconfig --list 13 . For both LVS routers.1. Configuring Services on the LVS Routers The Red Hat Enterprise Linux installation program installs all of the components needed to set up LVS. 2. For example: $ su . you must also enable the iptables service. open a shell prompt and use the su . To get a list of services on the system as well as what runlevel they are set to activate on. you must take some basic steps to set up both the LVS routers and the real servers. Note To attain root access. replace daemon with the name of the service you are activating.command followed by the root password. There are three primary tools available for setting services to activate at boot time under Red Hat Enterprise Linux: the command line program chkconfig. All of these tools require root access. and the graphical Services Configuration Tool. Note The LVS router node that becomes the active node once LVS is started is also referred to as the primary node.Chapter 2. but the appropriate services must be activated before configuring LVS.root password On the LVS routers. It is best to set these services to activate in both runlevel 3 and runlevel 5. To accomplish this using chkconfig. This chapter covers these initial steps in detail. there are three services which need to be set to activate at boot time: • The piranha-gui service (primary node only) • The pulse service • The sshd service If you are clustering multi-port services or using firewall marks. the ncurses-based program ntsysv. set the appropriate services to start at boot time. Initial LVS Configuration After installing Red Hat Enterprise Linux. use the Piranha Configuration Tool on the primary node. When configuring LVS. type the following command for each service: /sbin/chkconfig --level 35 daemon on In the above command.

start or restart the piranhagui service located in /etc/rc. the piranhagui version of httpd runs as the piranha user in a separate process.3. To do this. login as root and issue the following command: /usr/sbin/piranha-passwd After entering this command. The Apache HTTP Server must be installed on the system. commonly used acronyms. See Section 2. it should not contain proper nouns. 2. “Starting the Piranha Configuration Tool Service” for an example of how to use the /sbin/service command. The fact that piranha-gui leverages the httpd service means that: 1.2. or words in a dictionary from any language. 2. Warning For a password to be more secure. you must restrict access to it by creating a password. the administrator is prompted to provide the new password. Do not leave the password unencrypted anywhere on the system. To do this. Stopping or restarting the Apache HTTP Server via the service command stops the piranhagui service. Starting the Piranha Configuration Tool Service After you have set the password for the Piranha Configuration Tool. For security reasons.d/init.3. For more information on runlevels and configuring services with ntsysv and the Services Configuration Tool.d/piranha-gui. 2. Setting a Password for the Piranha Configuration Tool Before using the Piranha Configuration Tool for the first time on the primary LVS router. To do this use the /sbin/service command. create the administrative password when prompted.Chapter 2. 14 . refer to the chapter titled "Controlling Access to Services" in the Red Hat Enterprise Linux System Administration Guide. type the following command as root: /sbin/service piranha-gui start or /sbin/service piranha-gui restart Issuing this command starts a private session of the Apache HTTP Server by calling the symbolic link /usr/sbin/piranha_gui -> /usr/sbin/httpd. If the password is changed during an active Piranha Configuration Tool session. Initial LVS Configuration Warning Turning any of the above services on using chkconfig does not actually start the daemon.

Configuring the Piranha Configuration Tool Web Server Port The Piranha Configuration Tool runs on port 3636 by default. 2.0.htaccess file to allow access from only the loopback device (127. When your browser connects to the Piranha Configuration Tool. Enter piranha in the Username field and the password set with piranhapasswd in the Password field. The next section reviews ways to accomplish this task.4. To change this port number.htaccess file each time it accesses the directory. See Section 4.0.1). open the location http://localhost:3636. For more information on the loopback device. However. Here is what the default access looks like: Order deny. Now that the Piranha Configuration Tool is running.htaccess. because all of the data passed to the Piranha Configuration Tool is in plain text. To use the Piranha Configuration Tool you need at minimum a text-only Web browser. you must start the piranha-gui service by issuing the following command: /sbin/service piranha-gui start The piranha-gui service is all that is necessary to begin configuring LVS.1. “Starting LVS” for information on starting the pulse service.Configuring the Piranha Configuration Tool Web Server Port Warning If the command /sbin/service httpd stop or /sbin/service httpd restart is issued on an LVS router.allow Allow from all To limit access of the Piranha Configuration Tool to only the localhost change the . you may wish to consider limiting who has access to the tool over the network. After altering the file you do not have to restart the piranha-gui service because the server checks the . You can reach the Piranha Configuration Tool from anywhere via Web browser by replacing localhost with the hostname or IP address of the primary LVS router. if you are configuring LVS remotely. see the chapter titled Network Scripts in the Red Hat Enterprise Linux Reference Guide. 15 . you must login to access the configuration services. The easiest way to restrict access is to use the Apache HTTP Server's built in access control mechanisms by editing /etc/sysconfig/ha/web/secure/. it is recommended that you restrict access only to trusted networks or to the local machine. the access controls for this directory allow anyone to view the contents of the directory. However. the sshd service is also required. You do not need to start the pulse service until configuration using the Piranha Configuration Tool is complete.8. change the line Listen 3636 in Section 2 of the piranha-gui Web server configuration file /etc/ sysconfig/ha/conf/httpd. 2. Limiting Access To the Piranha Configuration Tool The Piranha Configuration Tool prompts for a valid username and password combination.3.conf. By default. If you start a Web browser on the primary LVS router.

1.Chapter 2. To check if IP forwarding is turned on.168.6. only Web browsers from the machine with the IP address of 192. Turning on Packet Forwarding In order for the LVS router to forward network packets properly to the real servers. Log in as root and change the line which reads net. If it returns a 0.conf to the following: net. 2. It may also be useful to access the real servers remotely.ip_forward If the above command returns a 1. issue the following command as root: /sbin/sysctl net.1.htaccess file limits access to the configuration pages in the /etc/sysconfig/ha/web/secure/ directory but not to the login and the help pages in /etc/sysconfig/ha/web/.htaccess.0.ipv4. These daemons can include httpd for Web services or xinetd for FTP or Telnet services.ipv4.ipv4.0. set the appropriate server daemons to activate at boot time. To limit access to this directory. 16 .ip_forward = 1 The changes take effect when you reboot the system.1 You can also allow specific hosts or subnets as seen in this example: Order deny. then you can turn it on manually using the following command: /sbin/sysctl -w net.ip_forward = 0 in /etc/sysctl.ipv4.57/24 network can access the Piranha Configuration Tool.16. Initial LVS Configuration Order deny. Warning Editing the Piranha Configuration Tool.100 Allow from 172. create a .168. so the sshd daemon should also be installed and running.5. each LVS router node must have IP forwarding turned on in the kernel.100 and machines on the 172. and deny lines identical to /etc/ sysconfig/ha/web/secure/.htaccess file in the /etc/sysconfig/ha/web/ directory with order. then IP forwarding is enabled.ip_forward=1 2. allow. Configuring Services on the Real Servers If the real servers are Red Hat Enterprise Linux systems.16.57 In this example.allow Deny from all Allow from 127.allow Deny from all Allow from 192.

The NAT LVS Network The NAT topology allows for great latitude in utilizing existing hardware.1. each real server only needs one NIC since it will only be responding to the LVS router. Configuring Network Interfaces for LVS with NAT To set up LVS with NAT. To prevent a single point of failure. on the other hand. The LVS router group should consist of two identical or very similar systems running Red Hat Enterprise Linux.168.12/24 network. In particular. Setting Up LVS LVS consists of two basic groups: the LVS routers and the real servers. each groups should contain at least two member systems. but it is limited in its ability to handle large loads because all packets going into and coming out of the pool pass through the LVS router.11. but let us pretend there is a firewall in front of the LVS router for good measure) and the private interfaces which link to the real servers (eth1) will be on the 10. Software Because the NAT topology requires the use of iptables for some configurations. Because this topology creates a network bottleneck at the LVS router. the LVS routers' public interfaces (eth0) will be on the 192. If gigabit Ethernet is employed on the LVS routers. this is not a routable IP.9 17 . the public interface's network script.1. So on the active or primary LVS router node. could look something like this: DEVICE=eth0 BOOTPROTO=static ONBOOT=yes IPADDR=192. Hardware The NAT topology is the most flexible in regards to hardware because the real servers do not need to be Linux machines to function correctly. In this example. so they need to have as close to the same capabilities as possible. /etc/sysconfig/ network-scripts/ifcfg-eth0. The real servers pass all requests back through the LVS router so they are on their own private network.26/24 network (I know. Network Layout The topology for LVS using NAT routing is the easiest to configure from a network layout perspective because only one access point to the public network is needed. In a NAT topology. gigabit Ethernet NICs can be employed on each LVS router to increase the bandwidth the LVS routers can handle. FTP services and the use of firewall marks requires extra manual configuration of the LVS routers to route requests properly. 3.168.Chapter 3. One will act as the active LVS router while the other stays in hot standby mode. need two NICs each to route traffic between the two networks. The LVS routers.26. you must first configure the network interfaces for the public network and the private network on the LVS routers. any switch connecting the real servers to the LVS routers must have at least two gigabit Ethernet ports to handle the load efficiently. 3. determine which of the three LVS topologies to use. I know. Before choosing and configuring the hardware for the real server group.1. there can be a fair amount of software configuration outside of Piranha Configuration Tool. as shown in Section 4.10 and the VIP for the NAT or private interface will be 10.6. For instance.168.12.0 In this example. After configuring the primary LVS router node's network interfaces.12. So the real server's /etc/sysconfig/network-scripts/ifcfg-eth0 file could look similar to this: 18 . that address is 10.9 NETMASK=255.12.0 GATEWAY=192. it is essential that the real servers route requests back to the VIP for the NAT interface.Chapter 3. You will. configure the backup LVS router's real network interfaces — taking care that none of the IP address conflict with any other IP addresses on the network.26. Routing on the Real Servers The most important thing to remember when configuring the real servers network interfaces in a NAT topology is to set the gateway for the NAT floating IP address of the LVS router. be able to ping the real IP for the LVS router's private interface.254 The /etc/sysconfig/network-scripts/ifcfg-eth1 for the private NAT interface on the LVS router could look something like this: DEVICE=eth1 BOOTPROTO=static ONBOOT=yes IPADDR=10. “The VIRTUAL SERVER Subsection”.4. however. “GLOBAL SETTINGS” and Section 4. the machines will be unable to ping or connect in other ways to the public network.255.255.255. Note Once the network interfaces are up on the real servers. In this example.26.11. the VIP for the LVS router's public interface will be 192. Important The sample Ethernet interface configuration settings in this section are for the real IP addresses of an LVS router and not the floating IP addresses. So. 3. if eth0 connects to the public network on the primary node. Setting Up LVS NETMASK=255. in this case 10. To configure the public and private floating IP addresses the administrator should use the Piranha Configuration Tool.1. it must also connect to the public network on the backup node as well. Important Be sure each interface on the backup node services the same network as the interface on primary node.12. This is normal.

Warning Do not configure the floating IP for eth0:1 or eth1:1 by manually editing network scripts or using a network configuration tool. Direct routing requires that the real servers be physically connected to a network segment with the LVS router and be able to process and direct outgoing packets as well.6. Once forwarding is enabled on the LVS routers and the real servers are set up and have the clustered services running.8. direct routing allows real servers to process and route packets directly to a requesting user rather than passing outgoing packets through the LVS router. “Turning on Packet Forwarding” for instructions on turning on packet forwarding.4. the real servers may not route requests properly. “Starting LVS”. Instead. Network Layout In a direct routing LVS setup. When finished. Therefore if both eth0 and eth1 are configured and eth1 is used for LVS. Enabling NAT Routing on the LVS Routers In a simple NAT LVS configuration where each clustered service uses only one port.4.255. the administrator needs only to enable packet forwarding on the LVS routers for the requests to be properly routed between the outside world and the real servers. LVS via Direct Routing As mentioned in Section 1. like HTTP on port 80. Once pulse is up and running. However.1. For information on creating multi-port services using firewall marks.12. 3. “GLOBAL SETTINGS” and Section 4. use the Piranha Configuration Tool as shown in Section 4.11. use the Piranha Configuration Tool to configure LVS as shown in Chapter 4. the first one to come up will get the gateway. “The VIRTUAL SERVER Subsection”. Configuring the LVS Routers with Piranha Configuration Tool. the active LVS router will begin routing requests to the pool of real servers.0 GATEWAY=10. See Section 2. “Direct Routing”.2.11. The real servers then need to directly route the response to the client.1 NETMASK=255.1.10 Warning If a real server has more than one network interface configured with a GATEWAY= line. more configuration is necessary when the clustered services require more than one port to go to the same real server during a user session. if the client is on the Internet. So. 3. start the pulse service as shown in Section 4.Enabling NAT Routing on the LVS Routers DEVICE=eth0 ONBOOT=yes BOOTPROTO=static IPADDR=10.4. and sends the packet through the 19 .2. see Section 3. for example. “Multi-port Services and LVS”. the LVS router needs to receive incoming requests and route them to the proper real server for processing.5.3. It is best to turn off extraneous network interfaces by setting ONBOOT=no in their network scripts within the /etc/sysconfig/network-scripts/ directory or by making sure the gateway is correctly set in the interface which comes up first.255.12.

Using the arptables_jf method. Important It is not recommended to use the LVS router as a gateway for the real servers. a gateway to the Internet is required. Direct Routing and arptables_jf In order to configure direct routing using arptables_jf. 3. and any ARP packets that might otherwise be sent containing the VIPs are mangled to contain the real server's IP instead of the VIPs. VIPs can not be configured to start on boot using standard Red Hat Enterprise Linux system configuration tools. each real server must have their virtual IP address configured. perform the following steps: 1.2. each real server can be connected to its own separate gateway which has its own dedicated connection to the carrier network to which the client is connected (such as the Internet or an intranet). often this is the IP bound to eth0): 20 . For example. the real server must be able to go directly to the client via the Internet. Each real server in the server pool can have its own separate gateway (and each gateway with its own connection to the Internet). the arptables_jf method allows multiple instances of Apache HTTP Server to be running bound explicitly to different VIPs on the system.Chapter 3. To configure each real server to ignore ARP requests for each virtual IP addresses. which reintroduces the network bottleneck that exists in NAT routing. There are also significant performance advantages to using arptables_jf over the iptables option.2. You can use two NICs for ease of configuration and to distinctly separate traffic — incoming requests are handled by one NIC and routed packets to real servers on the other. using the arptables_jf method. While the LVS router needs to be running Red Hat Enterprise Linux to process the incoming requests and perform load-balancing for the real servers. The LVS routers need one or two NICs each (depending on if there is a back-up router). Refer to Section 3. however. Setting Up LVS LVS router to a real server. as that adds unneeded setup complexity as well as network load on the LVS router. Hardware The hardware requirements of an LVS system using direct routing is similar to other LVS topologies. the real servers can communicate through one gateway (and therefore one network connection). “Direct Routing and iptables” for more information. ARP requests for the VIP are ignored entirely by the real servers. However.2. Create the ARP table entries for each virtual IP address on each real server (the real_ip is the IP the director uses to communicate with the real server.2. Software There is some configuration outside of Piranha Configuration Tool that needs to be done. For maximum performance and availability.1. For typical LVS setups. the real servers do not need to be Linux machines to function correctly. applications may bind to each individual VIP or port that the real server is servicing. allowing for maximum throughput and scalability. Since the real servers bypass the LVS router and send outgoing packets directly to a client. especially for administrators facing ARP issues when using LVS via direct routing. “Direct Routing and arptables_jf” or Section 3. so they can directly route packets.1. This can be done by configuring a gateway for the real server to pass packets to the Internet.

Configure Piranha for Direct Routing.168. save the ARP table entries by typing the following commands on each real server: service arptables_jf save chkconfig --level 2345 arptables_jf on The chkconfig command will cause the system to reload the arptables configuration on bootup — before the network is started.Direct Routing and iptables arptables -A IN -d <virtual_ip> -j DROP arptables -A OUT -s <virtual_ip> -j mangle --mangle-ip-s <real_ip> This will cause the real servers to ignore all ARP requests for the virtual IP addresses. Once this has been completed on each real server. You also cannot reuse ports using the iptables method.252. 3.2. because the virtual IP address(es) only exist on the active LVS director.255. 3. For example: # ifconfig eth0:1 192.24 dev eth0 As previously noted. To configure direct routing using the iptables method. the virtual IP addresses can not be configured to start on boot using the Red Hat system configuration tools. and change any outgoing ARP responses which might otherwise contain the virtual IP so that they contain the real IP of the server instead. The iptables method is simpler to configure than the arptables_jf method. This method also circumvents the LVS ARP issue entirely. you must add rules that create a transparent proxy so that a real server will service packets sent to the VIP address.255 up Or using the iproute2 utility ip.79.local.24 netmask 255.76. Direct Routing and iptables You may also work around the ARP issue using the direct routing method by creating iptables firewall rules. as there is overhead in forwarding/masquerading every packet. Refer to Chapter 4. Configure the virtual IP address on all real servers using ifconfig to create an IP alias. 2.0 broadcast 192. To configure direct routing using iptables.2.76. Configuring the LVS Routers with Piranha Configuration Tool for more information. even though the VIP address does not exist on the system. for example: # ip addr add 192. One way to work around this issue is to place these commands in /etc/rc. it is not possible to run two separate Apache HTTP Server services bound to port 80. The only node that should respond to ARP requests for any of the VIPs is the current active LVS node. because both must bind to INADDR_ANY instead of the virtual IP addresses. there are performance issues using the iptables method compared to arptables_jf.168. perform the following steps: 21 .168.d/rc. However. 4. For example.

run the following command for every VIP. 2. Putting the Configuration Together After determining which of the preceding routing methods to use. For more information about adding devices using system-config-network. This can be done using a graphical application such as system-confignetwork or by editing the network scripts manually. Important The adapter devices on the LVS routers must be configured to access the same networks. Below are some useful commands for bringing up network interfaces or checking their status. example alterations to network interfaces are made either manually or through the Piranha Configuration Tool.3. configure the network interfaces on the primary and backup LVS routers. For the remainder of the chapter. use the following command as root. port. then these same devices on the backup LVS router must connect to the same networks. and protocol (TCP or UDP) combination intended to be serviced for the real server: iptables -t nat -A PREROUTING -p <tcp|udp> -d <vip> --dport <port> -j REDIRECT This command will cause the real servers to process packets destined for the VIP and port that they are given. Bringing Up Real Network Interfaces To bring up a real network interface. This is especially important to consider when configuring the real servers.1.3. After physically connecting together the hardware. /sbin/ifup ethN 22 . the hardware should be linked together on the network. replacing N with the number corresponding to the interface (eth0 and eth1). 3. On each real server.Chapter 3. The sections on each topology give example network addresses. see the chapter titled Network Configuration in the Red Hat Enterprise Linux Deployment Guide. Save the configuration on each real server: # service iptables save # chkconfig --level 2345 iptables on The commands above cause the system to reload the iptables configuration on bootup — before the network is started. For instance if eth0 connects to public network and eth1 connects to the private network. General LVS Networking Tips Configure the real IP addresses for both the public and private networks on the LVS routers before attempting to configure LVS using the Piranha Configuration Tool. Setting Up LVS 1. Also the gateway listed in the first interface to come up at boot time is added to the routing table and subsequent gateways listed in other interfaces are ignored. but the actual network addresses are needed. 3.

when combined with persistence. outside of Piranha Configuration Tool. /sbin/ifdown ethN Checking the Status of Network Interfaces If you need to check which network interfaces are up at any given time. “The VIRTUAL SERVER Subsection”.4. Multi-port services can be created artificially by using firewall marks to bundle together different. the administrator must use iptables. iptables. If an LVS is used for FTP services.1. replacing N with the number corresponding to the interface (eth0 and eth1). Assigning Firewall Marks To assign firewall marks to a packet destined for a particular port.5. To do this. or when LVS is used with true multi-port protocols. issue the following command: /sbin/route 3. however. see Section 4. 3. but bearing the same firewall mark.6. should be handled identically. The basic rule to remember when using firewall marks is that for every protocol using a firewall mark in Piranha Configuration Tool there must be a commensurate iptables rule to assign marks to the network packets. refer to Section 3. open a shell prompt. type the following: /sbin/ifconfig To view the routing table for a machine. In either case. the mechanism used to balance the loads on the real servers — IPVS — can recognize the firewall marks assigned to a packet. The job of assigning firewall marks must be performed by the network packet filter. Unfortunately. the LVS router uses firewall marks to recognize that packets destined for different ports. Use the service command to start pulse instead (see Section 4. firewall marks ensure connections from the client machine are routed to the same host. such as HTTP (port 80) and HTTPS (port 443). login as root. use the following command as root. but related protocols. as long as the connections occur within the length of time specified by the persistence parameter. Bringing Down Real Network Interfaces To bring down a real network interface. “Configuring FTP” for configuration details. “Starting LVS” for details). Multi-port Services and LVS LVS routers under any topology require extra configuration when creating multi-port LVS services.1. but cannot itself assign firewall marks. such as FTP. FTP is another commonly clustered multi-port protocol. Before creating network packet filter rules. and type: /sbin/service iptables status 23 . This section illustrates how to bundle HTTP and HTTPS as an example.Multi-port Services and LVS Warning Do not use the ifup scripts to bring up any floating IP addresses you may configure using Piranha Configuration Tool (eth0:1 or eth1:1).4. make sure there are no rules already in place. For more on assigning persistence to a virtual server. Also.8.

In the above iptables commands. The two types of data connections are: Active Connections When an active connection is established. n. Also note that you must log in as root and load the module for iptables before issuing rules for the first time.1.n/32 --dport 80 -j MARK --set-mark 80 /sbin/iptables -t mangle-A PREROUTING -p tcp -d n.5.n.n should be replaced with the floating IP for your HTTP and HTTPS virtual servers. check the contents of /etc/sysconfig/iptables and copy any rules worth keeping to a safe place before proceeding.n/32 --dport 443 -j MARK --set-mark 80 For instructions on assigning the VIP to the public network interface.5.n.n. the prompt will instantly reappear. the server opens a data connection to the client from port 20 to a high range port on the client machine. Setting Up LVS If iptables is not running. All data from the server is then passed over this connection. see Section 4.n. 3. If rules are present. “Saving Network Packet Filter Settings” 3. If iptables is active. on ports 80 and 443.n. 80. 24 .1. type the following command: /sbin/service iptables stop If the rules already in place are important. to incoming traffic destined for the floating IP address. Configuring FTP File Transport Protocol (FTP) is an old and complex multi-port protocol that presents a distinct set of challenges to an LVS environment. How FTP Works With most other server client relationships. but do not persist through a reboot of the system. To ensure network packet filter settings are restored upon reboot.6.n. refer to Section 3.Chapter 3. n. Below are rules which assign the same firewall mark. /sbin/modprobe ip_tables /sbin/iptables -t mangle -A PREROUTING -p tcp -d n.6. The type of connection chosen by the client determines how the server responds and on what ports transactions will occur.n.n. the client machine opens up a connection to the server on a particular port and the server then responds to the client on that port. you must first understand some key things about how FTP works. “The VIRTUAL SERVER Subsection”. it displays a set of rules. These commands have the net effect of assigning any traffic addressed to the VIP on the appropriate ports a firewall mark of 80. which in turn is recognized by IPVS and forwarded appropriately.n. Then the client tells the FTP server whether to establish an active or passive connection. When an FTP client connects to an FTP server it opens a connection to the FTP control port 21. Warning The commands above will take effect immediately. To understand the nature of these challenges.

1. How This Affects LVS Routing IPVS packet forwarding only allows connections in and out of the cluster based on it recognizing its port number or its firewall mark.n. 3. not the server. it drops the connection. the client asks the FTP server to establish a passive connection port.4. n. The server then binds to this highnumbered port for this particular session and relays that port number back to the client.3. Note The client determines the type of connection. Creating Network Packet Filter Rules Before assigning any iptables rules for FTP service. If a client from outside the cluster attempts to open a port IPVS is not configured to handle.3. This means to effectively cluster FTP.n. See Section 4. if the real server attempts to open a connection back out to the Internet on a port IPVS does not know about.n should be replaced with the first three values for the floating IP for the NAT interface's internal network interface defined in the GLOBAL SETTINGS panel of Piranha Configuration Tool. The FTP client/server relationship can potentially open a large number of ports that the Piranha Configuration Tool and IPVS do not know about.2.5. “The VIRTUAL SERVER Subsection” for details.1.1. Similarly. to FTP traffic. you must configure the LVS routers to handle both active and passive connections. 3. This means all connections from FTP clients on the Internet must have the same firewall mark assigned to them and all connections from the FTP server must be properly forwarded to the Internet using network packet filtering rules. The following iptables command allows the LVS router to accept outgoing connections from the real servers that IPVS does not know about: /sbin/iptables -t nat -A POSTROUTING -p tcp -s n. review the information in Section 3.n.0/24 --sport 20 -j MASQUERADE In the iptables command. For these rules to work properly. Rules for Active Connections The rules for active connections tell the kernel to accept and forward connections coming to the internal floating IP address on port 20 — the FTP data port. it drops the connection. 21. The client then opens the newly bound port for the data connection.How This Affects LVS Routing Passive Connections When a passive connection is established.5. Each data request the client makes results in a separate data connection.5.000. you must also use the VIRTUAL SERVER subsection of Piranha Configuration Tool to configure a virtual server for port 21 with a value of 21 in the Firewall Mark field.6. Most modern FTP clients attempt to establish a passive connection when requesting data from servers. “Assigning Firewall Marks” concerning multi-port services and techniques for checking the existing network packet filtering rules. which can be on any port higher than 10. 25 . Below are rules which assign the same firewall mark. 3.

n Replace n.n. refer to Section 2. but do not persist through a reboot of the system. “Saving Network Packet Filter Settings” Finally. The following iptables commands have the net effect of assigning any traffic addressed to the floating IP on the appropriate ports a firewall mark of 21. 26 . For more on this.Chapter 3. For example: pasv_address=n. Warning The commands above take effect immediately. add the following line to /etc/vsftpd. To ensure network packet filter settings are restored after a reboot. Rules for Passive Connections The rules for passive connections assign the appropriate firewall mark to connections coming in from the Internet to the floating IP for the service on a wide range of ports — 10.n.n.n. This can be accomplished by adding the following lines to / etc/vsftpd.1. see Section 3. you must also configure the VSFTP server to use a matching port range.n.n. consult the respective documentation.n should be replaced with the floating IP for the FTP virtual server defined in the VIRTUAL SERVER subsection of Piranha Configuration Tool. Setting Up LVS 3.000 to 20.n/32 --dport 10000:20000 -j MARK --set-mark 21 In the iptables commands.n with the VIP address of the LVS system. n.n. For configuration of other FTP servers.3.2.n.conf to override the real server IP address to the VIP. “Configuring Services on the LVS Routers”. you need to be sure that the appropriate service is set to activate on the proper runlevels.n/32 --dport 21 -j MARK --set-mark 21 /sbin/iptables -t mangle -A PREROUTING -p tcp -d n. you can increase this number to include all available non-secured ports by changing 10000:20000 in the commands below to 1024:65535. which is what the client sees upon connection. This range should be a wide enough for most situations. however.n.n.5. Warning If you are limiting the port range for passive connections. which is in turn recognized by IPVS and forwarded appropriately: /sbin/iptables -t mangle -A PREROUTING -p tcp -d n.6. In a NAT routed LVS system.000.conf: pasv_min_port=10000 pasv_max_port=20000 You must also control the address that the server displays to the client for passive FTP connections.

see Section 2. For more on this. save the settings so they get restored after a reboot. see Section 2. Saving Network Packet Filter Settings After configuring the appropriate network packet filters for your situation.6. The next chapter explains how to use the Piranha Configuration Tool to configure the LVS router and describe the steps necessary to activate LVS. 27 . you are able to use the /sbin/service command to start.1. “Configuring Services on the LVS Routers”.Saving Network Packet Filter Settings 3. type the following command: /sbin/service iptables save This saves the settings in /etc/sysconfig/iptables so they can be recalled at boot time. Finally. For an example of how to use the /sbin/service command. The /sbin/service will automatically load the appropriate module for you.3. stop. For iptables. Once this file is written. “Starting the Piranha Configuration Tool Service”. you need to be sure the appropriate service is set to activate on the proper runlevels. and check the status (using the status switch) of iptables.

28 .

Configuring the LVS Routers with Piranha Configuration Tool The Piranha Configuration Tool provides a structured approach to creating the necessary configuration file for LVS — /etc/sysconfig/ha/lvs. “The Welcome Panel”. Otherwise. such as links. Once the browser connects. Important The configuration file for LVS follows strict formatting rules. Necessary Software The piranha-gui service must be running on the primary LVS router to use the Piranha Configuration Tool. Using the Piranha Configuration Tool is the best way to prevent syntax errors in the lvs. While configuring the primary LVS router it is a good idea to keep a concurrent ssh connection in a terminal window. you can open http://localhost:3636 in a Web browser to access the Piranha Configuration Tool. as described in Section 2.1.cf and therefore prevent software failures. The next four sections walk through each of the configuration pages of the Piranha Configuration Tool and give instructions on using it to set up LVS. This chapter describes the basic operation of the Piranha Configuration Tool and how to activate LVS once configuration is complete. To do this. you should always begin by configuring the primary router with the Piranha Configuration Tool. “Setting a Password for the Piranha Configuration Tool”. 4. type in the hostname or real IP address for the server followed by :3636. you will see the screen shown in Figure 4. 29 . you also need an ssh connection to the primary LVS router as the root user. and monitor /var/log/messages during trouble shooting. If you are accessing the LVS router from another machine. 4. To configure LVS.2.Chapter 4.1.verify that the piranha-gui service is running and an administrative password has been set. Logging Into the Piranha Configuration Tool When configuring LVS.2. If you are accessing the machine locally. you minimally need a text-only Web browser. This connection provides a secure way to restart pulse and other services. configure network packet filters.cf.

and the LVS-spawned nanny processes. Note The fields for CURRENT LVS ROUTING TABLE and CURRENT LVS PROCESSES remain blank until you actually start LVS. CONTROL/MONITORING The CONTROL/MONITORING Panel presents the a limited runtime status of LVS.1. the Virtual Servers panel contains four subsections.Chapter 4. It displays the status of the pulse daemon.8. “Starting LVS”. Configuring the LVS Routers with Piranha Configuration Tool Figure 4. In addition. 30 . The CONTROL/MONITORING panel is the first panel after the login screen. as shown in Section 4.3. The Piranha Configuration Tool is made of four main screens or panels. The Welcome Panel Click on the Login button and enter piranha for the Username and the administrative password you created in the Password field. the LVS routing table. 4.

Update information now You can manually update the status information manually by clicking this button. The CONTROL/MONITORING Panel Auto update The status display on this page can be updated automatically at a user configurable interval. 31 . To enable this feature. 4. If you encounter this issue.4.GLOBAL SETTINGS Figure 4. CHANGE PASSWORD Clicking this button takes you to a help screen with information on how to change the administrative password for the Piranha Configuration Tool. Doing so may make it difficult to reconfigure the Auto update interval because the page will update too frequently. GLOBAL SETTINGS The GLOBAL SETTINGS panel is where the you define the networking details for the primary LVS router's public and private network interfaces. such as Mozilla. simply click on another panel and then back on CONTROL/MONITORING. click on the Auto update checkbox and set the desired update frequency in the Update frequency in seconds text box (the default value is 10 seconds).2. The Auto update feature does not work with all browsers. It is not recommended that you set the automatic update to an interval less than 10 seconds.

1.Chapter 4. These are the interfaces already configured in Section 3.1. but doing so will mean there is no alternate heartbeat channel for the backup LVS router to use and therefore will create a single point of failure.3. “Configuring Network Interfaces for LVS with NAT”. as all real servers as well as the LVS directors share the same virtual IP addresses and should have the same IP route configuration. Primary server public IP In this field.1. Primary server private IP Enter the real IP address for an alternative network interface on the primary LVS node. The GLOBAL SETTINGS Panel The top half of this panel sets up the primary LVS router's public and private network interfaces. Configuring the LVS Routers with Piranha Configuration Tool Figure 4. You may leave this field blank. 32 . enter the publicly routable real IP address for the primary LVS node.1. Note The private IP address is not needed for Direct Routing configurations. This address is used solely as an alternative heartbeat channel for the backup router and does not have to correlate to the real private IP address assigned in Section 3. “Configuring Network Interfaces for LVS with NAT”.

4. “The REDUNDANCY Panel”. click on the ENABLE button so that the screen matches Figure 4. Click the Direct Routing button to select direct routing. NAT Router IP Enter the private floating IP in this text field. so eth1:1 is the floating IP address. 33 . click the ACCEPT button to make sure you do not lose any changes when selecting a new panel. NAT Router netmask If the NAT router's floating IP needs a particular netmask. These fields do not apply to the direct routing network type. The next three fields deal specifically with the NAT router's virtual network interface connecting the private network with the real servers. Use network type Click the NAT button to select NAT routing. Note The first time you visit this screen. the private network is on the eth1 interface. Warning After completing this page. it displays an "inactive" Backup status and an ENABLE button. In this example. such as eth1:1. To configure the backup LVS router.REDUNDANCY Note The primary LVS router's private IP can be configured on any interface that accepts TCP/IP. NAT Router device Use this text field to define the device name of the network interface for the floating IP address. REDUNDANCY The REDUNDANCY panel allows you to configure of the backup LVS router node and set various heartbeat monitoring options.4. Note You should alias the NAT floating IP address to the Ethernet interface connected to the private network. whether it be an Ethernet adapter or a serial port.5. select it from drop-down list. This floating IP should be used as the gateway for the real servers.

Heartbeat Interval (seconds) This field sets the number of seconds between heartbeats — the interval that the backup node will check the functional status of the primary LVS node. The default is set to 539 if this field is left blank. Assume dead after (seconds) If the primary LVS node does not respond after this number of seconds. The REDUNDANCY Panel Redundant server public IP Enter the public real IP address for the backup LVS router node. which is used by the backup node to monitor the primary node for failure. 34 . If you do not see the field called Redundant server private IP. Redundant server private IP Enter the backup node's private real IP address in this text field.4. Configuring the LVS Routers with Piranha Configuration Tool Figure 4. then the backup LVS router node will initiate failover. Heartbeat runs on port This field sets the port at which the heartbeat communicates with the primary LVS node. The rest of the panel is devoted to configuring the heartbeat channel. go back to the GLOBAL SETTINGS panel and enter a Primary server private IP address and click ACCEPT.Chapter 4.

and the virtual device interface. the netmask of the virtual IP. Figure 4.6. 35 . After adding a virtual server. the protocol used. you can configure it by clicking the radio button to its left and clicking the EDIT button to display the VIRTUAL SERVER subsection. To add a service. To enable or disable a virtual server in the table click its radio button and click the (DE)ACTIVATE button. 4.5. click the ADD button.VIRTUAL SERVERS Warning Remember to click the ACCEPT button after making any changes in this panel to make sure you do not lose any changes when selecting a new panel. The VIRTUAL SERVERS Panel Each server displayed in the VIRTUAL SERVERS panel can be configured on subsequent screens or subsections. VIRTUAL SERVERS The VIRTUAL SERVERS panel displays information for each currently defined virtual server. select it by clicking the radio button next to the virtual server and click the DELETE button. the virtual IP assigned to the server. the port number to which the service communicates. Each table entry shows the status of the virtual server. To remove a service. the server name.

6. The VIRTUAL SERVER Subsection The VIRTUAL SERVER subsection panel shown in Figure 4. so this is selected in the example above. Application port Enter the port number through which the service application will listen. 36 . such as HTTP. Protocol Choose between UDP and TCP in the drop-down menu. You can even reference the protocol used by the virtual server. Links to subsections related specifically to this virtual server are located along the top of the page. “The VIRTUAL SERVERS Subsection” allows you to configure an individual virtual server.6. Figure 4. Web servers typically communicate via the TCP protocol.1. Configuring the LVS Routers with Piranha Configuration Tool 4. so make it descriptive and easily identifiable. port 80 is used. The VIRTUAL SERVERS Subsection Name Enter a descriptive name to identify the virtual server. But before configuring any of the subsections related to this virtual server. Since this example is for HTTP services. Virtual IP Address Enter the virtual server's floating IP address in this text field. complete this page and click on the ACCEPT button. This name is not the hostname for the machine.Chapter 4.6.

In this example. If you select rup from the drop-down menu. You should alias the public floating IP address to the Ethernet interface connected to the public network. before a real server is considered dead and removed from the pool. If you select ruptime. the public network is on the eth0 interface. Service Timeout Enter an integer value which defines the length of time. See Section 3. each real server must run the rwhod service. each real server must run the rstatd service. Warning Entering a firewall mark in this field allows IPVS to recognize that packets bearing this firewall mark are treated the same.5. In this example. before the active LVS router attempts to bring a real server back into the pool after a failure. “Multi-port Services and LVS” for instructions on creating multi-port services and Section 3. this technique will ensure users accessing both insecure and secure webpages are routed to the same real server. but related protocols. Load monitoring tool The LVS router can monitor the load on the various real servers by using either rup or ruptime.The VIRTUAL SERVER Subsection Virtual IP Network Mask Set the netmask for this virtual server with the drop-down menu. Device Enter the name of the network device to which you want the floating IP address defined the Virtual IP Address field to bind. “Configuring FTP” for creating a highly available FTP virtual server. so eth0:1 should be entered as the device name. in seconds. the least-connections table is reset to zero so the active LVS router routes requests as if all the real servers were freshly added to the pool. 37 . preserving state. in seconds. Quiesce server When the Quiesce server radio button is selected. Firewall Mark Do not enter a firewall mark integer value in this field unless you are bundling multi-port protocols or creating a multi-port virtual server for separate. the above virtual server has a Firewall Mark of 80 because we are bundling connections to HTTP on port 80 and to HTTPS on port 443 using the firewall mark value of 80. but you must perform further configuration outside of the Piranha Configuration Tool to actually assign the firewall marks. anytime a new real server node comes online. Re-entry Time Enter an integer value which defines the length of time. This option prevents the a new server from becoming bogged down with a high number of connections upon entering the pool.4. When combined with persistence.

be sure that if you use firewall marks and persistence together. you should enter a value for persistence as well. Now. It displays the status of the physical server hosts for a particular virtual service. that the amount of persistence is the same for each virtual server with the firewall mark. To make sure you do not lose changes when selecting a new panel. persistence limited by subnet was a crude way of bundling connections. Persistence If an administrator needs persistent connections to the virtual server during client transactions. Important If you entered a value in the Firewall Mark field above. For more information on scheduling algorithms. REAL SERVER Subsection Clicking on the REAL SERVER subsection link at the top of the panel displays the EDIT REAL SERVER subsection. 4. 38 . “Scheduling Algorithms”.6.2.3.Chapter 4. For more on persistence and firewall marks. if you use load monitoring. Configuring the LVS Routers with Piranha Configuration Tool Warning Load monitoring is not the same as load balancing and can result in hard to predict scheduling behavior when combined with weighted scheduling algorithms. “Persistence and Firewall Marks”. see Section 1. Also. select the appropriate network mask from the drop-down menu.5. the real servers must be Linux machines. it is best to use persistence in relation to firewall marks to achieve the same result. refer to Section 1. enter the number of seconds of inactivity allowed to lapse before a connection times out in this text field.1. Also. The default is Weighted least-connection. Persistence Network Mask To limit persistence to particular subnet. Warning Remember to click the ACCEPT button after making any changes in this panel. Scheduling Select your preferred scheduling algorithm from the drop-down menu. Note Before the advent of firewall marks.

REAL SERVER Subsection Figure 4. 39 .8. Click the EDIT button to load the EDIT REAL SERVER panel. To delete an existing server. select the radio button beside it and click the DELETE button.7. as seen in Figure 4. “The REAL SERVER Configuration Panel”. The REAL SERVER Subsection Click the ADD button to add a new server.

so make it descriptive and easily identifiable.3. Configuring the LVS Routers with Piranha Configuration Tool Figure 4. Weight An integer value indicating this host's capacity relative to that of other hosts in the pool. “Server Weight and Scheduling”. see Section 1. Address The real server's IP address. For more on server weight. do not add a port number. but treat it as a ratio in relation to other real servers in the pool. The REAL SERVER Configuration Panel This panel consists of three entry fields: Name A descriptive name for the real server.8. Since the listening port is already specified for the associated virtual server. 40 . The value can be arbitrary.2.Chapter 4. Note This name is not the hostname for the machine.

6. such as HTTPS or SSL. It is also the place where the administrator can specify customized scripts to check services requiring dynamically changing data. EDIT MONITORING SCRIPTS Subsection Click on the MONITORING SCRIPTS link at the top of the page. and type the path to it in the Sending Program field.3.EDIT MONITORING SCRIPTS Subsection Warning Remember to click the ACCEPT button after making any changes in this panel. you must write a script that returns a textual response. Figure 4. set it to be executable. 41 . The EDIT MONITORING SCRIPTS Subsection Sending Program For more advanced service verification. To make sure you do not lose any changes when selecting a new panel. The EDIT MONITORING SCRIPTS subsection allows the administrator to specify a send/expect string sequence to verify that the service for the virtual server is functional on each real server. To use this functionality. This functionality is especially helpful for services that require dynamically changing data.9. you can use this field to specify the path to a servicechecking script. 4.

ASCII characters as well as the following escape characters: • \n for new line. • \t for tab.com if [ $TEST != "1" ].Chapter 4. This token is replaced with each real server's IP address as the script is called by the nanny daemon. use the special token %h after the path to the script in the Sending Program field. Expect Enter a the textual response the server should return if it is functioning properly. then the Send field is ignored. Note To determine what to send for a given service. FTP reports 220 upon connecting. By default the send field is completed for HTTP.example.com @$1 | grep -c dns. The following is a sample script to use as a guide when composing an external service-checking script: #!/bin/sh TEST=`dig -t soa example. • \ to escape the next character which follows it. If you wrote your own sending program. • \r for carriage return. the nanny daemon attempts to open the port and assume the service is running if it succeeds. then echo "OK else echo "FAIL" fi Note If an external program is entered in the Sending Program field. so could enter quit in the Send field and 220 in the Expect field. For instance. If you leave this field blank. and it can only contain printable. Configuring the LVS Routers with Piranha Configuration Tool Note To ensure that each server in the real server pool is checked. Only one send sequence is allowed in this field. 42 . Send Enter a string for the nanny daemon to send to each real server in this field. You can alter this value depending on your needs. you can open a telnet connection to the port on a real server and see what is returned. enter the response you told it to send if it was successful.

• /etc/sysctl — the configuration file that. • /etc/sysconfig/iptables — If you are using firewall marks. among other things.Synchronizing Configuration Files Warning Remember to click the ACCEPT button after making any changes in this panel.1. Important The /etc/sysctl. 4. you should synchronize one of these files based on which network packet filter you are using. you must copy it to the backup LVS router node. Once you have configured virtual servers using the Piranha Configuration Tool.cf files 43 between the router nodes: . /etc/sysconfig/ha/lvs.7. “Synchronizing Configuration Files” for details. Important To use scp the sshd must be running on the backup router. “Configuring Services on the LVS Routers” for details on how to properly configure the necessary services on the LVS routers. Synchronizing lvs. see Section 2.cf Anytime the LVS configuration file.1. To make sure you do not lose any changes when selecting a new panel. 4.cf — the configuration file for the LVS routers. there are several configuration files that must be copied to the backup LVS router before you start LVS. is created or updated.conf and /etc/sysconfig/iptables files do not change when you configure LVS using the Piranha Configuration Tool. The best way to do this is to use the scp command.cf.7.cf files. These files include: • /etc/sysconfig/ha/lvs. Mismatched LVS configuration files between the LVS router nodes can prevent failover. turns on packet forwarding in the kernel. you must copy specific configuration files to the backup LVS router. Warning Both the active and backup LVS router nodes must have identical lvs.7. See Section 4. Synchronizing Configuration Files After configuring the primary LVS router. Issue the following command as the root user from the primary LVS router to sync the lvs.

see Section 2. if necessary.n.cf In the command. Important If you are not sure whether or not packet forwarding is enabled in the kernel. 4.cf n.n.n:/etc/sysconfig/ In the command. watch the kernel log messages with the command: tail -f /var/log/messages Then start LVS by typing the following command into the other terminal: /sbin/service pulse start Follow the progress of the pulse service's startup in the terminal with the kernel log messages.n. Synchronizing Network Packet Filtering Rules If you are using iptables. 4. 4.n.Chapter 4.1.n. you will need to synchronize the appropriate configuration file on the backup LVS router. “Configuring Services on the LVS Routers” for more on this topic) you are ready to start LVS. replace n.5. If you alter the any network packet filter rules.7. Next either open an ssh session to the backup router or log into the machine as root and type the following command: /sbin/service iptables restart Once you have copied these files over to the backup router and started the appropriate services (see Section 2.n. enable this key functionality. In one terminal.2.7.8. “Turning on Packet Forwarding” for instructions on how to check and. Starting LVS To start LVS. the pulse daemon has started properly: gratuitous lvs arps finished To stop watching /var/log/messages.n.n with the real IP address of the backup LVS router.n. Synchronizing sysctl The sysctl file is only modified once in most situations. Configuring the LVS Routers with Piranha Configuration Tool scp /etc/sysconfig/ha/lvs. type Ctrl+c.n with the real IP address of the backup LVS router. When you see the following output. enter the following command as root from the primary LVS router: scp /etc/sysconfig/iptables n.n:/etc/sysconfig/ha/lvs. it is best to have two root terminals open simultaneously or two simultaneous root open ssh sessions to the primary LVS router. replace n.3. This file is read at boot time and tells the kernel to turn on packet forwarding. 44 .

Starting LVS From this point on. 45 . you should start the backup LVS router before putting LVS into service. LVS will be up and running. simply repeat the process described above on the backup LVS router node. To do this. After completing this final step. While you can make requests to LVS at this point. the primary LVS router is also the active LVS router.

46 .

and application availability. which forward the data to the requesting client. data integrity. LVS with a Red Hat Cluster Serving dynamic Web content with LVS requires a three-tier configuration (as shown in Figure A. Client requests to the URL pass through the firewall to the active LVS load-balancing router. “LVS with a Red Hat Cluster”).1. While a two-tier LVS configuration is suitable if the Web servers serve only static Web content (consisting of small amounts of infrequently 47 . no-single-point-of-failure e-commerce site.1.1. The configuration in Figure A. This combination of LVS and Red Hat Cluster allows for the configuration of a high-integrity. “LVS with a Red Hat Cluster” represents an e-commerce site used for online merchandise ordering through a URL. Using LVS with Red Hat Cluster You can use LVS routers with a Red Hat Cluster to deploy a high-availability e-commerce site that provides load balancing. which then forwards the requests to one of the Web servers.Appendix A. The Red Hat Cluster nodes serve dynamic data to the Web servers. Figure A. The Red Hat Cluster can run a high-availability instance of a database or a set of databases that are network-accessible to the Web servers. A three-tier configuration is required to provide dynamic content.

Each Web server can independently process an HTTP request from a client and send the response back to the client. a two-tier configuration is not suitable if the Web servers serve dynamic content.Appendix A. In an LVS configuration like the one in Figure A. LVS continues to perform load balancing across a smaller set of Web servers. For redundancy. • Third tier — A Red Hat Cluster to serve data to the Web servers. the LVS routers perform load balancing across a wider set of Web servers. which must be consistent on all the Web servers to ensure that customers have access to up-to-date and accurate information. or customer databases. it can be removed. Each tier provides the following functions: • First tier — LVS routers performing load-balancing to distribute Web requests. which can be a Linux system serving in that capacity or a dedicated firewall device. “LVS with a Red Hat Cluster”. Behind the firewall are LVS load-balancing routers. Using LVS with Red Hat Cluster changing data). you can configure firewall devices in a failover configuration. For security reasons. 48 . LVS enables you to expand a Web site's capacity by adding Web servers behind the LVS routers. The active load-balancing router forwards the requests to the set of Web servers. which can be configured in an active-standby mode. In addition. Dynamic content could include product inventory.1. these requests enter a Web site through a firewall. client systems issue requests on the World Wide Web. • Second tier — A set of Web servers to serve the requests. purchase orders. if a Web server fails.

Revision 1.com 49 . Revision History Revision 2.0 Mon Feb 08 2010 Paul Kennedy pkennedy@redhat.Appendix B.com Resolves: 492000 Changes -d to -s in arptables "OUT" directive in "Direct Routing and arptables_jf" section.0 Tue Jan 20 2009 Consolidation of point releases Paul Kennedy pkennedy@redhat.

50 .

24 nanny daemon. viii FTP. v other Red Hat Enterprise Linux documents. 47 components of LVS. 38 REDUNDANCY. 20 requirements. real servers. 44 synchronizing configuration files. 19 requirements. 16 Piranha Configuration Tool. LVS. 23 (see also LVS) J job scheduling. hardware. 3 direct routing and arptables_jf. LVS) LVS /etc/sysconfig/ha/lvs. 33 setting a password. 11 CONTROL/MONITORING. 11 daemon. viii. 1 routing methods NAT. 11 components of. 47 lvs daemon. 14 VIRTUAL SERVER subsection. 13 P packet forwarding. 4 send_arp program. 19 routing methods. 13 multi-port services. 17 overview of. 11 primary node. 23 FTP. 29 REAL SERVER subsection. 6 routing prerequisites. 3 starting LVS. 29 necessary software. 11 D direct routing and arptables_jf. network. 11 real servers.cf file. 11 pulse daemon. 11 M multi-port services. 13 ipvsadm program. 16 (see also LVS) Piranha Configuration Tool. 3 using LVS with Red Hat Cluster. 11 job scheduling. 7.cf file. hardware. 13 cluster using LVS with Red Hat Cluster. 41 GLOBAL SETTINGS. job. 7. software. 11 A arptables_jf. 11 LVS routers configuring services. 17 requirements. 17 scheduling. 31 limiting access to. v iptables. software. LVS. 4 N nanny daemon.Index Symbols /etc/sysconfig/ha/lvs. 1 packet forwarding. 11 NAT enabling. 19 requirements. 13 ipvsadm program. 11 shared data. 15 login panel. 19 requirements. 13 necessary services. 20 C chkconfig. 43 three-tier Red Hat Cluster Manager. 20 F feedback. 19 initial configuration. 29 overview of. 4 lvs daemon. 6 network address translation (see NAT) L least connections (see job scheduling. 11 date replication. network. 24 (see also LVS) I introduction. 36 51 . 11 NAT routing enabling. 30 EDIT MONITORING SCRIPTS Subsection. 17 requirements. 7.

35 piranha-gui service. 14 pulse daemon. 37 Persistence. 38 Virtual IP Address. 15 send_arp program. 47 using LVS with. 13 synchronizing configuration files. 36 VIRTUAL SERVERS. 13 piranha-passwd. LVS) routing prerequisites for LVS. LVS) 52 . 38 Scheduling. 47 round robin (see job scheduling. 43 W weighted least connections (see job scheduling. 4 security Piranha Configuration Tool. 17 S scheduling. 13 R real servers configuring services. 11 pulse service. job (LVS). 16 Red Hat Cluster and LVS.Index Firewall Mark. LVS) weighted round robin (see job scheduling. 11 sshd service.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->