Red Hat Training
A Red Hat training course is available for Red Hat Enterprise Linux
Virtual Server Administration
Linux Virtual Server (LVS) for Red Hat Enterprise Linux
Edition 5
Abstract
Introduction
- Red Hat Enterprise Linux Installation Guide — Provides information regarding installation of Red Hat Enterprise Linux 5.
- Red Hat Enterprise Linux Deployment Guide — Provides information regarding the deployment, configuration and administration of Red Hat Enterprise Linux 5.
- Red Hat Cluster Suite Overview — Provides a high level overview of the Red Hat Cluster Suite.
- Configuring and Managing a Red Hat Cluster — Provides information about installing, configuring and managing Red Hat Cluster components.
- Logical Volume Manager Administration — Provides a description of the Logical Volume Manager (LVM), including information on running LVM in a clustered environment.
- Global File System: Configuration and Administration — Provides information about installing, configuring, and maintaining Red Hat GFS (Red Hat Global File System).
- Global File System 2: Configuration and Administration — Provides information about installing, configuring, and maintaining Red Hat GFS2 (Red Hat Global File System 2).
- Using Device-Mapper Multipath — Provides information about using the Device-Mapper Multipath feature of Red Hat Enterprise Linux 5.
- Using GNBD with Global File System — Provides an overview on using Global Network Block Device (GNBD) with Red Hat GFS.
- Red Hat Cluster Suite Release Notes — Provides information about the current release of Red Hat Cluster Suite.
1. Feedback
Virtual_Server_Administration(EN)-5 (2010-02-08T16:55)
Chapter 1. Linux Virtual Server Overview
- To balance the load across the real servers.
- To check the integrity of the services on each real server.
1.1. A Basic LVS Configuration

Figure 1.1. A Basic LVS Configuration
eth0:1
. Alternatively, each virtual server can be associated with a separate device per service. For example, HTTP traffic can be handled on eth0:1
, and FTP traffic can be handled on eth0:2
.
1.1.1. Data Replication and Data Sharing Between Real Servers
- Synchronize the data across the real server pool
- Add a third layer to the topology for shared data access
1.1.1.1. Configuring Real Servers to Synchronize Data
rsync
to replicate changed data across all nodes at a set interval.
1.2. A Three-Tier LVS Configuration

Figure 1.2. A Three-Tier LVS Configuration
1.3. LVS Scheduling Overview
1.3.1. Scheduling Algorithms
- Round-Robin Scheduling
- Distributes each request sequentially around the pool of real servers. Using this algorithm, all the real servers are treated as equals without regard to capacity or load. 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. LVS round-robin scheduling also does not suffer the imbalances caused by cached DNS queries.
- Weighted Round-Robin Scheduling
- Distributes each request sequentially around the pool of real servers but gives more jobs to servers with greater capacity. Capacity is indicated by a user-assigned weight factor, which is then adjusted upward or downward by dynamic load information. Refer to Section 1.3.2, “Server Weight and Scheduling” for more on weighting real servers.Weighted round-robin scheduling is a preferred choice if there are significant differences in the capacity of real servers in the pool. However, if the request load varies dramatically, the more heavily weighted server may answer more than its share of requests.
- Least-Connection
- Distributes more requests to real servers with fewer active connections. Because it keeps track of live connections to the real servers through the IPVS table, least-connection is a type of dynamic scheduling algorithm, making it a better choice if there is a high degree of variation in the request load. It is best suited for a real server pool where each member node has roughly the same capacity. If a group of servers have different capabilities, weighted least-connection scheduling is a better choice.
- Weighted Least-Connections (default)
- Distributes more requests to servers with fewer active connections relative to their capacities. Capacity is indicated by a user-assigned weight, which is then adjusted upward or downward by dynamic load information. The addition of weighting makes this algorithm ideal when the real server pool contains hardware of varying capacity. Refer to Section 1.3.2, “Server Weight and Scheduling” for more on weighting real servers.
- Locality-Based Least-Connection Scheduling
- Distributes more requests to servers with fewer active connections relative to their destination IPs. This algorithm is designed for use in a proxy-cache server cluster. 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, in which case it assigns the IP address to the least loaded real server.
- Locality-Based Least-Connection Scheduling with Replication Scheduling
- Distributes more requests to servers with fewer active connections relative to their destination IPs. This algorithm is also designed for use in a proxy-cache server cluster. It differs from Locality-Based Least-Connection Scheduling by mapping the target IP address to a subset of real server nodes. Requests are then routed to the server in this subset with the lowest number of connections. If all the nodes for the destination IP are above capacity, 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. The most loaded node is then dropped from the real server subset to prevent over-replication.
- Destination Hash Scheduling
- Distributes requests to the pool of real servers by looking up the destination IP in a static hash table. This algorithm is designed for use in a proxy-cache server cluster.
- Source Hash Scheduling
- Distributes requests to the pool of real servers by looking up the source IP in a static hash table. This algorithm is designed for LVS routers with multiple firewalls.
1.3.2. Server Weight and Scheduling
1.4. Routing Methods
1.4.1. NAT Routing

