You set up and maintain an LVS cluster from the LVS routers, by editing
the configuration file and starting or restarting the
pulse daemon. Specifically, the steps are:
On the primary router, edit the configuration file
/etc/lvs.cf. This is best done using the
Piranha Web Interface, which is described in Chapter 9.
Copy the edited configuration file to the backup router.
Start (or restart) the pulse daemon; first on the
active router, then on the backup router.
You can perform these steps from the shell, by editing the configuration
file with the editor of your choice. The shell commands for starting,
restarting, and stopping the pulse daemon are:
/etc/rc.d/init.d/pulse start
/etc/rc.d/init.d/pulse restart
/etc/rc.d/init.d/pulse stop
The pulse daemon starts or restarts the other LVS
cluster daemons as needed, which obtain their configuration information,
directly or indirectly, from the current configuration file.
If you stop pulse (in order to shut down the
cluster), stop it on the backup router first. This will prevent the
backup router from initiating a failover when the active router goes
down.
Alternatively, you can use the Piranha Web Interface to configure, monitor, and
administer your LVS cluster. The entry fields on its windows set or
change lines in /etc/lvs.cf.
The next section describes the LVS cluster configuration file. Read this
section if you want to edit this file manually. If you chose to use the
Piranha Web Interface, please read Chapter 9 instead.
The /etc/lvs.cf file has three sections. The
global section, described in Table 8-3, sets up the
LVS routers and specifies networking and heartbeat parameters. There
is one set of parameters for the cluster. The per-virtual-server
section, described in Table 8-4, defines virtual
server addresses, sets up the associations between virtual servers and
real servers, and specifies job-scheduling parameters. There is a
separate set of parameters for each defined virtual server. The
per-real-server section, described in Table 8-5,
defines the real servers that will be load-balanced by each virtual
server. There is one set of these parameters for each virtual server.
Let's start with the parameters that are global.
Table 8-3. Setting Global Parameters
| Parameter | Description |
|---|
| primary = n.n.n.n
| Enter the IP address of the adapter connecting the primary LVS
router to the public network.
|
| backup = n.n.n.n
| Enter the IP address of the adapter connecting the backup
backup LVS router to the public network.
|
| heartbeat_port = n
| Enter the port number used for the heartbeat on the primary
and backup LVS routers.
|
| keepalive = n
| Enter the number of seconds between heartbeats.
|
| deadtime = n
| Enter the number of seconds to wait before declaring a
non-responding router dead and initiating failover.
|
| rsh_command =
[rsh|ssh]
| Enter the command family to use for synchronizing the
configuration files on the primary and backup
routers. Important: as described in Table 8-2, you must enable
the selected command on the primary and backup routers.
|
| network =
[nat|direct|tunnel]
| Enter the routing method to use when the LVS router contacts
the real servers. Note that you will need to make the
appropriate configuration changes to support the routing
method you choose.
|
| nat_router = n.n.n.n
ethn:n
| Enter the floating IP address and device of the NAT
router. This IP address must be the default route used by each
real server to communicate with the active LVS router. The IP
address is aliased to the device (for example,
eth1:1) connecting the LVS routers to the
private network of real servers. The device must be the same
(i.e., eth1) on both LVS routers.
|
| service =
[lvs|fos]
| Enter the type of cluster service you wish to use. To take
advantage of the features described in this chapter, you must
choose lvs.
|
The next set of parameters are repeated for each virtual server.
Table 8-4. Setting Per-Virtual-Server Parameters
| Parameter | Description |
|---|
| virtual xxx {
| Enter a unique identifier for the virtual server. Note the
brace ({) that starts this
per-virtual-server block.
|
| address =
n.n.n.n
| Enter the virtual server's IP address: a floating IP address
that has been associated with a fully-qualified domain name.
|
| active =
[0|1]
| Enable (1) or disable
(0) this server.
|
| load_monitor =
[uptime|ruptime|rup]
| Select the tool (default uptime) that will
be used by the active router to monitor the workload of real
servers. Important: as described in Table 8-2, unless you enable the selected
command on the real servers, the scheduling algorithms that
use dynamic load information will apply the assigned weight
statically rather than adjust the weight from load
information. If you select the default
(uptime), the tool you specified in the
rsh_command parameter is used to log in to
the real servers. This tool must be enabled on the real
servers.
|
| timeout = n
| Enter the number of seconds (default 10)
that must lapse before a real server determined to be dead is
removed from the routing table.
|
| reentry = n
| Enter the number of seconds (default 180)
that a restored real server must remain alive before being
re-added to the routing table.
|
| port = nnn
| Enter the listening port for this virtual server:
Typically, port 80 is used for http, and port 21 for ftp.
However, any valid port can be used.
|
| persistent = nnn
| If specified, this enables persistence and defines the timeout
(in seconds) of persistent connections. Persistence causes
multiple requests from a client to be redirected to the same
server each time (the server selected for the first
request). The timeout value of persistent sessions is
specified in seconds. The default is 300 seconds. Use this
option to solve problems with cookies, SSL, or FTP with
tunneling or direct routing.
|
| pmask =
nnn.nnn.nnn.nnn
| If persistence is enabled, this parameter allows a granularity
at which the clients are grouped. The source address of the
request is masked with this netmask to, for example, direct
all clients from a /24 network to the same real server. The
default is 255.255.255.255, which means that the persistence
granularity is per client host. Use this option to solve
problems with non-persistent cache clusters on the client
side.
|
| scheduler =
[wlc|lc|wrr|rr]
| Select the scheduling algorithm (default
wlc) for distributing jobs from this
virtual server to the real servers. The choices are described
in Table 8-1.
|
| }
| Ends the per-virtual-server-block.
|
The following parameters are repeated on a per-real-server basis.
Table 8-5. Setting Per-Real-Server Parameters
| Parameter | Description |
|---|
| server xxx {
| Enter a unique name for the real server. Note the brace
({) that starts this per-real-server
block.
|
| address =
n.n.n.n
| Enter the IP address of the real server on the private
network.
|
| active =
[0|1]
| Enable (1) or disable
(0) the real server.
|
| weight = n
| Enter an integer (default is 1) specifying
this server's processing capacity relative to that of other
real servers. For example, a server assigned a weight of 2000
has twice the capacity of a server assigned 1000. The weighted
scheduling algorithms adjust this number dynamically based on
workload.
|
| }
| Ends the per-real-server-block.
|