Saturday, July 3, 2021

How to create NFS server on Centos 7 | How to Install NFS server on Centos 8

 

Network File System (NFS) is a distributed file system protocol originally developed by Sun Microsystems (Sun) in 1984,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. NFS, like many other protocols, builds on the Open Network Computing Remote Procedure Call (ONC RPC) system. 


    Feature & Benefits of NFS Server 

    • NFS server allows to mount locally from  remote server files.
    • Fast and reliable services 
    •  NFS can be configure as centralized storage .
    • Users get their data irrespective of physical location.
    • File sync real time . 
    • Can be secured with Firewalls.

    NFS Configuration files 
    /etc/exports  : This is main configuration file which contain information of all shared Directory .

    /etc/sysconfig/nfs : This file contain information port and services information.

    /etc/fstab : This is not NFS configuration but we use this file to mount share permanently. 


    NFS Server Configuration
    Step 1 : Install required packages 

    [root@server1 ~]# yum install nfs-utils 


    Step 2 : Start the nfs service 


    [root@server1 ~]# systemctl start nfs-server  


    systemctl status nfs-server

    nfs-server.service - NFS server and services

       Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)

       Active: active (exited) since Tue 2021-06-22 23:12:52 EDT; 1s ago

      Process: 9325 ExecStartPost=/bin/sh -c if systemctl -q is-active gssproxy; then systemctl reload gssproxy ; fi (code=exited, status=0/SUCCESS)

      Process: 9309 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)

      Process: 9308 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)

     Main PID: 9309 (code=exited, status=0/SUCCESS)

        Tasks: 0

       CGroup: /system.slice/nfs-server.service


    Jun 22 23:12:52 server1 systemd[1]: Starting NFS server and services...

    Jun 22 23:12:52 server1 systemd[1]: Started NFS server and services.




    [root@server1 ~]# systemctl enable nfs-server 

    Created symlink from /etc/systemd/system/multi-user.target.wants/nfs-server.service to /usr/lib/systemd/system/nfs-server.service.




    Step 3 : Configure NFS Share 



    [root@server1 ~]# mkdir /opt/SHAREDRIVE



    [root@server1 ~]# vi /etc/exports


    /opt/SHAREDRIVE 192.168.43.230(rw,sync,no_root_squash)



    Note: In above entry /opt/SHAREDRIVE is a folder which you

          want to share over network and 192.168.43.230 is a client 

          IP to whom you want to share. if you want to share this

          NFS drive to all system over network user * in place of IP.



    : Now restart nfs service to take effect new configuration 


    [root@server1 ~]# systemctl restart nfs-server


    : Now check your configuration 


    [root@server1 ~]# showmount -e localhost


    Export list for localhost:

    /opt/SHAREDRIVE 192.168.43.230



    NFS Options

    • ro: With the help of this option we can provide read only access to the shared files.
    • rw: This option will allows both read and write access to the client.
    • sync: Sync confirms requests to the shared directory only once the changes have been committed.
    • no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger file system, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
    • no_root_squash: This allows root to connect to the directory.



    Step 4 : Mount NFS Share on client 



    Note: if nfs-utils package is not installed on client install it first 



    : Check available share 


    NirmalSingh@abcs-Air ~ % showmount -e 192.168.43.62


    Exports list on 192.168.43.62:

    /opt/SHAREDRIVE                     192.168.43.230 



    : Now Mount NFS share 

    [root@client1 ~]#  mount -t nfs 192.168.43.62:/opt/SHAREDRIVE /mnt/




    : Now Verify your NFS Mount 


    [root@client1 ~]# mount | grep nfs


    sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)

    nfsd on /proc/fs/nfsd type nfsd (rw,relatime)

    192.168.43.62:/opt/SHAREDRIVE on /mnt type nfs4 (rw,relatime,vers=4.1,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.43.62,local_lock=none,addr=192.168.43.62)



    : Now Mount NFS Share Permanent 

    : Make entry in /etc/fstab file 

    [root@client1 ~]# vi /etc/fstab


    192.168.43.62:/opt/SHAREDRIVE /mnt      nfs     defaults 0 0




    : Now all configuration done you can use share to put data

      and check on server.










    No comments:

    Post a Comment

    Installing Jenkins on RHEL 8 is a straightforward process. Here's a step-by-step guide

    Introduction  Jenkins is an open-source automation server widely used for continuous integration (CI) and continuous delivery (CD) pipelines...