0

What is the simplest way to set up shared/clustered read-write POSIX-compliant filesystem across servers where performance is not a major concern?

Suppose I have two Linux servers S1 and S2 and an uninitialized (no filesystem) block device /dev/sdb.

Note: self-answered question.

otujuhxv
  • 29
  • 3
  • Maybe you should have presented this question as a [question with its answer made by the same person](https://serverfault.com/help/self-answer "Can I answer my own question?"). Because the question looks rhetorical (or not a good question by asking "for the best"). – A.B Jun 10 '23 at 07:32
  • @A.B I split my question and "answer". I am a beginner and my answer is still very complex for me. Is there no easier way? – otujuhxv Jun 10 '23 at 17:41
  • I can just tell that compared to RHEL's GFS2 where every documentation tells you have to configure corosync (and possibly pacemaker and fencing) this appears easier. – A.B Jun 10 '23 at 17:47
  • @A.B I was hoping there is a simpler way where the filesystem would simply block if there is an active write (concurrency not required). – otujuhxv Jun 10 '23 at 21:10
  • I think NFS would work for my case too. It'll be slower, but acceptable. – otujuhxv Jun 10 '23 at 22:05

1 Answers1

2

OCFS2 is POSIX-compliant and "simple" to set up, I tried it and it works:

apt-get update
apt-get install -y ocfs2-tools

# Only step that needs to be done once on any node
mkfs.ocfs2 /dev/sdb

# Hostname MUST be correct or else it doesn't work
o2cb add-cluster CLUSTER_NAME
o2cb add-node CLUSTER_NAME S1_HOSTNAME --ip S1_PRIVATE_IP
o2cb add-node CLUSTER_NAME S2_HOSTNAME --ip S2_PRIVATE_IP

# Manually copy /etc/ocfs2/cluster.conf to all other nodes

# On all nodes, need to run this to set CLUSTER_NAME as default
# This can be skipped if using "ocfs2" (default cluster name)
# dpkg-reconfigure ocfs2-tools

# On all nodes (required)
echo "kernel.panic_on_oops = 1" > /etc/sysctl.conf
echo "kernel.panic = 30" > /etc/sysctl.conf

# On all nodes:
# Enable port 7777 (used by OCFS2 heartbeats) in firewall

# On all nodes
service o2cb online

# On all nodes
mkdir -p /mnt/shared
echo "/dev/sdb /mnt/shared ocfs2 defaults 0 0" >> /etc/fstab
mount -a

This is as simple as it gets for setting up a shared read-write POSIX-compliant filesystem on two or more servers. Nearly all steps need to be run on each node. And if a new node is added to the cluster, all nodes need to be updated with o2cb add-node CLUSTER_NAME SX_HOSTNAME --ip SX_PRIVATE_IP.

This also uses local heartbeat by default, which is supposedly easier to setup than global heartbeat.

otujuhxv
  • 29
  • 3