Configuring clustered Samba

From SambaWiki

Setting up a simple CTDB Samba cluster

As of April 2007 you can setup a simple Samba3 or Samba4 CTDB cluster, running either on loopback (with simulated nodes) or on a real cluster with TCP. This page will tell you how to get started.

Getting the code

You need two source trees, one is a copy of Samba3 with clustering patches, and the other is the ctdb code itself. Both source trees are stored in bzr repositories. See for more information on bzr.

The fastest way to checkout an initial copy of the Samba3 tree with clustering patches is:

  rsync -avz .

To update this tree when improvements are made in the upstream code do this:

   cd samba_3_0_ctdb
   bzr merge

To get an initial checkout of the ctdb code do this:

  rsync -avz .

To update this tree when improvements are made in the upstream code do this:

   cd ctdb
   bzr merge

Building the Samba3 tree

To build a copy of Samba3 with clustering and ctdb support you should do this:

   cd samba_3_0_ctdb/source
   ./configure --prefix=/gpfs0/samba/prefix --with-ctdb=/usr/src/ctdb --with-cluster-support --enable-pie=no
   make proto

You should replace the /gpfs0/samba/prefix path with the cluster shared storage path you will use to install Samba. The path should to be a directory that is the same on all nodes of the cluster. If you are setting up a virtual cluster on loopback then this can be any local directory.

The /usr/src/ctdb path should be replaced with the path to the ctdb sources that you downloaded above

Building the CTDB tree

To build a copy of the CTDB code you should do this:

  cd ctdb
  ./configure --prefix=/gpfs0/samba/prefix

Installing Samba3

To install Samba3 you should do this:

 cd samba_3_0_ctdb/source
 make install

If your path points to another version of Samba, it is recommended that you reset your path to point to the bin/ directory of this newer Samba installation (e.g. /gpfs0/samba/prefix/bin). Then you need to configure an appropriate smb.conf. There is a very simple example in samba_3_0_ctdb/examples/ctdb. You need to put this smb.conf in the lib/ subdirectory of the prefix you chose above.

Next you need to initialise the Samba password database, e.g.

 smbpasswd -a root

or if you have not reset your path to point to this newer version of Samba:

 /gpfs0/samba/prefix/bin/smbpasswd -a root

Samba with clustering must use the tdbsam or ldap SAM passdb backends (it must not use the default smbpasswd backend). The rest of the configuration of Samba is exactly as it is done on a normal system. See the docs on for details.

Cluster Configuration

The main cluster configuration file is cluster_nodes.txt in your Samba configuration directory (the lib/ subdirectory of your Samba installation prefix). This file needs to be created and should contain a list of the IP addresses of your cluster nodes.

Starting the cluster

There is an example startup script in samba_3_0_ctdb/examples/ctdb/

Loopback Setup

For testing purposes you can setup a Samba/CTDB cluster on a single computer using loopback networking. To set this up you need to do this:

- use ifconfig to create IP aliases for your loopback device for each virtual node - put the list of aliases addresses in cluster_nodes.txt

For example, you could do this:

 for i in `seq 2 4`; do
   ifconfig lo:$i 127.0.0.$i

Then you would have this in cluster_nodes.txt

Then start the cluster as above. The onnode.loop example script can be used for onnode