Introduction

OCFS2 is a cluster filesystem that allows sharing filesystems between multiple machines with fault tolerance.

This file system was initially created for Oracle databases and therefore has a locking mechanism designed for this type of application. You can use it as a file system, but the problem is that it may flush old locks after a certain period. If your idea is really to use a cluster filesystem to store files, it would be better to turn to GFS.

Installation

By default, OCFS2 is compiled as a module in the kernel. To ensure this, we can check the kernel config file:

  grep OCFS2 /boot/config-`uname -r`
  

which should return:

  CONFIG_OCFS2_FS=m
CONFIG_OCFS2_DEBUG_MASKLOG=y
  

Let’s install the necessary tools:

  aptitude install ocfs2-tools
  

Configuration

cluster.conf

Add this to the /etc/ocfs2/cluster.conf file. Be careful, it’s very picky, so include only what is strictly necessary with tabs, etc., and no superfluous lines:

  cluster:
        node_count = 2
        name = ocfs2_cluster
node:
        ip_port = 7777
        ip_address = 192.168.100.1
        number = 0
        name = zazu
        cluster = ocfs2_cluster
node:
        ip_port = 7777
        ip_address = 192.168.20.4
        number = 1
        name = shenzi
        cluster = ocfs2_cluster
  

I don’t think I need to provide many explanations, as the configuration file is clear. But here are some just in case:

  • node_count: number of nodes in the cluster

This configuration should be applied to all of your nodes.

o2cb

Now let’s edit the OCFS2 startup file:

  #
# This is a configuration file for automatic startup of the O2CB
# driver.  It is generated by running 'dpkg-reconfigure ocfs2-tools'.
# Please use that method to modify this file.
#
 
# O2CB_ENABLED: 'true' means to load the driver on boot.
O2CB_ENABLED=true
 
# O2CB_BOOTCLUSTER: If not empty, the name of a cluster to start.
O2CB_BOOTCLUSTER=ocfs2_cluster
 
# O2CB_HEARTBEAT_THRESHOLD: Iterations before a node is considered dead.
O2CB_HEARTBEAT_THRESHOLD=31
 
# O2CB_IDLE_TIMEOUT_MS: Time in ms before a network connection is considered dead.
O2CB_IDLE_TIMEOUT_MS=30000
 
# O2CB_KEEPALIVE_DELAY_MS: Max. time in ms before a keepalive packet is sent.
O2CB_KEEPALIVE_DELAY_MS=2000
 
# O2CB_RECONNECT_DELAY_MS: Min. time in ms between connection attempts.
O2CB_RECONNECT_DELAY_MS=2000
  

You just need to modify O2CB_ENABLED and O2CB_BOOTCLUSTER, indicating the name of the OCFS2 cluster.

Startup

There is a graphical tool for managing ocfs2, “ocfs2console”, but we won’t cover it here.

To properly start ocfs2 (necessary after each configuration change):

  /etc/init.d/o2cb offline ocfs2
/etc/init.d/o2cb unload
/etc/init.d/o2cb load
/etc/init.d/o2cb online ocfs2
  

For subsequent reboots:

  /etc/init.d/o2cb restart
  

Formatting

You can now format the device you want with OCFS2 using the mkfs.ocfs2 command:

  mkfs.ocfs2 /dev/drbd0
  

Now just mount this on your nodes:

  mount.ocfs2 /dev/drbd0 /mnt
  

Resources

Last updated 03 Mar 2012, 15:37 +0200. history