having fun with code

Got NFS working

Well, last night I started reading about how to share the files folder of a Drupal installation on a site with multiple web servers. Seems like NFS is the right way to go (as long as your traffic doesn’t grow too much). Perfect for Spaniards.es, since I want to move from a 2 dedicated server setup to a more flexible one where I can launch new web servers easily, almost on demand.

  1. # Install NFS
  2. yum -y install rpcbind nfs-utils nfs-utils-lib system-config-nfs rsync
  3.  
  4. # chkconfig nfs on
  5. /sbin/chkconfig nfs on
  6.  
  7. vi /etc/idmapd.conf
  8. # [General]
  9. # Domain = spaniards.es
  10. # [Mapping]
  11. # Nobody-User = nfsnobody
  12. # Nobody-Group = nfsnobody
  13.  
  14. service rpcidmapd restart
  15.  
  16. echo "/files/archivos  /nfs4exports/archivos none bind 0 0" >> /etc/fstab
  17. mount /nfs4exports/archivos
  18.  
  19. echo "/nfs4exports XXX.177.133.25(rw,insecure,no_subtree_check,nohide,fsid=0) XXX.177.136.14(rw,insecure,no_subtree_check,nohide,fsid=0)" > /etc/exports
  20. echo "/nfs4exports/archivos XXX.177.133.25(rw,insecure,no_subtree_check,nohide) XXX.177.136.14(rw,insecure,no_subtree_check,nohide)" >> /etc/exports
  21. su -c "/usr/sbin/exportfs -rva"
  22. /sbin/service nfs restart
  23.  
  24. echo 'portmap:ALL' > /etc/hosts.deny
  25. echo 'lockd:ALL' >> /etc/hosts.deny
  26. echo 'mountd:ALL' >> /etc/hosts.deny
  27. echo 'rquotad:ALL' >> /etc/hosts.deny
  28. echo 'statd:ALL' >> /etc/hosts.deny
  29.  
  30. echo 'portmap:XXX.177.133.25,XXX.177.136.14' > /etc/hosts.allow
  31. echo 'lockd:XXX.177.133.25,XXX.177.136.14' >> /etc/hosts.allow
  32. echo 'mountd:XXX.177.133.25,XXX.177.136.14' >> /etc/hosts.allow
  33. echo 'rquotad:XXX.177.133.25,XXX.177.136.14' >> /etc/hosts.allow
  34. echo 'statd:XXX.177.133.25,XXX.177.136.14' >> /etc/hosts.allow
  35.  
  36. echo 'LOCKD_TCPPORT=48620' >> /etc/sysconfig/nfs
  37. echo 'LOCKD_UDPPORT=48620' >> /etc/sysconfig/nfs
  38. echo 'MOUNTD_PORT=48621' >> /etc/sysconfig/nfs
  39. echo 'STATD_PORT=48622' >> /etc/sysconfig/nfs
  40. echo 'RQUOTAD=no' >> /etc/sysconfig/nfs
  41. echo 'RQUOTAD_PORT=48623' >> /etc/sysconfig/nfs

At the end, setting up NFS is not that complicated, but it was my first time, so it took a while. Actually, I had everything working before I noticed, since, logged in as root, I couldn’t figure out why I wasn’t able to write to the nfs mounted directory, being this mounted as rw. Well, turns out that you shouldn’t do this as root, since root access on nfs, once enabled does not require authentication.

I’m not sure why there is a need to mount a bind directory on the nfs server, but I think it has to do with the NFS4 directory configuration.

I think I got all the information I needed between these two links:
http://fconfig.wordpress.com/2006/08/17/setting-up-a-fedora-nfs-server/
http://fedorasolved.org/Members/renich/howtos/f7/en/nfsv4-fedora/?searchterm=nfs

Next step: set up the round robin load balancer: haproxy or dns?

Related Posts:

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Additional comments powered by BackType

About the blog

This is a blog about development, focused mainly on Javascript but also other languages like python, shell scripts and more.

About the author

Eneko Alonso is a software engineer and UI developer with more than eight years of experience in software and web development. He lives in San Luis Obispo, California and works at LEVEL Studios.

Contact Info

Contact Info

PromoteJS

JavaScript JS Documentation