ctdb.samba.org

Welcome to CTDB

CTDB is a cluster implementation of the TDB database used by Samba and a number of other projects to store temporary data. If an application already uses TDB, it's relatively straightforward to make it cluster-aware and switch it to CTDB instead.

CTDB provides the same functionality as TDB, but spread across multiple physical hosts in a cluster — with consistent data and consistent locking across all nodes.

Its most important use case to this day is clustered Samba: CTDB is the component that makes "pCIFS" (parallel CIFS) possible, serving the same file share in a highly available way from multiple nodes simultaneously.

Current Status

CTDB has not been maintained as a standalone release with its own version number for several years. It's developed, tested, and shipped directly inside the samba.git repository alongside the rest of the Samba source. Anyone using CTDB today typically installs it as part of a regular Samba package (e.g. the distribution's ctdb or samba-ctdb package).

Terminology update: in current CTDB versions, the node that coordinates privileged operations such as database recovery and IP failover is officially called the leader (previously: recovery master/recmaster). Likewise, the lock used to elect the leader and prevent split-brain is now called the cluster lock (previously: recovery lock/reclock). The older terms still appear in documentation and code for compatibility reasons.

Features

  • Consistent data and consistent locking for a TDB across all nodes in a cluster.
  • Very low latency thanks to local copies of the database on each node.
  • Automatic detection of node failures and automatic recovery/rebuild of all managed TDB databases.
  • Core component enabling pCIFS ("parallel CIFS") with Samba.
  • HA features such as node monitoring, node failover, and IP takeover.
  • A reliable messaging transport between application instances running on different cluster nodes.
  • TCP as the transport backend.
  • Application-specific management scripts for services that depend on network or filesystem resources.

Requirements

CTDB relies on a clustered filesystem that is mounted and available on all nodes participating in the CTDB cluster. On top of that, CTDB provides the HA features needed to export data from the clustered filesystem through multiple nodes via Samba, NFS, or FTP. Support for additional service types can be added via custom management scripts.

High Availability in Detail

The nodes in a CTDB cluster elect one node as the leader through an election process. If that node fails, a new election is triggered immediately so a leader is always available. The leader continuously monitors whether all nodes have a consistent configuration and view of the cluster, and initiates a recovery when needed.

During the recovery phase, all clustered TDB databases are rebuilt or repaired to ensure consistency. Recovery typically takes 1–3 seconds; during that time the databases are "frozen" and all database I/O operations from CTDB clients are suspended.

Is CTDB a HA solution?

Yes and no. CTDB alone is not a complete HA solution — combined with a clustered filesystem, it becomes one. CTDB deliberately relies on that external component for split-brain avoidance and other core clustering tasks. When a clustered filesystem is available on all nodes, CTDB provides an easy-to-install and easy-to-manage HA solution on top of it.

IP Takeover

If a node fails, a different node takes over its IP address so that the services provided remain reachable. To speed up takeover, CTDB automatically sends gratuitous ARP packets and "tickle ACK" packets to attached clients, prompting them to immediately re-establish the TCP connection instead of waiting for TCP retransmission timeouts.

TDB is a very fast, simple database originally developed for Samba. Today numerous other projects use TDB to store their data. See tdb.samba.org for details on how TDB works.

Documentation

The most detailed documentation on installing and configuring CTDB is available in the CTDB Wiki. Manual pages are available under Documentation, including ctdb(7), ctdbd(1), and ctdb-tunables(7).

Discussion & Bug Reports

For discussions, please use the Samba mailing lists (samba for general discussions, samba-technical for developer discussions). To report a bug, please use Samba Bugzilla.

We're happy to hear from other projects that want to make their services cluster-aware using CTDB.

Read the original on ctdb.samba.org ↗