Setting Up A Standalone Storage Server With GlusterFS And Samba On Debian Squeeze

Version 1.0
Author: Piotr Opara < piotr [dot] opara [at] gmail [dot] com >
Last edited 14/20/2012

This tutorial shows how to set up a standalone storage server on Debian 6.0, using GlusterFS and SAMBA, and custom scripts and settings to make life easier ;)

I do not issue any guarantee that this will work for you!

I do not issue any guarantee that you will understand my poor english ;)

 

1 Preliminary Note

Tutorial is based on Falko Timme article.

Linux Distribution:

I?m using the Debian 6.0 (Squeeze) distribution. The installation of the Debian is very simple, so I?m not going to explain it. Just remember that you'll need to have a disk or partition exclusive to data.

Network:

In this tutorial I use three systems, a two storage nodes and a windows client:

  • node1.example.com: IP address 192.168.20.106
  • node2.example.com: IP address 192.168.20.107
  • MS Windows client: IP address 192.168.20.7


2 Preparing The Nodes

We have to make sure, that both nodes are up to date and have installed SSH and other software that we like or need.

node1/node2

apt-get update

apt-get install mc ssh

We need to be sure, that both nodes should be able to resolve the other system's hostname:

node1/node2

vi /etc/hosts

127.0.0.1    localhost
192.168.20.106    node1.example.com    node1
192.168.20.107    node2.example.com    node2

 

Checking All Settings

node1

ping -c 1 node2

PING node2.example.com (192.168.20.107) 56(84) bytes of data.
64 bytes from node2.example.com (192.168.20.107): icmp_req=1 ttl=64 time=0.818 ms

--- node2.example.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.818/0.818/0.818/0.000 ms

node2

ping -c 1 node1

PING node1.example.com (192.168.20.106) 56(84) bytes of data.
64 bytes from node1.example.com (192.168.20.106): icmp_req=1 ttl=64 time=0.802 ms

--- node1.example.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.802/0.802/0.802/0.000 ms

 

3 Setting Up The Data Disks

On both nodes we have exclusive disk, we need to set them up:

node1/node2

fdisk /dev/sdb

Command (m for help): <-- n
Command action
  e   extended
  p   primary partition (1-4) <-- p
Partition number (1-4, default 1): <-- 1
First sector (1-1305, default 1): <-- ENTER
Using default value 1 Last sector, +sectors or +size{K,M,G} (1-1305, default 1305): <-- ENTER
Using default value 1305

Command (m for help): <-- t
Selected partition 1
Hex code (type L to list codes): <-- 83
Command (m for help): <-- w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

Now run

fdisk -l

and you should find /dev/sdb1 in the output on both nodes:

Device Boot Start End Blocks Id System
/dev/sdb1 1 1305 10482381 83 Linux

Now we create a filesystem on /dev/sdb1, and mount the /dev/sdb1 to /data directory

node1/node2

mkfs.ext3 /dev/sdb1
mkdir /data/
vi /etc/fstab

... 
/dev/sdb1 /data ext3 defaults 0 0
...

Now run

mount -a

After that, you should find the share in the outputs of

df -h

/dev/sdb1 9,9G 151M 9,2G 2% /data

mount

/dev/sdb1 on /data type ext3 (rw)

Share this page:

3 Comment(s)

Add comment

Comments

From: Piotr Opara at: 2013-01-30 19:37:31

Yes You have right, from the point of view of Windows users it is much easier,  and more comfortable to use only one IP address or hostname like You said. And I'm sure that there is more options to do that, for example - CTDB or Heartbeat. But in my case, I had reason to not use virtual IP. In my real system, nodes of cluster are in different locations, i mean two branches in different ends of city. There are different subnets and nodes are connected together via IPsec VPN. That's the reason, why I didn't use VIP. I schould said it in my article, then it would be clear. Thank's for suggestion to use UCARP. I didn't know that before, so I have to try it :)

From: Murgulet Iulian at: 2013-01-30 08:07:52

From point of view of Windows clients, the following setup is better(in my oppinion):

- you can use ucarp(http://www.pureftpd.org/project/ucarp): UCARP allows a couple of hosts to share common virtual IP addresses in order to provide automatic failover.

- the 2 servers(one nod is master, and the second is slave/backup) will share a VIP(cluster IP);

- on VIP up or down, ucarp it is capabile to run some scripts(in this case /etc/init.d/samba start on ucarp interface is up, and /etc/init.d/samba stop on ucarp interface is down);

- in  /etc/samba/smb.conf you can declare that the samba can use only localhost and ucarp(VIP) interfecaces;

  In this way, at any time you have only one samba daemon up(it is good for Windows browsing list, and you can use netbios name, \\CLUSTER) on the node where you have VIP(ucarp interface)  up. In case of problemens(on master node, who has ucarp up), ucarp begin to proceed(takeover) to stop samba, move the VIP on second nod, and start the samba (on second node). The takeover process complete in almost 5 seconds.

    The second improvment of this setup if you use ucarp, it is that you can extend the samba functions with: master domain, wins server, and so on. For master domain it is necessary to keep sa same SIDs on both samba(keep the /var/lib/samba on top of glusterfs).  

Have a nice ... cluster with samba, glusterfs and ucarp

 

From: Mihai at: 2013-01-30 22:00:58

True, i was thinking as you at ucarp. Maybe in addition ... one can use monit to monitor the sambe process (it may happen that the server is up, but samba is no longer responding) and restart the daemon in case it is not responding.

 Nice tutorial!