NFS Configuration on Linux RHEL/CentOS 6
NFS (NETWORK FILE SYSTEM)
NFS
(Network File System) is used to sharing the files and folders between
linux to unix and unix to linux machines,NFS was developed by Sun Mycro
Systems in the year 1984.
Features:
1. Every one can access same data.
2. Reduce Storage Cost and Easy to use.
3. Centralized Management of Files.
4. Secured with Firewalls and Kerberos.
NFS Configuration :
1. Every one can access same data.
2. Reduce Storage Cost and Easy to use.
3. Centralized Management of Files.
4. Secured with Firewalls and Kerberos.
NFS Configuration :
- NFS Port Number : 2049
- Service Name : nfs
- Packages : nfs-utils & nfs-utils-lib
- /etc/exports : It is main Configuration file of NFS, define all exported files and folders in this path.
- /etc/sysconfig/nfs : It is also Configuration file of NFS to controle on which port rpc and other services are listening.
NFS Server : 192.168.0.99
NFS Client : 192.168.0.20
Server Side Configuration(192.168.0.99)
Configure Server machine (192.168.0.99) using below steps
NFS Client : 192.168.0.20
Server Side Configuration(192.168.0.99)
Configure Server machine (192.168.0.99) using below steps
Step 1: Install NFS Packages & start services
Install NFS Packages using yum command
[root@bsrtech ~]# yum install nfs-utils nfs-utils-lib -y
start nfs service
[root@bsrtech ~]# service nfs start
[root@bsrtech ~]# chkconfig nfs on
(By using chkconfig for every reboot this services automatically starts)
Install NFS Packages using yum command
[root@bsrtech ~]# yum install nfs-utils nfs-utils-lib -y
start nfs service
[root@bsrtech ~]# service nfs start
[root@bsrtech ~]# chkconfig nfs on
(By using chkconfig for every reboot this services automatically starts)
Step 2 : Configure Shared Folders
[root@bsrtech ~]# vim /etc/exports
syntax : <share directory> <clients range> <permissions>
ex : /nfsdata 192.168.0.20(rw,sync)
save&quit(:wq)
where
syntax : <share directory> <clients range> <permissions>
ex : /nfsdata 192.168.0.20(rw,sync)
save&quit(:wq)
where
rw : read & write permissions of /nfsdata folder
sync : sync confirms requests to the shared directory only once the changes have been committed.
After changes , restart service
[root@bsrtech ~]# service nfs restart
By default kernel will read root_squash means anyone who wants to access /nfsdata comes under others.So we have to change permissions of /data as readwrite to others.
[root@bsrtech ~]# chmod 777 /nfsdata
Note : By giving like this there is no security and any file created by users under /nfsdata should get the owner and group ownership to nfsnobody.
sync : sync confirms requests to the shared directory only once the changes have been committed.
After changes , restart service
[root@bsrtech ~]# service nfs restart
By default kernel will read root_squash means anyone who wants to access /nfsdata comes under others.So we have to change permissions of /data as readwrite to others.
[root@bsrtech ~]# chmod 777 /nfsdata
Note : By giving like this there is no security and any file created by users under /nfsdata should get the owner and group ownership to nfsnobody.
To prevent this one provide no_root_squash in /etc/exports
[root@bsrtech ~]# vim /etc/exports
/nfsdata 192.168.0.20(rw,sync,no_root_squash)
save&quit (:wq)
Change permissons of /nfsdata folder
[root@bsrtech ~]# chmod 750 /nfsdata
[root@bsrtech ~]# service nfs restart
Create some files in shared directory
[root@bsrtech ~]# cd /nfsdata
[root@bsrtech nfsdata]# touch f1 f2 f3 f4
Client Side Configuration (192.168.0.20)
Configure Client machine (192.168.0.20) using below steps
[root@bsrtech ~]# vim /etc/exports
/nfsdata 192.168.0.20(rw,sync,no_root_squash)
save&quit (:wq)
Change permissons of /nfsdata folder
[root@bsrtech ~]# chmod 750 /nfsdata
[root@bsrtech ~]# service nfs restart
Create some files in shared directory
[root@bsrtech ~]# cd /nfsdata
[root@bsrtech nfsdata]# touch f1 f2 f3 f4
Client Side Configuration (192.168.0.20)
Configure Client machine (192.168.0.20) using below steps
Step 1: Install NFS Packages & start NFS service
Install NFS Packages using yum command
Install NFS Packages using yum command
[root@nfsclient ~]# yum install nfs-utils nfs-utils-lib -y
[root@nfsclient ~]# service nfs start
[root@nfsclient ~]# chkconfig nfs on
Step2 : To findout which files or directories are exported from the server
[root@nfsclient ~]# service nfs start
[root@nfsclient ~]# chkconfig nfs on
Step2 : To findout which files or directories are exported from the server
[root@nfsclient ~]# showmount -e 192.168.0.99
where 192.168.0.99 is server ip address
where 192.168.0.99 is server ip address
Step3 : Mount shared NFS Directory
Mount Sahred NFS directory using mount command, first create folder for mount point
[root@nfsclient ~]# mkdir /mnt/nfsdata
[root@nfsclient ~]# mount -t nfs 192.168.0.99:/nfsdata /mnt/nfsdata
Verify above mount point using mount command
[root@nfsclient ~]# mkdir /mnt/nfsdata
[root@nfsclient ~]# mount -t nfs 192.168.0.99:/nfsdata /mnt/nfsdata
Verify above mount point using mount command
The above mount command mounted the nfs shared directory on to nfs client on temporarily, to mount permanently write in /etc/fstab see below
[root@nfsclient ~]# vim /etc/fstab
192.168.0.99:/nfsdata /mnt/nfsdata nfs defauls 0 0
step 4 : Check the shared files & folders
Move to shared mounted directory
[root@nfsclient ~]# cd /mnt/nfsdata
[root@nfsclient nfsdata]# ls
f1 f2 f3 f4
No comments:
Post a Comment