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

[global]

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

[public]
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 samba.org::ftp/unpacked/ctdb .
cd ctdb/

Then we can compile it:

cd /usr/src/ctdb/
./autogen.sh
./configure
make
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

CTDB_RECOVERY_LOCK="/dadoscluster/ctdb/storage"
CTDB_PUBLIC_INTERFACE=eth0
CTDB_PUBLIC_ADDRESSES=/etc/ctdb/public_addresses
CTDB_MANAGES_SAMBA=yes
ulimit -n 10000
CTDB_NODES=/etc/ctdb/nodes
CTDB_LOGFILE=/var/log/log.ctdb
CTDB_DEBUGLEVEL=2
CTDB_PUBLIC_NETWORK="10.0.0.0/24"
CTDB_PUBLIC_GATEWAY="10.0.0.9" 

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

vi /etc/ctdb/public_addresses

10.0.0.183/24
10.0.0.184/24

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

vi /etc/ctdb/nodes

10.0.0.181
10.0.0.182

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

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

#!/bin/sh

. /etc/ctdb/functions
loadconfig ctdb

cmd="$1"
shift

case $cmd in
    takeip)
         # 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
         ;;
esac

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

 

References

CTDB: http://ctdb.samba.org/
CTDB: http://wiki.samba.org/index.php/CTDB_Setup#RedHat_GFS_filesystem
Howto: http://jun.homeunix.com/skills/server/GFS.DRBD8.CTDB.SAMBA.CentOS.txt

Share this page:

2 Comment(s)

Add comment

Comments

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


:D

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 node1.clustersmb.int {

    device     /dev/drbd0;

    disk       /dev/sdb;

    address    172.16.0.1:7788;

    meta-disk  internal;

  }


  on node2.clustersmb.int {

    device     /dev/drbd0;

    disk       /dev/sdb;

    address    172.16.0.1:7788;      # here address of node1 or node2?

    meta-disk  internal;

  }

}