Attach a Block Volume to Multiple Ubuntu Instances on Oracle Cloud with OCFS2
OCFS2 (Oracle Cluster File System 2) is a shared-disk cluster file system: it lets several Linux servers mount the same block volume and read and write to it at the same time. The commands below set it up on Ubuntu compute instances on Oracle Cloud, exactly as shown in the video.
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 find all commands used in the video. IMPORTANT: 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 – Install kernel modules (make sure to replace X with your kernel version number).
o2cb add-cluster ocfs2 – Create /etc/ocfs2/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 – Examine cluster configuration file.
dpkg-reconfigure ocfs2-tools – Configure the cluster settings.
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.