This episode takes Samba from one server to a cluster: CTDB (Clustered Trivial Database) for high availability and scale-out, how failover works via public IP, and the real-world case of a multi-node enterprise NAS with shared storage like GPFS and Ceph. You understand why SMB locking must be managed cluster-wide.

Up to episode 17, you have one great Samba server. Episode 18 answers the question that arises when one server isn't enough — or isn't allowed to die: how do you make several Samba servers work as one entity? The answer is CTDB (Clustered Trivial Database), the component that turns a group of Linux nodes into an enterprise NAS with high availability and scale-out. This is the topic that separates an ordinary file server administrator from a storage architect.
File sharing is easy to cluster as long as clients only read. The problem arises with locking: SMB lets clients lock files (oplock, byte-range lock). If two Samba nodes manage locks independently, node A doesn't know node B is locking the same file — and two clients can "believe" they each hold exclusive rights. Result: data corruption.
CTDB unifies the lock databases of all nodes into one distributed database (using record-based locking technology). Each node consults CTDB before locking; lock decisions are cluster-wide. This is exactly the analogue of a cluster file system at the SMB level — which is why CTDB is called Clustered Samba.
Public IP 192.168.10.50
|
+-------------+-------------+
| | |
node1 node2 node3
smbd+ctdb smbd+ctdb smbd+ctdb
| | |
+---- shared storage (CephFS/GPFS) ----+smbd + ctdbd and mounts shared storage (a cluster filesystem: CephFS, GPFS, GFS2, or GlusterFS).ctdbd maintains heartbeats between nodes and manages failover.The key to CTDB scale-out: all nodes see the same filesystem. There's no "file on node 1" vs "file on node 2" — there's one namespace accessed by all nodes. CTDB doesn't copy data; it only unifies locks and failover. Without shared storage, you don't have a cluster — you have several separate servers with different IPs.
[global]
workgroup = LAB
security = user
clustering = yes
idmap config * : backend = tdb
idmap config * : range = 3000-7999clustering = yes tells Samba it's running under CTDB — locking and state are moved to the cluster. All nodes must use identical configuration for consistent behavior.
public_addresses = /etc/ctdb/public_addressesThe per-node public IP list:
192.168.10.50/24 node1
192.168.10.51/24 node2sudo systemctl enable --now ctdbVerify the cluster status:
sudo ctdb status
sudo ctdb ip
sudo ctdb nodesctdb status: node list, roles (leader), and OK/DISCONNECTED status.ctdb ip: public IPs and the node actively holding each.ctdb nodes: cluster member list.Warning
CTDB is not supported for the AD DC role. AD replication is a different mechanism — adding a second DC is the way to go, not clustering (episode 9). CTDB is a solution for file servers serving many clients; don't mix these two worlds. For file serving alone, CTDB is plenty robust.
Stop one node (or sudo ctdb disable node1) and watch the IP move:
sudo ctdb ipWhen node1 goes down, its public IP is taken over by another node within seconds — clients using that IP keep running (active TCP connections may drop and must reconnect, but the service doesn't die). This is the essence of high availability: downtime measured in seconds, not hours.
CTDB scales by adding nodes (up to the storage scalability limit) — each node adds connection capacity and CPU for serving clients, while data stays in one namespace on shared storage. For a multi-node enterprise NAS:
ctdb status and each node's load (episode 20).Tip
Don't think of CTDB as "data replication". Data lives on the shared storage; what's replicated is locks and state. That means the shared storage is the critical point — make sure the storage itself is highly available (Ceph with replication, GPFS with quorum). A Samba cluster on top of a single fragile storage just moves the point of failure, not eliminates it.
clustering = yes isn't active on all nodes, or Samba versions differ.public_addresses is misformatted or heartbeats are disrupted — check ctdb status.Key takeaways:
clustering = yes in smb.conf on all nodes; ctdb status/ctdb ip for monitoring.In episode 19 next, we'll cover Samba in Docker/Kubernetes — samba images like linuxserver and dperson, mounting volumes for state, K8s StatefulSet, and the correct pattern: stateless containers with exposed services. Modernizing the deployment without losing Samba's essence!