Configuring OCFS2 Clustered File System on Debian Based Linux including Ubuntu and Kubuntu

There's a lot of information and guides on OCFS2 for RHEL and Centos Linux but the package setup and configuration is slightly different and this has thrown some people off.

Installing OC2FS

You should install the following packages to get started:

apt-get install ocfs2-tools ocfs2console

Configure OC2FS

In RHEL/Centos the main configuration file is located in /etc/sysconfig/o2cb

However in Debian based Linux it is located in: /etc/default/o2cb (I don't think either make sense, why not just have a dir inside /etc/ called ocfs2 ?)

Open the file: /etc/default/o2cb and change the following line:

O2CB_ENABLED=false

to O2CB_ENABLED=true

This enables OCFS2 to startup at boot time (which you obviously should want if you are using such a filesystem).

Setup OC2FS cluster.conf

You'll need to manually create this path:

mkdir /etc/ocfs2

now touch /etc/ocfs2/cluster.conf

Here is the cluster.conf I created (you can have less/more nodes if you like):

node:
        ip_port = 7777
        ip_address = 192.168.1.115
        number = 1
        name = one
        cluster = ocfs2
node:
        ip_port = 7777
        ip_address = 192.168.1.116
        number = 2
        name = two
        cluster = ocfs2
cluster:
        node_count = 2
        name = ocfs2

The hostname must be correct for the node, meaning it has to be the actual hostname.

Under "cluster" that is the name you will be calling your cluster. Make sure that in /etc/default/o2cb the parameter matches (by default it is set to ocfs2 but it can be changed if you like).

Also make sure under each node that the cluster value is correct.  cluster is the name of the OCFS2 filesystem/cluster you want those nodes to belong to.

Move cluster.conf to each node (remember that each node must have the exact same cluster.conf)

Start the o2cb service: /etc/init.d/o2cb start

Loading module "configfs": OK
Mounting configfs filesystem at /sys/kernel/config: OK
Loading module "ocfs2_nodemanager": OK
Loading module "ocfs2_dlm": OK
Loading module "ocfs2_dlmfs": OK
Mounting ocfs2_dlmfs filesystem at /dlm: OK
Starting O2CB cluster ocfs2: OK

 Checking the status of o2cb should show something like this (if everything is correct):

/etc/init.d/o2cb status
Module "configfs": Loaded
Filesystem "configfs": Mounted
Module "ocfs2_nodemanager": Loaded
Module "ocfs2_dlm": Loaded
Module "ocfs2_dlmfs": Loaded
Filesystem "ocfs2_dlmfs": Mounted
Checking O2CB cluster ocfs2: Online
Heartbeat dead threshold = 7
  Network idle timeout: 10000
  Network keepalive delay: 5000
  Network reconnect delay: 2000
Checking O2CB heartbeat: Active

Format your OCFS2 partition:

mkfs.ocfs2 -b 4k -C 32K -L "MyOCFS2Cluster" -N 4 /dev/sda2

Make sure you replace "/dev/sda2" with the partition you want.  Don't make a mistake here because you'll lose all data on whatever partition you specify.

The "-N 4" stands for slots for up to 4 nodes, note that this can be increased but can't be decreased.  You shouldn't have a number higher than you need (or at least not much).  The Oracle documentation says you can always add more node slots though.

Mount your OCFS2 partition

mount /dev/sda2 /mnt/sda2

Debian/Kubuntu Error when mounting

On Kubuntu 8.04 I got this error, I'm not sure if the Debian package itself has this problem but here it goes:

mount.ocfs2: Node manager kernel module is not loaded probably because o2cb service not started

Everything is fine configuration file wise, but there is a bug in the init script provided by the Kubuntu Package.

You can fix it by: adding "load_module ocfs2_stackglue" to the LOAD_ACTIONS in /etc/init.d/o2cb

Or you can just manually modprobe ocfs2_stackglue

This is supposed to be fix in the latest package, but as of the time of this writing (April 7th, 2009) the latest package is the one I have.  I guess the udpated version hasn't been distributed yet.

Latest Articles

  • Apache/Mod_SSL not serving the right/expected certificate?2010-03-09 04:09:36
  • Create/Enable SSL Certificates for Apache on Linux/Unix Systems eg. Redhat,Centos,Debian2010-03-09 04:07:21
  • MySQL Error "ERROR 1045 (28000): Access denied for user"2010-03-06 06:35:42
  • MySQL "Got error 28 from storage engine"2010-03-06 06:32:28
  • How to Track Down/Find Cause of Linux high disk iowait/wa2010-02-19 01:41:31
  • Mysqld Solution - Can't init databases /usr/libexec/mysqld: Can't read dir of '/tmp/' (Errcode: 13) /usr/libexec/mysqld: Can't create/write to file '/tmp/ibyP1qUC' (Errcode: 13) 100215 7:02:24 InnoDB: Error: unable to create temporary file; errno:2010-02-15 07:11:17
  • Windows Vista sysprep.exe /generalize error "The computer restarted unexpectedly or encountered an unexpected error. Windows installation cannot proceed. To install Windows, click "OK" to restart the computer, and then restart the installation."2010-02-13 10:08:29
  • Openvz "Container already locked" Error Message Solution/Fix2010-02-13 09:44:14
  • Adventures in pre-paid SIM Cards and data GPRS/Edge/3G in China with China Mobile in Shenzhen, Guangzhou, Shanghai, Beijing and other cities2010-02-12 08:37:57
  • iPhone Enable Tethering Manually Update ipcc Carrier Settings/Update via SSH2010-02-08 06:03:16
  • How To Enable 3rd/third party packages in RHEL/Redhat/Centos 4/5 Linux via RPMForge2010-01-17 16:44:41
  • How to avoid web content hijacking/copying/Force content to be accessed by only 1 domain name2010-01-17 16:39:39
  • SAMBA/SMB Share "Write" Access without Delete2009-12-19 20:04:22
  • The power of passive vs air cooling. Small fans make a world of difference.2009-12-18 13:22:52
  • Hard Drive Not Working/Not Detected By Your BIOS Anymore?2009-12-12 11:29:09
  • GRUB "Error 2: Bad file or directory type" 0.97 won2009-12-09 21:25:09
  • Unixbench Score with Glusterfs/Openvz & Quad Core Xeon - Updated with GlusterFS 2.0.8 & Optimized Client Config2009-11-29 01:26:44
  • Clustered/Distributed Network Filesystems, Which Ones live up to the hype?2009-11-28 22:19:13
  • Unixbench Score with Glusterfs/Openvz & Quad Core Xeon - Updated with GlusterFS 2.0.82009-11-28 22:04:16
  • yum error not working rpmdb: mmap: No such device TypeError: rpmdb open failed2009-11-23 00:06:42