Attach a block volume to multiple Ubuntu compute instances on Oracle Cloud with cluster-aware OCFS2

WARNING!!!: This is not a tutorial. This article contains only the commands executed in the above video. For full step-by-step tutorial watch the video above!

Below you can fins all commands used in the video. IMPORTNAT: Each command must be executed on every node that will be a part of the cluster!

Open /etc/iptables/rules.v4 and add rule to open port 7777.

iptables-restore < /etc/iptables/rules.v4 – Reload iptables config file.

apt install ocfs2-tools – Install ocfs2.

uname -r – Get kernel version.

apt install linux-modules-extra-X – Instal kernel modules (make sure replace X with your kernel version number.

o2cb add-cluster ocfs2 – Create /etc/ofc2/cluster.conf file and sets cluster named ocfs2.

o2cb add-node ocfs2 NODE_NAME –ip PRIVATE_IP – Adds node to the cluster.conf run once for each node on every node.

cat /etc/ocfs2/cluster.conf – Examina cluster configuration file.

dpkg-reconfigure ocfs2-tools – Configure the cluster setings.

service o2cb start – Start the cluster.

systemctl enable o2cb – Make service start on boot.

systemctl enable ocfs2 – Make service start on boot

sysctl kernel.panic=30 – Run this to set for kernel to work properly per Oracle

sysctl kernel.panic_on_oops=1 – Run this to set for kernel to work properly per Oracle

Open /etc/sysctl.conf and append the two lines below to the end of the file.

kernel.panic=30

kernel.panic_on_oops=1

mkfs.ocfs2 -L “my_ocfs2_vol” /dev/sdb – Format your block storage.

mkdir /sharedstorage – Make mount point Add the line below to /etc/fstab per Oracle replace /dev/sdb with UUID

/dev/sdb /sharedstorage ocfs2 _netdev,defaults 0 0

blkid – Get UUID

mount -a – Reload fstab and remount everything listed in it.

o2cb register-cluster ocfs2 – Register cluster.