Figure 1.3. LVS Implemented with NAT Routing
1.4.2. Direct Routing

Figure 1.4. LVS Implemented with Direct Routing
1.4.2.1. Direct Routing and the ARP Limitation
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.
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
1.5.1. Persistence
1.5.2. Firewall Marks
1.6. LVS — A Block Diagram

Figure 1.5. LVS Components
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.
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.
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.
1.6.1. LVS Components
pulse
” shows a detailed list of each software component in an LVS router.
1.6.1.1. pulse
/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 user-configurable 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.
1.6.1.2. lvs
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.
1.6.1.3. ipvsadm
lvs
daemon sets up and administers LVS by calling ipvsadm
to add, change, or delete entries in the IPVS routing table.
1.6.1.4. nanny
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.
1.6.1.5. /etc/sysconfig/ha/lvs.cf
1.6.1.6. Piranha Configuration Tool
/etc/sysconfig/ha/lvs.cf
LVS configuration file.
1.6.1.7. send_arp
Chapter 2. Initial LVS Configuration
Note
2.1. Configuring Services on the LVS Routers
chkconfig
, the ncurses-based program ntsysv
, and the graphical Services Configuration Tool. All of these tools require root access.
Note
su -
command followed by the root password. For example:
$ su - root password
- The
piranha-gui
service (primary node only) - The
pulse
service - The
sshd
service
iptables
service.
chkconfig
, type the following command for each service:
/sbin/chkconfig --level 35 daemon on
/sbin/chkconfig --list
Warning
chkconfig
does not actually start the daemon. To do this use the /sbin/service
command. See Section 2.3, “Starting the Piranha Configuration Tool Service” for an example of how to use the /sbin/service
command.
ntsysv
and the Services Configuration Tool, refer to the chapter titled "Controlling Access to Services" in the Red Hat Enterprise Linux System Administration Guide.
2.2. Setting a Password for the Piranha Configuration Tool
/usr/sbin/piranha-passwd
Warning
2.3. Starting the Piranha Configuration Tool Service
piranha-gui
service located in /etc/rc.d/init.d/piranha-gui
. To do this, type the following command as root:
/sbin/service piranha-gui start
/sbin/service piranha-gui restart
/usr/sbin/piranha_gui -> /usr/sbin/httpd
. For security reasons, the piranha-gui
version of httpd
runs as the piranha user in a separate process. The fact that piranha-gui
leverages the httpd
service means that:
- The Apache HTTP Server must be installed on the system.
- Stopping or restarting the Apache HTTP Server via the
service
command stops thepiranha-gui
service.
Warning
/sbin/service httpd stop
or /sbin/service httpd restart
is issued on an LVS router, you must start the piranha-gui
service by issuing the following command:
/sbin/service piranha-gui start
piranha-gui
service is all that is necessary to begin configuring LVS. However, if you are configuring LVS remotely, the sshd
service is also required. You do not need to start the pulse
service until configuration using the Piranha Configuration Tool is complete. See Section 4.8, “Starting LVS” for information on starting the pulse
service.
2.3.1. Configuring the Piranha Configuration Tool Web Server Port
Listen 3636
in Section 2 of the piranha-gui
Web server configuration file /etc/sysconfig/ha/conf/httpd.conf
.
http://localhost:3636
. 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.
piranha
in the Username field and the password set with piranha-passwd
in the Password field.
2.4. Limiting Access To the Piranha Configuration Tool
/etc/sysconfig/ha/web/secure/.htaccess
. After altering the file you do not have to restart the piranha-gui
service because the server checks the .htaccess
file each time it accesses the directory.
Order deny,allow Allow from all
.htaccess
file to allow access from only the loopback device (127.0.0.1). For more information on the loopback device, see the chapter titled Network Scripts in the Red Hat Enterprise Linux Reference Guide.
Order deny,allow Deny from all Allow from 127.0.0.1
Order deny,allow Deny from all Allow from 192.168.1.100 Allow from 172.16.57
Warning
.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/
. To limit access to this directory, create a .htaccess
file in the /etc/sysconfig/ha/web/
directory with order
, allow
, and deny
lines identical to /etc/sysconfig/ha/web/secure/.htaccess
.
2.5. Turning on Packet Forwarding
net.ipv4.ip_forward = 0
in /etc/sysctl.conf
to the following:
net.ipv4.ip_forward = 1
/sbin/sysctl net.ipv4.ip_forward
1
, then IP forwarding is enabled. If it returns a 0
, then you can turn it on manually using the following command:
/sbin/sysctl -w net.ipv4.ip_forward=1
2.6. Configuring Services on the Real Servers
httpd
for Web services or xinetd
for FTP or Telnet services.
sshd
daemon should also be installed and running.
Chapter 3. Setting Up LVS
3.1. The NAT LVS Network
- 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. The real servers pass all requests back through the LVS router so they are on their own private network.
- 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 a NAT topology, each real server only needs one NIC since it will only be responding to the LVS router. The LVS routers, on the other hand, need two NICs each to route traffic between the two networks. Because this topology creates a network bottleneck at the LVS router, gigabit Ethernet NICs can be employed on each LVS router to increase the bandwidth the LVS routers can handle. If gigabit Ethernet is employed 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.
- Software
- Because the NAT topology requires the use of
iptables
for some configurations, there can be a fair amount of software configuration outside of Piranha Configuration Tool. In particular, FTP services and the use of firewall marks requires extra manual configuration of the LVS routers to route requests properly.
3.1.1. Configuring Network Interfaces for LVS with NAT
eth0
) will be on the 192.168.26/24 network (I know, I know, this is not a routable IP, 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.11.12/24 network.
/etc/sysconfig/network-scripts/ifcfg-eth0
, could look something like this:
DEVICE=eth0 BOOTPROTO=static ONBOOT=yes IPADDR=192.168.26.9 NETMASK=255.255.255.0 GATEWAY=192.168.26.254
/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.11.12.9 NETMASK=255.255.255.0
Important
Important
3.1.2. Routing on the Real Servers
Note
/etc/sysconfig/network-scripts/ifcfg-eth0
file could look similar to this:
DEVICE=eth0 ONBOOT=yes BOOTPROTO=static IPADDR=10.11.12.1 NETMASK=255.255.255.0 GATEWAY=10.11.12.10
Warning
GATEWAY=
line, the first one to come up will get the gateway. Therefore if both eth0
and eth1
are configured and eth1
is used for LVS, the real servers may not route requests properly.
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.
3.1.3. Enabling NAT Routing on the LVS Routers
Warning
eth0:1
or eth1:1
by manually editing network scripts or using a network configuration tool. Instead, use the Piranha Configuration Tool as shown in Section 4.4, “GLOBAL SETTINGS” and Section 4.6.1, “The VIRTUAL SERVER Subsection”.
pulse
service as shown in Section 4.8, “Starting LVS”. Once pulse
is up and running, the active LVS router will begin routing requests to the pool of real servers.
3.2. LVS via Direct Routing
- Network Layout
- In a direct routing LVS setup, the LVS router needs to receive incoming requests and route them to the proper real server for processing. The real servers then need to directly route the response to the client. So, for example, if the client is on the Internet, and sends the packet through the LVS router to a real server, the real server must be able to go directly to the client via the Internet. This can be done by configuring a gateway for the real server to pass packets to 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), allowing for maximum throughput and scalability. For typical LVS setups, however, the real servers can communicate through one gateway (and therefore one network connection).
Important
It is not recommended to use the LVS router as a gateway for the real servers, as that adds unneeded setup complexity as well as network load on the LVS router, which reintroduces the network bottleneck that exists in NAT routing. - Hardware
- The hardware requirements of an LVS system using direct routing is similar to other LVS topologies. 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 real servers do not need to be Linux machines to function correctly. The LVS routers need one or two NICs each (depending on if there is a back-up router). 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.Since the real servers bypass the LVS router and send outgoing packets directly to a client, a gateway to the Internet is required. For maximum performance and availability, 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).
- Software
- There is some configuration outside of Piranha Configuration Tool that needs to be done, especially for administrators facing ARP issues when using LVS via direct routing. Refer to Section 3.2.1, “Direct Routing and
arptables_jf
” or Section 3.2.2, “Direct Routing andiptables
” for more information.
3.2.1. Direct Routing and arptables_jf
arptables_jf
, each real server must have their virtual IP address configured, so they can directly route packets. ARP requests for the VIP are ignored entirely by the real servers, 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.
arptables_jf
method, applications may bind to each individual VIP or port that the real server is servicing. For example, the arptables_jf
method allows multiple instances of Apache HTTP Server to be running bound explicitly to different VIPs on the system. There are also significant performance advantages to using arptables_jf
over the iptables
option.
arptables_jf
method, VIPs can not be configured to start on boot using standard Red Hat Enterprise Linux system configuration tools.
- 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; often this is the IP bound to
eth0
):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, 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 only node that should respond to ARP requests for any of the VIPs is the current active LVS node. - Once this has been completed on each real server, save the ARP table entries by typing the following commands on each real server:
service arptables_jf save
chkconfig --level 2345 arptables_jf on
Thechkconfig
command will cause the system to reload the arptables configuration on bootup — before the network is started. - Configure the virtual IP address on all real servers using
ifconfig
to create an IP alias. For example:#
ifconfig eth0:1 192.168.76.24 netmask 255.255.252.0 broadcast 192.168.79.255 up
Or using theiproute2
utilityip
, for example:#
ip addr add 192.168.76.24 dev eth0
As previously noted, the virtual IP addresses can not be configured to start on boot using the Red Hat system configuration tools. One way to work around this issue is to place these commands in/etc/rc.d/rc.local
. - Configure Piranha for Direct Routing. Refer to Chapter 4, Configuring the LVS Routers with Piranha Configuration Tool for more information.
3.2.2. Direct Routing and iptables
iptables
firewall rules. To configure direct routing using iptables
, you must add rules that create a transparent proxy so that a real server will service packets sent to the VIP address, even though the VIP address does not exist on the system.
iptables
method is simpler to configure than the arptables_jf
method. This method also circumvents the LVS ARP issue entirely, because the virtual IP address(es) only exist on the active LVS director.
iptables
method compared to arptables_jf
, as there is overhead in forwarding/masquerading every packet.
iptables
method. For example, it is not possible to run two separate Apache HTTP Server services bound to port 80, because both must bind to INADDR_ANY
instead of the virtual IP addresses.
iptables
method, perform the following steps:
- On each real server, run the following command for every VIP, port, 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. - Save the configuration on each real server:
#
service iptables save
#chkconfig --level 2345 iptables on
The commands above cause the system to reload theiptables
configuration on bootup — before the network is started.
3.3. Putting the Configuration Together
Important
eth0
connects to public network and eth1
connects to the private network, then these same devices on the backup LVS router must connect to the same networks.
3.3.1. General LVS Networking Tips
- Bringing Up Real Network Interfaces
- To bring up a real network interface, use the following command as root, replacing N with the number corresponding to the interface (
eth0
andeth1
)./sbin/ifup ethN
Warning
Do not use theifup
scripts to bring up any floating IP addresses you may configure using Piranha Configuration Tool (eth0:1
oreth1:1
). Use theservice
command to startpulse
instead (see Section 4.8, “Starting LVS” for details). - Bringing Down Real Network Interfaces
- To bring down a real network interface, use the following command as root, replacing N with the number corresponding to the interface (
eth0
andeth1
)./sbin/ifdown ethN
- Checking the Status of Network Interfaces
- If you need to check which network interfaces are up at any given time, type the following:
/sbin/ifconfig
To view the routing table for a machine, issue the following command:/sbin/route
3.3.1.1. Troubleshooting Virtual IP Address Issues
pulse
service is manually restarted do all virtual IP addresses activate.
echo 1 > /proc/sys/net/ipv4/conf/all/promote_secondaries
/etc/sysctl.conf
file and add the following line:
net.ipv4.conf.all.promote_secondaries = 1
3.4. Multi-port Services and LVS
iptables
, outside of Piranha Configuration Tool.
3.4.1. Assigning Firewall Marks
iptables
.
iptables
rule to assign marks to the network packets.
/sbin/service iptables status
iptables
is not running, the prompt will instantly reappear.
iptables
is active, it displays a set of rules. If rules are present, type the following command:
/sbin/service iptables stop
/etc/sysconfig/iptables
and copy any rules worth keeping to a safe place before proceeding.
/sbin/modprobe ip_tables
/sbin/iptables -t mangle -A PREROUTING -p tcp -d n.n.n.n/32 --dport 80 -j MARK --set-mark 80
/sbin/iptables -t mangle-A PREROUTING -p tcp -d n.n.n.n/32 --dport 443 -j MARK --set-mark 80
iptables
before issuing rules for the first time.
iptables
commands, n.n.n.n should be replaced with the floating IP for your HTTP and HTTPS virtual servers. 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.
Warning
3.5. Configuring FTP
3.5.1. How FTP Works
- Active Connections
- When an active connection is established, the server opens a data connection to the client from port 20 to a high range port on the client machine. All data from the server is then passed over this connection.
- Passive Connections
- When a passive connection is established, the client asks the FTP server to establish a passive connection port, which can be on any port higher than 10,000. The server then binds to this high-numbered port for this particular session and relays that port number back to the client. The client then opens the newly bound port for the data connection. Each data request the client makes results in a separate data connection. Most modern FTP clients attempt to establish a passive connection when requesting data from servers.
Note
3.5.2. How This Affects LVS Routing
3.5.3. Creating Network Packet Filter Rules
iptables
rules for FTP service, review the information in Section 3.4.1, “Assigning Firewall Marks” concerning multi-port services and techniques for checking the existing network packet filtering rules.
21
in the Firewall Mark field. See Section 4.6.1, “The VIRTUAL SERVER Subsection” for details.
3.5.3.1. Rules for Active Connections
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.n.n.0/24 --sport 20 -j MASQUERADE
iptables
command, n.n.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.
3.5.3.2. Rules for Passive Connections
Warning
/etc/vsftpd.conf
:
pasv_min_port=10000
pasv_max_port=20000
/etc/vsftpd.conf
to override the real server IP address to the VIP, which is what the client sees upon connection. For example:
pasv_address=n.n.n.n
10000:20000
in the commands below to 1024:65535
.
iptables
commands have the net effect of assigning any traffic addressed to the floating IP on the appropriate ports a firewall mark of 21, which is in turn recognized by IPVS and forwarded appropriately:
/sbin/iptables -t mangle -A PREROUTING -p tcp -d n.n.n.n/32 --dport 21 -j MARK --set-mark 21
/sbin/iptables -t mangle -A PREROUTING -p tcp -d n.n.n.n/32 --dport 10000:20000 -j MARK --set-mark 21
iptables
commands, n.n.n.n should be replaced with the floating IP for the FTP virtual server defined in the VIRTUAL SERVER subsection of Piranha Configuration Tool.
Warning
3.6. Saving Network Packet Filter Settings
iptables
, type the following command:
/sbin/service iptables save
/etc/sysconfig/iptables
so they can be recalled at boot time.
/sbin/service
command to start, stop, and check the status (using the status switch) of iptables
. The /sbin/service
will automatically load the appropriate module for you. For an example of how to use the /sbin/service
command, see Section 2.3, “Starting the Piranha Configuration Tool Service”.
Chapter 4. Configuring the LVS Routers with Piranha Configuration Tool
/etc/sysconfig/ha/lvs.cf
. This chapter describes the basic operation of the Piranha Configuration Tool and how to activate LVS once configuration is complete.
Important
lvs.cf
and therefore prevent software failures.
4.1. Necessary Software
piranha-gui
service must be running on the primary LVS router to use the Piranha Configuration Tool. To configure LVS, you minimally need a text-only Web browser, such as links
. If you are accessing the LVS router from another machine, you also need an ssh
connection to the primary LVS router as the root user.
ssh
connection in a terminal window. This connection provides a secure way to restart pulse
and other services, configure network packet filters, and monitor /var/log/messages
during trouble shooting.
4.2. Logging Into the Piranha Configuration Tool
piranha-gui
service is running and an administrative password has been set, as described in Section 2.2, “Setting a Password for the Piranha Configuration Tool”.
http://localhost:3636
in a Web browser to access the Piranha Configuration Tool. Otherwise, type in the hostname or real IP address for the server followed by :3636
. Once the browser connects, you will see the screen shown in Figure 4.1, “The Welcome Panel”.

