NFS Shares on CentOS
July 5, 2008 – 8:10 pmMany situations require a “share” of some sort where data is accessible on several machines from a common source. This way data does not have to be duplicated every time and can be accessed over network. The two popular methods are NFS and Samba. For this tutorial we will try to use NFS. Setting up NFS shares on CentOS is fairly easy and mounting them is even simpler!
I. The server that holds the content to be shared:
First you will want to install the needed apps and libraries:
yum install -y nfs-utils nfs-utils-lib nfs-utils-lib-devel
Then you should edit /etc/exports and setup your shares. The format is “/path/to/share ip.ad.dre.ss(options,options) ip.ad.dre.ss(options,options) etc…” You should end up with a file like this:
/home/something/content1/ 192.168.1.101(async,no_subtree_check,rw) 192.168.1.102(async,no_subtree_check,rw)
/home/something/content2/ 192.168.1.101(async,no_subtree_check,rw) 192.168.1.102(async,no_subtree_check,rw)
/home/something/content3/ 192.168.1.101(async,no_subtree_check,rw) 192.168.1.102(async,no_subtree_check,rw)
Then you will want to edit /etc/hosts.allow and add something like:
portmap: 192.168.1.101, 192.168.1.102
Then start services:
/etc/init.d/portmap start
/etc/init.d/nfs start
Then make sure the services start on boot:
chkconfig nfs on
chkconfig portmap on
II. The servers that are pulling the content over NFS:
This is the easy part. You just have to mount the share via /etc/fstab. The format is “nfshost:/nfs/share /path/to/mount/to nfs option,option,option 0 0″. So go ahead and open /etc/fstab and add something like this:
192.168.1.1:/home/something/content1/ /home/mydomain/public_html/mycontent1 nfs rw,hard,intr 0 0
Then you just need to run:
mount -a
Which should mount everything in fstab. If there are errors re-read the tutorial and make sure they are nfs related errors, not other errors in your fstab! Google is your friend!
You must be logged in to post a comment.