Setting Up An Active/Active Samba CTDB Cluster Using GFS & DRBD (CentOS 5.5) - Page 3

This article explains how to set up an Active/Active Samba CTDB Cluster, using GFS and DRBD. Prepared by Rafael Marangoni, from BRLink Servidor Linux Team.

6. Configuring Samba

The samba configuration is very common. In this article, we don't cover how to configure samba. We only explain a very simple configuration.
Do it on both nodes:

First, we need to configure /etc/samba/smb.conf on both nodes:

vi /etc/samba/smb.conf


clustering = yes
idmap backend = tdb2
private dir=/clusterdata/ctdb
fileid:mapping = fsname
use mmap = no
nt acl support = yes
ea support = yes

comment = public share
path = /clusterdata/public
public = yes
writeable = yes
only guest = yes 

We must to create the directories used by samba (only on one node):

mkdir /clusterdata/ctdb
mkdir /clusterdata/public
chmod 777 /clusterdata/public

Adding root on samba, only on one node:

smbpasswd -a root


7. Configuring CTDB

The process to install ctdb it's very simple. Do it on both nodes:

First, we need to download it:

cd /usr/src
rsync -avz .
cd ctdb/

Then we can compile it:

cd /usr/src/ctdb/
make install

Creating the init scripts and config links to /etc:

cp config/ctdb.sysconfig /etc/sysconfig/ctdb
cp config/ctdb.init /etc/rc.d/init.d/ctdb
chmod +x /etc/init.d/ctdb

ln -s /usr/local/etc/ctdb/ /etc/ctdb
ln -s /usr/local/bin/ctdb /usr/bin/ctdb
ln -s /usr/local/sbin/ctdbd /usr/sbin/ctdbd

Next, we need to config /etc/sysconfig/ctdb on both nodes:

vi /etc/sysconfig/ctdb

ulimit -n 10000

Now, config /etc/ctdb/public_addresses on both nodes:

vi /etc/ctdb/public_addresses

Then, config /etc/ctdb/nodes on both nodes:

vi /etc/ctdb/nodes

Then, config /etc/ctdb/events.d/11.route on both nodes:

vi /etc/ctdb/events.d/11.route


. /etc/ctdb/functions
loadconfig ctdb


case $cmd in
         # we ignore errors from this, as the route might be up already when we're grabbing
         # a 2nd IP on this interface
         /sbin/ip route add $CTDB_PUBLIC_NETWORK via $CTDB_PUBLIC_GATEWAY dev $1 2> /dev/null

exit 0

Set +x permission on script:

chmod +x /etc/ctdb/events.d/11.route

Finally, we need to bring services on:

/etc/init.d/ctdb start
/etc/init.d/smb start
chkconfig --level 35 ctdb on
chkconfig --level 35 smb on




Share this page:

2 Comment(s)

Add comment


From: pb at: 2010-12-06 05:03:35

WTF?! why did you disable SELINUX?? please read /etc/samba/smb.conf for info on how to make samba play nicely. NEVER disable SELINUX, doing so is like chmod 777, yes you do make it work but... While getting your head around contexts and such may I recommend SELINUX=permissive so you can at some point re-enable it to harden your server. If you tried to do a full system relabel now you will most likely get some MASSIVE issues.

getenforce (is the system enforcing or permissive?)
setenforce 0 (set SELINUX on the fly to permissive)
setenforce 1 (set SELINUX on the fly to enforcing)
# the system will default back to what ever is defined in /etc/selinux/config upon reboot. this will NOT work if you have at any point disabled SELINUX

From Fedora's smb.conf:
chcon -R -t samba_share_t /path/to/share

all newly created files will automatically inherit the context of their parent.

you will not find the samba_share_t context listed anywhere other than smb.conf as there is no default system location for a samba share, unlike the default httpd doc root. If you were running an httpd server you can find out the needed contexts by simply:
semanage fcontext -l|grep httpd


From: chamssun at: 2011-03-24 15:10:27

vi /etc/drbd.conf

 global {

    usage-count yes;


common {

  syncer {

                rate 100M;

                al-extents 257;



resource r0 {

  protocol C;

  startup {

    become-primary-on both;              ### For Primary/Primary ###

    degr-wfc-timeout 60;

    wfc-timeout  30;


  disk {

    on-io-error   detach;


  net {

    allow-two-primaries;                 ### For Primary/Primary ###

    cram-hmac-alg sha1;

    shared-secret "mysecret";

    after-sb-0pri discard-zero-changes;

    after-sb-1pri violently-as0p;

    after-sb-2pri violently-as0p;


  on {

    device     /dev/drbd0;

    disk       /dev/sdb;


    meta-disk  internal;


  on {

    device     /dev/drbd0;

    disk       /dev/sdb;

    address;      # here address of node1 or node2?

    meta-disk  internal;