Figure 4.1. The Welcome Panel
piranha
for the Username and the administrative password you created in the Password field.
4.3. CONTROL/MONITORING
pulse
daemon, the LVS routing table, and the LVS-spawned nanny
processes.
Note

Figure 4.2. The CONTROL/MONITORING Panel
- Auto update
- The status display on this page can be updated automatically at a user configurable interval. To enable this feature, 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).It is not recommended that you set the automatic update to an interval less than 10 seconds. Doing so may make it difficult to reconfigure the Auto update interval because the page will update too frequently. If you encounter this issue, simply click on another panel and then back on CONTROL/MONITORING.The Auto update feature does not work with all browsers, such as Mozilla.
- Update information now
- You can manually update the status information manually by clicking this button.
- 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.
4.4. GLOBAL SETTINGS

Figure 4.3. The GLOBAL SETTINGS Panel
- Primary server public IP
- In this field, enter the publicly routable real IP address for the primary LVS node.
- Primary server private IP
- Enter the real IP address for an alternative network interface on the primary LVS node. 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.1.1, “Configuring Network Interfaces for LVS with NAT”. You may leave this field blank, 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.
Note
The private IP address is not needed for Direct Routing configurations, as all real servers as well as the LVS directors share the same virtual IP addresses and should have the same IP route configuration.Note
The primary LVS router's private IP can be configured on any interface that accepts TCP/IP, whether it be an Ethernet adapter or a serial port. - Use network type
- Click the NAT button to select NAT routing.Click the Direct Routing button to select direct routing.
- NAT Router IP
- Enter the private floating IP in this text field. This floating IP should be used as the gateway for the real servers.
- NAT Router netmask
- If the NAT router's floating IP needs a particular netmask, select it from drop-down list.
- NAT Router device
- Use this text field to define the device name of the network interface for the floating IP address, such as
eth1:1
.Note
You should alias the NAT floating IP address to the Ethernet interface connected to the private network. In this example, the private network is on theeth1
interface, soeth1:1
is the floating IP address.
Warning
4.5. REDUNDANCY
Note

