Search This Blog

Tuesday, December 17, 2013

Shared Storage with OCFS2

Hi Friends,
How is it going ? Well today i am here to share with you how to share your shared storage (SAN in shared mode or shared iscsi lun ) across multiple nodes. Here we go

Do these steps on all nodes you wish to have shared storage

Step 1: Install ocfs2 tools on each of the nodes. Lets me assume you have debian based distro. Use relative commands for other distro

# apt-get install ocfs2-tools ocfs2console

Step 2: Edit default configuration file and enable O2CB

# vi /etc/default/o2cb


O2CB_ENABLED = false



Step 3: Create the clustering configuration

# vi /etc/ocfs2/cluster.conf

Add these contents

        ip_port = 7777
        ip_address = <node 1 ip>
        number = 1
        name = <node 1 host name>
        cluster = ocfs2
        ip_port = 7777
        ip_address = <node 2 ip>
        number = 2
        name = <node 2 host name>
        cluster = ocfs2
        node_count = 2
        name = ocfs2

        <node # ip> is the node ip
        <node # host name> is the host name of node

I have assumed that my cluster consists of 2 nodes. If there are more nodes add more node parameter group and change node_count = <total of nodes in the cluster>

Step 4: start or restart o2cb service

# /etc/init.d/o2cb restart

Step 5: Change vm.dirty_ratio to reduce caching of files as it would create some lag in shared cluster.

# vi /etc/sysctl.conf

Add this line to the end of file, if it does not exists anywhere in the file


Save the file and exit

Step 6: This step is performed on only one of the nodes. Here we format the file system to ocfs2 format

# mkfs.ocfs2 -b 4k -C 32k -L <any cluster name> -N <max no. of nodes> /dev/<shared device path>


# mkfs.ocfs2 -b 4k -C 32k  -L "cluster-storage" -N2 /dev/sdb1

Step 7: Perform the following steps on all nodes

# modprobe ocfs2_stackglue

Mount the shared partition on all nodes

# mount /dev/<shared device path> <mount point>


# mount /dev/sdb1 /mnt/

Step 8: Testing the shared storage

# touch <mounted location>/a

list it across all the other nodes

# ls <mounted location>

You must be able to see the shared data on all nodes :)


  1. I have a SAN ,Up to now i am not yet started to using this. i hope this procedure will help to configure and share folder from SERVER to SAN through Lun.

    Thanks Vignesh

  2. I did it but the files aren´t sync in both sides!