Installation of NFS (server side)
System Requirements & Prerequisites
On our server (IP :10.10.13.58), we define a place (a folder) which will be reserved for NFS.
In our case, the whole /backup directory is reserved for NFS. We plan to have several shared folders, one by server.
So, in order to do that, we create each of them : /backup/srv01-136 ; /backup/srv01-137 ; /backup/srv01-138 …
If we want to have these servers which are NFS clients, allowed to add files to those locations, we must modify the permissions of each folder of backup.
# chown -R nobody.nogroup backup/
Installation and configuration of NFS
On our server, we install NFS with the following commend:
# apt-get install nfs-kernel-server nfs-common portmap
Once it is done, we edit the configuration file /etc/exports in order to allow incomming connections from NFS clients (IP : 10.10.13.16 for exemple) and we define for each NFS clients, a specific folder (those one which we had created in the previous step (/backup/srv01-136).
# nano /etc/exports
# /etc/exports: the access control list for filesystems which may be exported # to NFS clients. See exports(5). # # Example for NFSv2 and NFSv3: # /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check) # # Example for NFSv4: # /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check) # /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check) # /backup/srv01-136 10.10.13.16/32(rw)
We add the red line to the config file and we save and close the file.
If we want to confirm our configuration, we can execute the next command line:
# exportfs -a
Installation of NFS (client side)
System Requirements & Prerequisites
On our client, before installing the NFS package, we need to create and mount a new folder.
We create it at the root of our client:
# mkdir backup
Installation and configuration of NFS
Installation of NFS
On our client, we install NFS with the following command line:
Debian :
# apt-get install nfs-common portmap
Ou
# apt-get install nfs-common rpcbind
RedHat :
# yum install nfs
Mounting a remote folder
Once it is done, we can mount our new remote folder and make it available from our new local folder created earlier.
So we mount our folder with the argument –t NFS, and with the permission argument –o Read and Write.
/backup points to 10.10.13.58:/backup/srv01-136
Debian :
# mount -t nfs -o rw 10.10.13.58:/backup/srv-136 /backup
RedHat :
# mount -t nfs -o rw 10.10.13.58:/backup/nuwebdev01-05 /backup
Mounting at boot
Now, we add a line in the /etc/fstab file so everytime the server is reboot, the mounting will be fine, it will be done automatically.
# nano /etc/fstab
# /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 # /dev/sda4 UUID=d434dcfb-56d1-45d7-9a86-28e56813e32e / ext3 relatime,errors=remount-ro 0 1 # /dev/sda1 UUID=d773cafb-6b4c-455a-88d1-243584a65872 /boot ext3 relatime 0 2 # /dev/sda8 UUID=5c40d3de-6071-4e63-8461-e5da40c46d36 /home ext3 relatime 0 2 # /dev/sda7 UUID=02ffccd5-0882-48ee-a5b8-8942b3be74f1 /tmp ext3 relatime 0 2 # /dev/sda5 UUID=9d5faabc-3df1-4ef7-9968-3dcfa3bfdc6e /usr ext3 relatime 0 2 # /dev/sda6 UUID=e3d58648-b324-326c-b84e-daf912fefcc2 /var ext3 relatime 0 2 # /dev/sda3 UUID=b9553074-5eb9-4a5a-2ac3-ef96ac525c09 none swap sw 0 0 /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0 /dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0 #Debian 10.10.13.58:/backup/srv01-136 /backup nfs rw 0 0 #RedHat 10.10.13.58:/backup/srv01-136 /backup nfs rw 0 0
Backup’s script
Now, the backup’s path must point to: /backup
Example of our swtich on srv01-136 :
#!/bin/sh for DIR in $(ls /home/www/sites); do tar -czf /backup/$DIR.tgz -C /home/www/sites $DIR done
We add our backup’s script to crontab. It will be executed every night at 03h00.
NFS Status checking commands
root@srv01-136:/# rpcinfo -p program vers proto port service 100000 4 tcp 111 portmapper 100000 3 tcp 111 portmapper 100000 2 tcp 111 portmapper 100000 4 udp 111 portmapper 100000 3 udp 111 portmapper 100000 2 udp 111 portmapper 100024 1 udp 41682 status 100024 1 tcp 40394 status Info sur NFS $ nfsstat -1 $ nfsstat -2 $ nfsstat -3 $ nfsstat -4