Adding public IP addresses
CTDB can manage a pool of public IP addresses that are distributed across nodes of a cluster. This allows CTDB to perform failover of connections and load balance between nodes. Public IP addresses allow a cluster of nodes that to function as a single multi-homed node, in nearly all respects. This allows the cluster to offer coherent services (e.g. SMB, NFS) across all nodes.
The clustering model utilises IP takeover techniques to ensure that the full set of public IP addresses assigned to services on the cluster will always be available to the clients even when some nodes have failed and become unavailable.
Alternatively, CTDB can be configured to use LVS for failover and load balancing. However, this is not as well tested as the approach described here.
CTDB configuration file
CTDB_PUBLIC_ADDRESSES configuration variable must be set in the ctdbd configuration fileto point to a public addresses file containing the public IP address configuration. This file is usually called
public_addresses and should reside in the CTDB configuration directory.
Please see ctdbd.conf(5) for more details.
Public addresses file
The file contains a list of public IP addresses, one per line, each with an optional (comma-separated) list of network interfaces that can have that address assigned. These are the addresses that clients should be configured to connect to.
192.168.1.1/24 eth1 192.168.1.2/24 eth1 192.168.2.1/24 eth2 192.168.2.2/24 eth2
If network interfaces are not specified on all lines in the public addresses file then the
CTDB_PUBLIC_INTERFACE configuration variable must be used to specify a default interface.
- The CTDB cluster utilises IP takeover techniques to ensure that all the public IP addresses will always be available to clients, as long as at least one node in the cluster is available,
- Do not manually assign the public IP addresses to interfaces on any node. CTDB will add and remove these addresses automatically at runtime.
- There is no built-in restriction on the number of IP addresses or network interfaces that can be used. However, performance limitations (e.g. time taken to calculate IP address distribution, time taken to break TCP connections and delete IPs from interfaces, ...) introduce practical limits.
- It is sensible to plan the public IP addresses so that they can be evenly redistributed across subsets of nodes. For example, a 4 node cluster will always be able to evenly distribute 12 public IP addresses (across 4, 3, 2, 1 nodes). Having IP addresses evenly balanced is not a hard requirement but evenly balancing IP addresses is the only method of load balancing used by CTDB.
- The public addresses file can differ between nodes, allowing subsets of nodes to host particular public IP addresses. Note that pathological configurations can result in undesirable IP address distribution.
ctdb ip shows the lists public IP addresses and that node that is hosting them.
# ctdb ip Public IPs on node 0 192.168.1.1 0 192.168.1.2 1 192.168.2.1 2 192.168.2.2 3
- A value of
-1for a node number indicates that an address is not currently hosted.
- This command only shows public IP addresses defined on the current node. If different groups of public IP addresses are defined on different nodes then use
ctdb ip allto show addresses defined on all nodes.
You can configure the public IP addresses to correspond to a DNS name. This can allow some clients to be configured to connect to the DNS name. Clients should then connect to different public IP addresses in a round-robin manner.