Linux server configuration steps to set up NFS server

  • 2020-05-06 12:09:40
  • OfStack

1. Install and configure NFS server

1 > For the NFS server to be serviced, you must start inet, portmap, nfs, and mount
These four daemons, and keep running in the background.
2 > Plan the partition or directory
to share 3 > Define the client's parameter
4 > Configure NFS master profile: /etc/exports
5 > Restart NFS service

1. Configure /etc/exports file syntax
#vi   /etc/exports
  /sharedir         -maproot=daemon     host2
  /sharedir2       -ro         -network 192.168.1.0
  or
in the following format   /sharedir   host3(OPTION)
  /sharedir   192.168.1.12/24(OPTION)
  first paragraph: for Shared directories, be sure to have an absolute path.
The second paragraph: some parameters, such as: -maproot =daemon means that if the visitor is root user, then converted to daemon user; -ro: represents a read-only permission.
The third paragraph of  : represents the client that is allowed to access, which can be a host, such as host2; It could be a net segment; The host can be represented by a domain name or IP, which supports wildcards but does not include points. Such as *. example. net  , can represent e1. example. net or e2. example. net, etc., but can not be said s1. e1. example. net.
The third   format means that you can write the read-write, read-write, and so on in parentheses, separated by commas.

2. Activation services portmap and nfsd
When Portmap is activated, the Sunrpc service
with port number 111 appears #service   portmap restart
#service   nfs         restart

3. The client is configured with
3.1   opens portmap service

3.2   mounts the Shared directory
using the mount command   mount     en t     -- o     device     dir
  #mount   -t   nfs     -o   hard   192.168.1.22:/sharedir     /tmp/
3.3   users can mount with /etc/fstab or autofs in addition to mounting with the mount command.

server configuration instance

NFS server-side configuration:
1. First check to see if the following package
is installed on the server side #rpm -qa   |grep   nfs
nfs-utils-1.0.9-16.e15
nfs-utils-lib-1.0.8-7.2

2. Configure NFS server-side configuration file: /etc/exports
/sharedir: is a Shared directory. Permissions are limited by Shared permissions (rw) and local permissions.
192.168.1.22/24: allows all machines in the 192.168.1.0 segment to access
#vim   /etc/exports
#cat   /etc/exports
/sharedir       192.168.1.22/24(rw)

3. Restart NFS service
            #service       nfs         restart

NFS client configuration:
1. Confirm that portmap package
is installed             #rpm     -qa |grep   portmap
            portmap-4.0-65.2.2.1

2. Open portmap service
#service       portmap     restart

3. View an NFS server Shared directory
192.168.1.22: is the IP address
of NFS server   #showmount     -e       192.168.1.22
  export   list     for   192.168.1.22:
  /sharedir         192.168.1.22/24

4.
, the Shared directory where the server is mounted -t nfs: represents the file system format for mounting files.
can also be omitted   #mount   -t nfs   192.168.1.22:/sharedir   /mnt/


Related articles: