iSCSI, multiple initiators for the same LUN
I have a web application that is distributed over 3 servers. These 3 servers need a shared storage to access files. Since iSCSI is just a protocol, not a filesystem, it will not have any implementation of locking files; so if I just connect it as it is, I will just destroy all of the data.
According to my research, I would need an actual filesystem on these LUNs in order to function as I intend to use it.
How would that work? How can I implement a file system for the LUN?
OS Used: Ubuntu 16.* or 18.*
You need to have some sort of either a clustered file system or distributed lock manager to avoid metadata damage done to your file system with concurrent writes.
There's a good summary of this issue on StarWind forum.
https://forums.starwindsoftware.com/viewtopic.php?f=5&t=1392
Generally speaking, you need a cluster in order to share storage between multiple systems (unless you want one of them to act as a file server).
I don't actually know anything about building clusters on Ubuntu, but this looks promising: http://manpages.ubuntu.com/manpages/cosmic/man7/ocfs2.7.html.
So after some research, I came up with few solutions that would be interesting for those who are looking to set up remote storage or a cluster.
Reconsider your network and your needs. One thing that I ran into is setting up an iscsi with cluster-aware file systems is not an easy task. Additionally GFS and OCFS2 do not have well-documented troubleshooting guide available to the public. In the case of OCFS2, you would need to be Oracle's customer and have an active support account. same with GFS2. if you are Centos user, you are stuck with online tutorials and no support for it.
Most likely it is out of your budget anyway. Consider using NFS for hobby-small-medium business. it is much easier to set up, it has plenty of documentation online.
If you really need an iscsi LUN to be shared across multiple machines, then there are 3 solutions available out there. Oracles OCFS2, Red Hat GFS2, VMFS. all 3 are cluster-aware file systems. OCFS2 is simpler to set up but requires you to have access to oracle support which is not free, GFS2 is not as simple as OCFS2 because you would have to manually set up bits of it but it also makes it more customizable. ad VMFS which is cool to use with your ESXI server to keep your VM machines there.
I hope that helps some users in the future when deciding what you actually need for your network and storage. I personally opted for NFS as storage and dedicated iscsi to ESXI server for image booting.