Wissensdatenbank
Set Up an NFS Storage on CentOS 6
About NFS (Network File System) Mounts
NFS mounts work to share a directory between several servers. This has the advantage of saving disk space, as the home directory is only kept on one server, and others can connect to it over the network. When setting up mounts, NFS is most effective for permanent fixtures that should always be accessible.
An NFS mount is set up between at least two servers. The machine hosting the shared network is called the server, while the ones that connect to it are called ‘clients’.
This tutorial requires 2 servers: one acting as the server and one as the client. We will set up the server machine first, followed by the client. The following IP addresses will refer to each one:
Master: 12.34.56.789
Client: 12.33.44.555
Setting Server NAS
Install Require Package:
yum install nfs* rpcbind
Start Service NFS:
service nfs restart
service rpcbind restart
chkconfig nfs on
chkconfig rpcbind on
Create Folder for Sharing Storage:
mkdir /home/folder
chmod 0777 /home/folder
We need to export the directory:
nano /etc/exports
Add the following lines to the bottom of the file, sharing the directory with the client:
/home/folder 12.33.44.555(rw,sync,no_root_squash,no_subtree_check)
Once you have entered in the settings for each directory, run the following command to export them:
/usr/sbin/exportfs -avr
Setting Server Client
Install Require Package:
yum install nfs* rpcbind
Start Service NFS:
service nfs restart
service rpcbind restart
chkconfig nfs on
chkconfig rpcbind on
Check Service NFS is Working:
showmount -e nas-server
Create new folder for mount:
mkdir -p /mnt/nfs/home
Mount Storage:
mount 12.34.56.789:/home/folder /mnt/nfs/home
Check Storage success attach:
df -h
You can ensure that the mount is always active by adding the directory to the fstab file on the client. This will ensure that the mount starts up after the server reboots.
nano /etc/fstab
12.34.56.789:/home /mnt/nfs/home nfs auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0