# Setting up clustered samba

It is assumed tou have already installed the ctdb version of samba and also installed, configured and tested CTDB.

## Create a user account

First you need to initialise the Samba password database so that you have some user that can authenticate to the samba service.
Do this by running:

      smbpasswd -a root

Samba with clustering must use the tdbsam or ldap SAM passdb backends (it must not use the default smbpasswd backend), or must be configured to be a member of a domain.
The rest of the configuration of Samba is exactly as it is done on a normal system.
See the docs on http://samba.org/ for details.

## Critical smb.conf parameters

A clustered Samba install must set some specific configuration parameters

      clustering = yes
      idmap backend = tdb2
      private dir = /a/directory/on/your/cluster/filesystem

It is vital that the private directory is on shared storage.

## Using smbcontrol

You can check for connectivity to the smbd daemons on each node using smbcontrol

      smbcontrol smbd ping

## Using Samba4 smbtorture

The Samba4 version of smbtorture has several tests that can be used to benchmark a CIFS cluster.
You can download Samba4 like this:

      svn co svn://svnanon.samba.org/samba/branches/SAMBA_4_0

Then configure and compile it as usual.
The particular tests that are helpful for cluster benchmarking are the RAW-BENCH-OPEN, RAW-BENCH-LOCK and BENCH-NBENCH tests.
These tests take a unclist that allows you to spread the workload out over more than one node. For example:

      smbtorture //localhost/data -Uuser%password  RAW-BENCH-LOCK --unclist=unclist.txt --num-progs=32 -t60

The file unclist.txt should contain a list of server names in your cluster prefixed by //. For example

     //192.168.1.1
     //192.168.1.2
     //192.168.2.1
     //192.168.2.2

For NBENCH testing you need a client.txt file.
A suitable file can be found in the dbench distribution at http://samba.org/ftp/tridge/dbench/

### CTDB_MANAGES_SAMBA

This is a parameter in /etc/sysconfig/ctdb
When this parameter is set to "yes" CTDB will start/stop/restart the local samba daemon as the cluster configuration changes.
When this parameter is set you should also make sure that samba is NOT started by default by the linux system when it boots, e.g.

      chkconfig smb off

on a Redhat system and

      chkconfig smb off
      chkconfig nmb off

on a SuSE system. Example:

      CTDB_MANAGES_SAMBA="yes"

It is strongly recommended that you set this parameter to "yes" if you intend to use clustered samba.

### CTDB_MANAGES_WINBIND

This is a parameter in /etc/sysconfig/ctdb
When this parameter is set to "yes" CTDB will start/stop/restart the local winbind daemon as the cluster configuration changes.
When this parameter is set you should also make sure that winbind is NOT started by default by the linux system when it boots:

      chkconfig winbind off

Example:

      CTDB_MANAGES_WINBIND="yes"

It is strongly recommended that you set this parameter to "yes" if you intend to use clustered samba in DOMAIN or ADS security mode.