Home » Categories » Multiple Categories |
How To Set Up an NFS Mount on CentOS 6 |
Article Number: 236 | Rating: Unrated | Last Updated: Tue, Dec 31, 2013 at 9:28 AM
|
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.
SetupAn 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 The system should be set up as root. You can access the root user by typing sudo su Setting Up the NFS ServerStep One—Download the Required SoftwareStart off by using apt-get to install the nfs programs. yum install nfs-utils nfs-utils-lib Subsequently, run several startup scripts for the NFS server: chkconfig nfs on service rpcbind start service nfs start Step Two—Export the Shared DirectoryThe next step is to decide which directory we want to share with the client server. The chosen directory should then be added to the /etc/exports file, which specifies both the directory to be shared and the details of how it is shared. Suppose we wanted to share the directory, /home. We need to export the directory: vi /etc/exports Add the following lines to the bottom of the file, sharing the directory with the client: /home 12.33.44.555(rw,sync,no_root_squash,no_subtree_check) These settings accomplish several tasks:
Once you have entered in the settings for each directory, run the following command to export them: exportfs -a Setting Up the NFS ClientStep One—Download the Required SoftwareStart off by using apt-get to install the nfs programs. yum install nfs-utils nfs-utils-lib Step Two—Mount the DirectoriesOnce the programs have been downloaded to the the client server, create the directory that will contain the NFS shared files mkdir -p /mnt/nfs/home Then go ahead and mount it mount 12.34.56.789:/home /mnt/nfs/home You can use the df -h command to check that the directory has been mounted. You will see it last on the list. df -h Filesystem Size Used Avail Use% Mounted on /dev/sda 20G 783M 18G 5% / 12.34.56.789:/home 20G 785M 18G 5% /mnt/nfs/home Additionally, use the mount command to see the entire list of mounted file systems. mount Your list should look something like this: /dev/sda on / type ext4 (rw,errors=remount-ro) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw) nfsd on /proc/fs/nfsd type nfsd (rw) 12.34.56.789:/home on /mnt/nfs/home type nfs (rw,noatime,nolock,bg,nfsvers=2,intr,tcp,actimeo=1800,addr=12.34.56.789) Testing the NFS MountOnce you have successfully mounted your NFS directory, you can test that it works by creating a file on the Client and checking its availability on the Server. Create a file in the directory to try it out: touch /mnt/nfs/home/example You should then be able to find the files on the Server in the /home. ls /home 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. vi /etc/fstab 12.34.56.789:/home /mnt/nfs/home nfs auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0 You can learn more about the fstab options by typing in: man nfs After any subsequent server reboots, you can use a single command to mount directories specified in the fstab file: mount -a You can check the mounted directories with the two earlier commands: df -h mount Removing the NFS MountShould you decide to remove a directory, you can unmount it using the umount command: cd
sudo umount /directory name You can see that the mounts were removed by then looking at the filesystem again. df -h You should find your selected mounted directory gone. |
Attachments
There are no attachments for this article.
|
How To Create Nagios Plugins With Python On CentOS 6
Viewed 3628 times since Sat, Jan 4, 2014
How To Create Nagios Plugins With Perl On CentOS 6
Viewed 2559 times since Sat, Jan 4, 2014
How To Configure Secure Updates and Installations in WordPress on Ubuntu
Viewed 5204 times since Sat, Jan 4, 2014
How To Deploy Node.js Applications Using Systemd and Nginx
Viewed 9568 times since Sat, Jan 4, 2014
How To Setup a Rails 4 App With Apache and Passenger on CentOS 6
Viewed 3659 times since Thu, Dec 19, 2013
How To Create An Off-Site Backup Of Your Site With Rsync On Centos 6
Viewed 5779 times since Sat, Jan 4, 2014
How to Add a Swap File on an Arch Linux Cloud Server
Viewed 2632 times since Fri, Dec 27, 2013
How To Install Ruby on Rails on CentOS 6
Viewed 3053 times since Tue, Dec 31, 2013
Top 10 Linux Easter Eggs
Viewed 7329 times since Sat, Jan 4, 2014
How to Setup Additional Entropy for Cloud Servers Using Haveged
Viewed 2524 times since Sat, Jan 4, 2014
|