Monday, December 7, 2015

How to Setup NFS (Network File System) on RHEL

NFS (Network File System) is basically developed for sharing of files and folders between Linux/Unix systems. It allows you to mount your local file systems over a network and remote hosts to interact with them as they are mounted locally on the same system. With the help of NFS, we can set up file sharing between UNIX to Linux system and Linux to UNIX system. Then let me to describe as following commands.
We have a primary server that we have a LUN that his name is /test-nf.
/test-nfs mounted on the server db-test-2 and we want to share this directory for using on db-test-1.

db-test-1 : 10.8.72.24
db-test-2 : 10.8.72.25

1-
[root@db-test-2 ~]# id oracle
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54323(asmdba),54324(asmoper),54326(oper)
-----------------------------------------------------------------------------
2-
[root@db-test-2 ~]# vi /etc/exports

/test-nfs 10.8.72.0/24(rw,sync,all_squash,anonuid=54321,anongid=54321)
-----------------------------------------------------------------------------
3-
[root@db-test-2 ~]# /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Stopping RPC idmapd:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
[root@db-test-2 ~]# /etc/init.d/nfs restart
Shutting down NFS daemon:                                  [  OK  ]
Shutting down NFS mountd:                                  [  OK  ]
Shutting down NFS quotas:                                  [  OK  ]
Shutting down NFS services:                                [  OK  ]
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Stopping RPC idmapd:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
[root@db-test-2 ~]#
-----------------------------------------------------------------------------
4-On the server db-test-1:
[root@db-test-1 ~]# mount 10.8.72.25:/test-nfs /backup/
-----------------------------------------------------------------------------

Be careful if you configured firewall on the Linux, then you have to configure
Iptables by opening tcp and udp ports then restart NFS service and mount again as following commands:

[root@db-test-1 ~]#  vim /etc/sysconfig/iptables

-A INPUT -p tcp -m state —state NEW -m tcp —dport 111 -j ACCEPT
-A INPUT -p tcp -m state —state NEW -m tcp —dport 2049 -j ACCEPT
-A INPUT -p udp -m state —state NEW -m udp —dport 111 -j ACCEPT
-A INPUT -p udp -m state —state NEW -m udp —dport 2049 -j ACCEPT


[root@db-test-1 ~]# /etc/init.d/iptables restart

[root@db-test-2 ~]# /etc/init.d/nfs restart


[root@db-test-1 ~]# mount 10.8.72.25:/test-nfs /backup/  



No comments:

Post a Comment