13

I have a CentOS 6.3 client that needs to access NFS storage. There are two NFS servers that serve up the same content stored on a SAN with a clustered filesystem. How do I set up CentOS to failover to the backup NFS server if needed? When I Google, I keep reading that Linux does not support this, but that would be strange since there is plenty of information out there on how to set up a clustered Linux NFS server farm...

Doug
  • 371
  • 2
  • 5
  • 15
  • 4
    Would using Heartbeat and a floating virtual IP help you out? It's not limited to NFS, but a more general approach. see for example [Arch Linux wiki: Simple IP Failover with Heartbeat](https://wiki.archlinux.org/index.php/Simple_IP_Failover_with_Heartbeat). – gertvdijk Dec 19 '12 at 23:52
  • 2
    I second the comment by @gertvdijk. You might be able to configure active/passive failover by configuring the same IP address and hostname on the main server and the failover server. That is how commercial NFS filers work such as EMC VG-2 storage gateway. – Dmitri Chubarov Dec 20 '12 at 08:49
  • heartbeat would work but this is a strange particular situation. The NFS server is a OS X 10.8 Xsan setup and they removed heartbeat in 10.8 (10.7 had it). – Doug Jan 04 '13 at 03:07

2 Answers2

10

That sounds like a job for the automount(8) daemon. See the autofs(5) man page (from the autofs rpm) under "Replicated Server". I believe if you add a line like

fileserv host1,host2:/server/export/point

to /etc/auto.misc on your client and (re-)start the autofs service, your NFS storage will show up under /misc/fileserv. You could add -ro as mount options if you want to mount read only (or other mount options of course).

John Sellens
  • 171
  • 1
  • 2
  • 1
    that did it sure enough! thanks. It would be cool if it could revert back to the main server when its back online, but this works well enough to get the job done. – Doug Jan 04 '13 at 03:05
0

The Right Way(tm) to do this is with GlusterFS, which is a scale out filesystem that runs in userspace atop an underlying filesystem like NFS or CIFS.

All this sounds impressive and complicated, but it's actually really simple to set up. It honestly should take you less than 15 minutes. You'd have two servers, each with a "brick" (unit of storage) defined. A volume would then be defined within this server pool. Replication of the data between the servers happens automatically, as does failover on the client if one of the servers dies.

jamieb
  • 3,387
  • 4
  • 24
  • 36
  • Another Right Way is Ceph [RBD](https://ceph.com/docs/master/rbd/rbd/). – Snowball Jul 02 '14 at 15:02
  • You can use [MooseFS](https://moosefs.com/). It's open source and fault-tolerant distributed file system. – TechGeek Jun 14 '18 at 15:37
  • Ceph is slow on VMs. Gluster/Heketi also and it is not yet suitable for many small files and/or many write operations, e.g. databases or Redis - I have learned through pain. I have not tried MooseFS yet. I am now back to NFS, autofs and lsyncd. – uav Jul 30 '20 at 14:43