Setting up a file server cluster with Samba and CTDB

The Toolbox

The CTDB package supplies two useful programs, ctdb and onnode, along with the daemon ctdbd. The ctdb tool is the client interface for CTDB cluster management. The most frequently used command is bound to be ctdb status, which outputs the general status of the cluster (Figure 2). The ctdb ip command shows the distribution of public IP addresses over the nodes (Figure 3). ctdb lets the admin trigger actions in the cluster, such as enabling or disabling individual nodes, adding or removing public IPs, forcing a recovery, or applying various tweaks. See the CTDB man page [24] for more information.

Figure 2: The popular ctdb status command outputs the cluster status.
Figure 3: ctdb ip tells the admin how public IP addresses are distributed among the servers.

The onnode script is a very useful tool that lets you run commands on one or multiple nodes:

onnode node[,node...] Kommando

onnode gleans the node details from the /etc/ctdb/nodes file. The target can be one or multiple node numbers or a numeric range. Also all nodes (all), connected nodes (con), healthy nodes (ok), and the recovery master (rm) have symbolic names. onnode uses SSH to establish connections to the nodes; password-less SSH logins are thus a good idea on the internal CTDB network.

Using onnode, the admin can easily roll out service configuration files on the nodes or install the same software package after storing the data on the cluster filesystem beforehand:

onnode all cp /shared/smb.conf /etc/samba/smb.conf

Because onnode only needs to reference the nodes file, you can use it to launch ctdbd on all or selected nodes:

onnode 0,2-5 service ctdb start

For more, see the onnode man page [25].


To guarantee trouble-free monitoring and failover operations in CTDB, it is important not to use the interfaces or bind interfaces only configuration parameters to restrict the IP addresses or network interfaces you want Samba to listen on. Samba service monitoring requires Samba to listen on the wildcard address,, or :: for IPv6.

Listing 2 shows an example of a Samba configuration file that the admin would distribute to all the nodes in the cluster. The smbstatus shows the connections for all nodes in the cluster. To do so, it not only lists the process IDs of the smbd processes, but outputs their node number prefixes (Figure 4). Similarly, admins can influence the Samba daemons throughout the cluster using smbcontrol.

Listing 2

smb.conf for a Cluster


Figure 4: The smbstatus command shows the connections for all nodes in the cluster.

When running a Samba cluster, it doesn't make any sense to run the NetBIOS name service, nmbd, on multiple nodes – the broadcast would just suffer from a split personality. Also, the WINS service is not cluster-capable because Samba does not handle the wins.dat database with CTDB.


For the first time, and conditional on a freely available clustering filesystem that passes the ping-pong test, Samba 3.3 in combination with CTDB offers a highly scalable CIFS cluster that is easily installable for production use without the need for patches and workarounds. After the basic setup, registry-based configuration and the onnode script make managing the cluster a pleasant task. Read on for more on Samba's new registry configuration system.


  1. Samba project:
  2. Samba team:
  3. Samba Team Receives Microsoft Protocol Documentation:
  4. CTDB project:
  5. File locking principles:
  6. TDB:
  7. Ronnie Sahlberg's CTDB repository: git://
  8. Samba & clustering:
  9. "Clustered Samba" by Andrew Tridgell and Ronnie Sahlberg at, 2008,
  10. Samba via Git:
  11. Web interface for Samba's Git repository:
  12. Git repository mirror:
  13. CTDB RPMs for RHEL:
  14. CTDB RPMs for other distributions:
  15. ping_pong.c:
  16. Ping-pong:
  17. IBM General Parallel File System:
  18. Red Hat Global File System:
  19. GlusterFS (GNU Cluster File System):
  20. Lustre File System:
  21. Oracle Cluster File System (OCFS2):
  22. OCFS2 mailing list posting on Posix fcntl() locking support:
  23. CTDB setup:
  24. CTDB man page:
  25. onnode man page:

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Samba's Registry

    Samba's new registry-based configuration system conserves resources and lets the administrator configure entire clusters with a single command.

  • Samba 4

    Samba 4 has been around for more than three years, but some users still shy from it. If you are still sitting on the fence, this tour through some of the new features and capabilities might help you decide whether it is finally time to upgrade.

  • Samba 3.2 With IPv6, Clustering and GPLv3

    The free Samba project has just released version 3.2 of the file and printer server for Microsoft Windows clients. The team will be moving to the GPL v3 license as of this version.

  • Samba 4

    Since the release of the final version, Samba 4 has become increasingly significant in IT practice; now it has found its way into Jessie, the next Debian release. We take a look at the new features.

  • Samba 4

    A technical preview version of Samba 4 became available at the end of January. We took a look at what’s coming in the next version of the Samba file and print service suite.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More