Figure 4.4. The REDUNDANCY Panel
- Redundant server public IP
- Enter the public real IP address for the backup LVS router node.
- Redundant server private IP
- Enter the backup node's private real IP address in this text field.If you do not see the field called Redundant server private IP, go back to the GLOBAL SETTINGS panel and enter a Primary server private IP address and click ACCEPT.
- 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.
- Assume dead after (seconds)
- If the primary LVS node does not respond after this number of seconds, 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 default is set to 539 if this field is left blank.
Warning
4.6. VIRTUAL SERVERS

Figure 4.5. The VIRTUAL SERVERS Panel
4.6.1. The VIRTUAL SERVER Subsection

Figure 4.6. The VIRTUAL SERVERS Subsection
- Name
- Enter a descriptive name to identify the virtual server. This name is not the hostname for the machine, so make it descriptive and easily identifiable. You can even reference the protocol used by the virtual server, such as HTTP.
- Application port
- Enter the port number through which the service application will listen. Since this example is for HTTP services, port 80 is used.
- Protocol
- Choose between UDP and TCP in the drop-down menu. Web servers typically communicate via the TCP protocol, so this is selected in the example above.
- Virtual IP Address
- Enter the virtual server's floating IP address in this text field.
- Virtual IP Network Mask
- Set the netmask for this virtual server with the drop-down menu.
- 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, but related protocols. In this example, 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. When combined with persistence, this technique will ensure users accessing both insecure and secure webpages are routed to the same real server, preserving state.
Warning
Entering a firewall mark in this field allows IPVS to recognize that packets bearing this firewall mark are treated the same, but you must perform further configuration outside of the Piranha Configuration Tool to actually assign the firewall marks. See Section 3.4, “Multi-port Services and LVS” for instructions on creating multi-port services and Section 3.5, “Configuring FTP” for creating a highly available FTP virtual server. - Device
- Enter the name of the network device to which you want the floating IP address defined the Virtual IP Address field to bind.You should alias the public floating IP address to the Ethernet interface connected to the public network. In this example, the public network is on the
eth0
interface, soeth0:1
should be entered as the device name.
- Re-entry Time
- Enter an integer value which defines the length of time, in seconds, before the active LVS router attempts to bring a real server back into the pool after a failure.
- Service Timeout
- Enter an integer value which defines the length of time, in seconds, before a real server is considered dead and removed from the pool.
- Quiesce server
- When the Quiesce server radio button is selected, anytime a new real server node comes online, 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. This option prevents the a new server from becoming bogged down with a high number of connections upon entering the pool.
- Load monitoring tool
- The LVS router can monitor the load on the various real servers by using either
rup
orruptime
. If you selectrup
from the drop-down menu, each real server must run therstatd
service. If you selectruptime
, each real server must run therwhod
service.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. Also, if you use load monitoring, the real servers must be Linux machines. - Scheduling
- Select your preferred scheduling algorithm from the drop-down menu. The default is
Weighted least-connection
. For more information on scheduling algorithms, see Section 1.3.1, “Scheduling Algorithms”. - Persistence
- If an administrator needs persistent connections to the virtual server during client transactions, enter the number of seconds of inactivity allowed to lapse before a connection times out in this text field.
Important
If you entered a value in the Firewall Mark field above, you should enter a value for persistence as well. Also, be sure that if you use firewall marks and persistence together, that the amount of persistence is the same for each virtual server with the firewall mark. For more on persistence and firewall marks, refer to Section 1.5, “Persistence and Firewall Marks”. - Persistence Network Mask
- To limit persistence to particular subnet, select the appropriate network mask from the drop-down menu.
Note
Before the advent of firewall marks, persistence limited by subnet was a crude way of bundling connections. Now, it is best to use persistence in relation to firewall marks to achieve the same result.
Warning
4.6.2. REAL SERVER Subsection

