Friday, April 20, 2018

.::: Setting NFS Server & NFS Client on Centos7 to Connect Network Share :::.

Network File System (NFS) is a distributed file system protocol originally developed by Sun Microsystems in 1984, allowing a user on a client computer to access files over a computer network much like local storage is accessed. NFS, like many other protocols, builds on the Open Network Computing Remote Procedure Call (ONC RPC) system. The NFS is an open standard defined in Request for Comments (RFC), allowing anyone to implement the protocol.

A. Server (example 10.10.10.10 & /home/mounting)

1. Install Package
# yum install nfs* rcpbind

2. Allow firewall port/service
# firewall-cmd --permanent --add-service=rpc-bind
# firewall-cmd --permanent --add-service=nfs
# firewall-cmd --permanent --add-service=mountd
# firewall-cmd --complete-reload

3. Enable nfs service
# systemctl start nfs-server
# systemctl enable nfs
   
# systemctl start nfs-lock
# systemctl start nfs-idmap

# systemctl start rpcbind
# systemctl status rpcbind
# systemctl enable rpcbind

4. Create Folder/directory sharing
# mkdir /home/mounting
# chmod -R 777 /home/mounting

5. export directory server
vi /etc/exports
/home/mounting 10.10.10.0/24 *(rw,sync)

[root@teguht-server mounting]# cat /etc/exports
/home/mounting 10.10.10.0/24 *(rw,sync)
[root@teguht-server mounting]#

6. exportfs
# systemctl enable rpcbind
# systemctl restart rpcbind
# showmount -e
# exportfs -a
# mount -a

B. Client (example 10.10.10.20 & /mnt)
1. Install Package
# yum -y install nfs-utils

2. Allow firewall port/service
# firewall-cmd --permanent -add-service=rpc-bind
# firewall-cmd --permanent --add-service=nfs
# firewall-cmd --complete-reload

3. Editing fstab
    vi /etc/fstab
    teguht-server:/home/mounting /mnt nfs defaults 0 0
[root@teguht-client ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Thu Apr 19 14:40:30 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=a41f701b-7add-45d3-b881-a26b3bb35ccc /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
#//teguht-server/shares /mnt/samba cifs creds=/root/teguh.creds 0 0
teguht-server:/home/mounting /mnt nfs defaults 0 0

[root@teguht-client ~]#

4. additional hosts
[root@teguht-client ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.10.10.20 teguht-client
10.10.10.10  teguht-server
[root@teguht-client ~]#

4. Restart nfs
# systemctl restart nfs-secure
# systemctl enable nfs-secure

5. Checking
# mount -a
# df -h

C. Testing
on server
[root@teguht-server data]# cd /home/mounting/
[root@teguht-server mounting]# cat test.txt
test
[root@teguht-server mounting]#
[root@teguht-server mounting]# vi ttttt.txt
[root@teguht-server mounting]# ls
12.txt  test.txt  ttttt.txt
[root@teguht-server mounting]#
[root@teguht-server mounting]# cat /home/mounting/ttttt.txt
ttgf
[root@teguht-server mounting]#

on client
[root@teguht-client mnt]# pwd
/mnt
[root@teguht-client mnt]# ls
12.txt  test.txt  ttttt.txt
[root@teguht-client mnt]#
[root@teguht-client mnt]# cat /mnt/ttttt.txt
ttgf
[root@teguht-client mnt]#






No comments:

Post a Comment

Popular Posts