Figure 4.7. The REAL SERVER Subsection

Figure 4.8. The REAL SERVER Configuration Panel
- Name
- A descriptive name for the real server.
Note
This name is not the hostname for the machine, so make it descriptive and easily identifiable. - Address
- The real server's IP address. Since the listening port is already specified for the associated virtual server, do not add a port number.
- Weight
- An integer value indicating this host's capacity relative to that of other hosts in the pool. The value can be arbitrary, but treat it as a ratio in relation to other real servers in the pool. For more on server weight, see Section 1.3.2, “Server Weight and Scheduling”.
Warning
4.6.3. EDIT MONITORING SCRIPTS Subsection

Figure 4.9. The EDIT MONITORING SCRIPTS Subsection
- Sending Program
- For more advanced service verification, you can use this field to specify the path to a service-checking script. This functionality is especially helpful for services that require dynamically changing data, such as HTTPS or SSL.To use this functionality, you must write a script that returns a textual response, set it to be executable, and type the path to it in the Sending Program field.
Note
To ensure that each server in the real server pool is checked, use the special token%h
after the path to the script in the Sending Program field. This token is replaced with each real server's IP address as the script is called by thenanny
daemon.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.com @$1 | grep -c dns.example.com if [ $TEST != "1" ]; then echo "OK else echo "FAIL" fi
Note
If an external program is entered in the Sending Program field, then the Send field is ignored. - Send
- Enter a string for the
nanny
daemon to send to each real server in this field. By default the send field is completed for HTTP. You can alter this value depending on your needs. If you leave this field blank, thenanny
daemon attempts to open the port and assume the service is running if it succeeds.Only one send sequence is allowed in this field, and it can only contain printable, ASCII characters as well as the following escape characters:- \n for new line.
- \r for carriage return.
- \t for tab.
- \ to escape the next character which follows it.
- Expect
- Enter a the textual response the server should return if it is functioning properly. If you wrote your own sending program, enter the response you told it to send if it was successful.
Note
To determine what to send for a given service, you can open atelnet
connection to the port on a real server and see what is returned. For instance, FTP reports 220 upon connecting, so could enterquit
in the Send field and220
in the Expect field.
Warning
4.7. Synchronizing Configuration Files
/etc/sysconfig/ha/lvs.cf
— the configuration file for the LVS routers./etc/sysctl
— the configuration file that, among other things, turns on packet forwarding in the kernel./etc/sysconfig/iptables
— If you are using firewall marks, you should synchronize one of these files based on which network packet filter you are using.
Important
/etc/sysctl.conf
and /etc/sysconfig/iptables
files do not change when you configure LVS using the Piranha Configuration Tool.
4.7.1. Synchronizing lvs.cf
/etc/sysconfig/ha/lvs.cf
, is created or updated, you must copy it to the backup LVS router node.
Warning
lvs.cf
files. Mismatched LVS configuration files between the LVS router nodes can prevent failover.
scp
command.
Important
scp
the sshd
must be running on the backup router, see Section 2.1, “Configuring Services on the LVS Routers” for details on how to properly configure the necessary services on the LVS routers.
lvs.cf
files between the router nodes:
scp /etc/sysconfig/ha/lvs.cf n.n.n.n:/etc/sysconfig/ha/lvs.cf
4.7.2. Synchronizing sysctl
sysctl
file is only modified once in most situations. This file is read at boot time and tells the kernel to turn on packet forwarding.
Important
4.7.3. Synchronizing Network Packet Filtering Rules
iptables
, you will need to synchronize the appropriate configuration file on the backup LVS router.
scp /etc/sysconfig/iptables n.n.n.n:/etc/sysconfig/
ssh
session to the backup router or log into the machine as root and type the following command:
/sbin/service iptables restart
4.8. Starting LVS
ssh
sessions to the primary LVS router.
tail -f /var/log/messages
/sbin/service pulse start
pulse
service's startup in the terminal with the kernel log messages. When you see the following output, the pulse daemon has started properly:
gratuitous lvs arps finished
/var/log/messages
, type Ctrl+c.
Appendix A. Using LVS with Red Hat Cluster

Figure A.1. LVS with a Red Hat Cluster
- First tier — LVS routers performing load-balancing to distribute Web requests.
- Second tier — A set of Web servers to serve the requests.
- Third tier — A Red Hat Cluster to serve data to the Web servers.
Appendix B. Revision History
Revision History | ||||
---|---|---|---|---|
Revision 1-7 | Mon Sep 8 2014 | Steven Levine | ||
| ||||
Revision 1-4 | Mon Jul 07 2014 | John Ha | ||
| ||||
Revision 1-1 | Mon Feb 08 2010 | Paul Kennedy | ||
| ||||
Revision 1-0 | Tue Jan 20 2009 | Paul Kennedy | ||
|
Index
Symbols
- /etc/sysconfig/ha/lvs.cf file, /etc/sysconfig/ha/lvs.cf
A
- arptables_jf, Direct Routing and arptables_jf
C
- chkconfig, Configuring Services on the LVS Routers
- cluster
- using LVS with Red Hat Cluster, Using LVS with Red Hat Cluster
- components
- of LVS, LVS Components
D
- direct routing
- and arptables_jf, Direct Routing and arptables_jf
F
- feedback, Feedback
- FTP, Configuring FTP
- (see also LVS)
I
- introduction, Introduction
- other Red Hat Enterprise Linux documents, Introduction
- iptables , Configuring Services on the LVS Routers
- ipvsadm program, ipvsadm
J
- job scheduling, LVS, LVS Scheduling Overview
L
- least connections (see job scheduling, LVS)
- LVS
- /etc/sysconfig/ha/lvs.cf file, /etc/sysconfig/ha/lvs.cf
- components of, LVS Components
- daemon, lvs
- date replication, real servers, Data Replication and Data Sharing Between Real Servers
- direct routing
- and arptables_jf, Direct Routing and arptables_jf
- requirements, hardware, Direct Routing, LVS via Direct Routing
- requirements, network, Direct Routing, LVS via Direct Routing
- requirements, software, Direct Routing, LVS via Direct Routing
- initial configuration, Initial LVS Configuration
- ipvsadm program, ipvsadm
- job scheduling, LVS Scheduling Overview
- lvs daemon, lvs
- LVS routers
- configuring services, Initial LVS Configuration
- necessary services, Configuring Services on the LVS Routers
- primary node, Initial LVS Configuration
- multi-port services, Multi-port Services and LVS
- FTP, Configuring FTP
- nanny daemon, nanny
- NAT routing
- enabling, Enabling NAT Routing on the LVS Routers
- requirements, hardware, The NAT LVS Network
- requirements, network, The NAT LVS Network
- requirements, software, The NAT LVS Network
- overview of, Linux Virtual Server Overview
- packet forwarding, Turning on Packet Forwarding
- Piranha Configuration Tool , Piranha Configuration Tool
- pulse daemon, pulse
- real servers, Linux Virtual Server Overview
- routing methods
- NAT, Routing Methods
- routing prerequisites, Configuring Network Interfaces for LVS with NAT
- scheduling, job, LVS Scheduling Overview
- send_arp program, send_arp
- shared data, Data Replication and Data Sharing Between Real Servers
- starting LVS, Starting LVS
- synchronizing configuration files, Synchronizing Configuration Files
- three-tier
- Red Hat Cluster Manager, A Three-Tier LVS Configuration
- using LVS with Red Hat Cluster, Using LVS with Red Hat Cluster
- lvs daemon, lvs
M
- multi-port services, Multi-port Services and LVS
- (see also LVS)
N
- nanny daemon, nanny
- NAT
- enabling, Enabling NAT Routing on the LVS Routers
- routing methods, LVS, Routing Methods
- network address translation (see NAT)
P
- packet forwarding, Turning on Packet Forwarding
- (see also LVS)
- Piranha Configuration Tool , Piranha Configuration Tool
- CONTROL/MONITORING , CONTROL/MONITORING
- EDIT MONITORING SCRIPTS Subsection, EDIT MONITORING SCRIPTS Subsection
- GLOBAL SETTINGS , GLOBAL SETTINGS
- limiting access to, Limiting Access To the Piranha Configuration Tool
- login panel, Logging Into the Piranha Configuration Tool
- necessary software, Necessary Software
- overview of, Configuring the LVS Routers with Piranha Configuration Tool
- REAL SERVER subsection, REAL SERVER Subsection
- REDUNDANCY , REDUNDANCY
- setting a password, Setting a Password for the Piranha Configuration Tool
- VIRTUAL SERVER subsection, The VIRTUAL SERVER Subsection
- Firewall Mark , The VIRTUAL SERVER Subsection
- Persistence , The VIRTUAL SERVER Subsection
- Scheduling , The VIRTUAL SERVER Subsection
- Virtual IP Address , The VIRTUAL SERVER Subsection
- VIRTUAL SERVERS , VIRTUAL SERVERS
- piranha-gui service, Configuring Services on the LVS Routers
- piranha-passwd , Setting a Password for the Piranha Configuration Tool
- pulse daemon, pulse
- pulse service, Configuring Services on the LVS Routers
R
- real servers
- configuring services, Configuring Services on the Real Servers
- Red Hat Cluster
- and LVS, Using LVS with Red Hat Cluster
- using LVS with, Using LVS with Red Hat Cluster
- round robin (see job scheduling, LVS)
- routing
- prerequisites for LVS, Configuring Network Interfaces for LVS with NAT
S
- scheduling, job (LVS), LVS Scheduling Overview
- security
- Piranha Configuration Tool , Limiting Access To the Piranha Configuration Tool
- send_arp program, send_arp
- sshd service, Configuring Services on the LVS Routers
- synchronizing configuration files, Synchronizing Configuration Files
W
- weighted least connections (see job scheduling, LVS)
- weighted round robin (see job scheduling, LVS)