[CENTOS] NFS server construction

This time, the procedure is to build an NFS server in the verification environment and mount it as an ESXi datastore.

Deploy virtual machine

First, configure the virtual hardware settings for the virtual machine. -Log in to the deployment destination ESXi. -Store the ISO file in any location from Storage> Datastore> Datastore Browser. -From the creation / registration of the virtual machine, set the following and complete. ● Selection of creation type -Create a new virtual machine ● Name and guest OS selection ・ The name is CentOS7 (optional) · Compatibility is ESXi 6.x virtual machine -Guest OS family is linux, guest OS version is CentOS 7 (64-bit) ● Storage selection -Select any data store ● Customize settings ・ CPU / memory / hard disk / network adapter is optional -Select the ISO file stored in any location in the data store on the CD / DVD drive 1 and select it. Put ☑ in the connection when powering on

Next, start the virtual machine and install the OS. The installation settings are optional, but the software selection chooses a minimal installation. After installation, reboot.

See below for creating a local repository. https://qiita.com/fooot4/items/6e7ec0df51ac18abfb2b

nfs installation

# yum --disablerepo=* --enablerepo=local install nfs-utils
Loaded plugin:fastestmirror
Loading mirror speeds from cached hostfile
Resolving dependencies
-->Performing transaction confirmation.
--->Package nfs-utils.x86_64 1:1.3.0-0.21.install el7
-->I'm dealing with dependencies: libtirpc >= 0.2.3-1 package: 1:nfs-utils-1.3.0-0.21.el7.x86_64
-->I'm dealing with dependencies: gssproxy >= 0.3.0-0 packages: 1:nfs-utils-1.3.0-0.21.el7.x86_64
-->I'm dealing with dependencies:rpcbind package: 1:nfs-utils-1.3.0-0.21.el7.x86_64
-->I'm dealing with dependencies:quota package: 1:nfs-utils-1.3.0-0.21.el7.x86_64
-->I'm dealing with dependencies:libnfsidmap package: 1:nfs-utils-1.3.0-0.21.el7.x86_64
-->I'm dealing with dependencies:libevent package: 1:nfs-utils-1.3.0-0.21.el7.x86_64
-->I'm dealing with dependencies:keyutils package: 1:nfs-utils-1.3.0-0.21.el7.x86_64
-->I'm dealing with dependencies: libtirpc.so.1()(64bit)Package: 1:nfs-utils-1.3.0-0.21.el7.x86_64
-->I'm dealing with dependencies: libnfsidmap.so.0()(64bit)Package: 1:nfs-utils-1.3.0-0.21.el7.x86_64
-->I'm dealing with dependencies: libevent-2.0.so.5()(64bit)Package: 1:nfs-utils-1.3.0-0.21.el7.x86_64
-->Performing transaction confirmation.
--->Package gssproxy.x86_64 0:0.4.1-7.install el7
-->I'm dealing with dependencies: libverto-package of tevent: gssproxy-0.4.1-7.el7.x86_64
-->I'm dealing with dependencies: libini_config.so.3(INI_CONFIG_1.1.0)(64bit)Package: gssproxy-0.4.1-7.el7.x86_64
-->I'm dealing with dependencies: libref_array.so.1()(64bit)Package: gssproxy-0.4.1-7.el7.x86_64
-->I'm dealing with dependencies: libini_config.so.3()(64bit)Package: gssproxy-0.4.1-7.el7.x86_64
-->I'm dealing with dependencies: libcollection.so.2()(64bit)Package: gssproxy-0.4.1-7.el7.x86_64
-->I'm dealing with dependencies: libbasicobjects.so.0()(64bit)Package: gssproxy-0.4.1-7.el7.x86_64
--->Package keyutils.x86_64 0:1.5.8-3.install el7
--->Package libevent.x86_64 0:2.0.21-4.install el7
--->Package libnfsidmap.x86_64 0:0.25-12.install el7
--->Package libtirpc.x86_64 0:0.2.4-0.6.install el7
--->Package quota.x86_64 1:4.01-11.install el7
-->I'm dealing with dependencies: quota-nls = 1:4.01-11.el7 package: 1:quota-4.01-11.el7.x86_64
-->I'm dealing with dependencies: tcp_Wrappers package: 1:quota-4.01-11.el7.x86_64
--->Package rpcbind.x86_64 0:0.2.0-32.install el7
-->Performing transaction confirmation.
--->Package libbasicobjects.x86_64 0:0.1.1-25.install el7
--->Package libcollection.x86_64 0:0.6.2-25.install el7
--->Package libini_config.x86_64 0:1.2.0-25.install el7
-->I'm dealing with dependencies: libpath_utils.so.1(PATH_UTILS_0.2.1)(64bit)Package: libini_config-1.2.0-25.el7.x86_64
-->I'm dealing with dependencies: libpath_utils.so.1()(64bit)Package: libini_config-1.2.0-25.el7.x86_64
--->Package libref_array.x86_64 0:0.1.5-25.install el7
--->Package libverto-tevent.x86_64 0:0.2.5-4.install el7
-->I'm dealing with dependencies: libtevent.so.0(TEVENT_0.9.9)(64bit)Package: libverto-tevent-0.2.5-4.el7.x86_64
-->I'm dealing with dependencies: libtalloc.so.2(TALLOC_2.0.2)(64bit)Package: libverto-tevent-0.2.5-4.el7.x86_64
-->I'm dealing with dependencies: libtevent.so.0()(64bit)Package: libverto-tevent-0.2.5-4.el7.x86_64
-->I'm dealing with dependencies: libtalloc.so.2()(64bit)Package: libverto-tevent-0.2.5-4.el7.x86_64
--->Package quota-nls.noarch 1:4.01-11.install el7
--->Package tcp_wrappers.x86_64 0:7.6-77.install el7
-->Performing transaction confirmation.
--->Package libpath_utils.x86_64 0:0.2.1-25.install el7
--->Package libtalloc.x86_64 0:2.1.2-1.install el7
--->Package libtevent.x86_64 0:0.9.25-1.install el7
-->Dependency resolution finished.

Resolved the dependency

================================================================================
Package architecture
Version repository
capacity
================================================================================
During installation:
 nfs-utils             x86_64       1:1.3.0-0.21.el7          local       370 k
Dependency related installation:
 gssproxy              x86_64       0.4.1-7.el7               local        84 k
 keyutils              x86_64       1.5.8-3.el7               local        54 k
 libbasicobjects       x86_64       0.1.1-25.el7              local        24 k
 libcollection         x86_64       0.6.2-25.el7              local        40 k
 libevent              x86_64       2.0.21-4.el7              local       214 k
 libini_config         x86_64       1.2.0-25.el7              local        59 k
 libnfsidmap           x86_64       0.25-12.el7               local        46 k
 libpath_utils         x86_64       0.2.1-25.el7              local        27 k
 libref_array          x86_64       0.1.5-25.el7              local        26 k
 libtalloc             x86_64       2.1.2-1.el7               local        31 k
 libtevent             x86_64       0.9.25-1.el7              local        32 k
 libtirpc              x86_64       0.2.4-0.6.el7             local        85 k
 libverto-tevent       x86_64       0.2.5-4.el7               local       9.0 k
 quota                 x86_64       1:4.01-11.el7             local       176 k
 quota-nls             noarch       1:4.01-11.el7             local        89 k
 rpcbind               x86_64       0.2.0-32.el7              local        57 k
 tcp_wrappers          x86_64       7.6-77.el7                local        78 k

Transaction summary
================================================================================
Installation 1 package(+17 dependency packages)

Total download capacity: 1.5 M
Installation capacity: 4.3 M
Is this ok [y/d/N]: y
Downloading packages:
--------------------------------------------------------------------------------
Total 143 MB/s | 1.5 MB  00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
During installation: libbasicobjects-0.1.1-25.el7.x86_64            1/18
During installation: libtirpc-0.2.4-0.6.el7.x86_64                  2/18
During installation: libref_array-0.1.5-25.el7.x86_64               3/18
During installation: libcollection-0.6.2-25.el7.x86_64              4/18
During installation: libtalloc-2.1.2-1.el7.x86_64                   5/18
During installation: libtevent-0.9.25-1.el7.x86_64                  6/18
During installation: libverto-tevent-0.2.5-4.el7.x86_64             7/18
During installation: rpcbind-0.2.0-32.el7.x86_64                    8/18
During installation: libnfsidmap-0.25-12.el7.x86_64                 9/18
During installation: 1:quota-nls-4.01-11.el7.noarch                10/18
During installation: keyutils-1.5.8-3.el7.x86_64                   11/18
During installation: libevent-2.0.21-4.el7.x86_64                  12/18
During installation: libpath_utils-0.2.1-25.el7.x86_64             13/18
During installation: libini_config-1.2.0-25.el7.x86_64             14/18
During installation: gssproxy-0.4.1-7.el7.x86_64                   15/18
During installation: tcp_wrappers-7.6-77.el7.x86_64                16/18
During installation: 1:quota-4.01-11.el7.x86_64                    17/18
During installation: 1:nfs-utils-1.3.0-0.21.el7.x86_64             18/18
During verification: libini_config-1.2.0-25.el7.x86_64              1/18
During verification: tcp_wrappers-7.6-77.el7.x86_64                 2/18
During verification: libverto-tevent-0.2.5-4.el7.x86_64             3/18
During verification: libtalloc-2.1.2-1.el7.x86_64                   4/18
During verification: libcollection-0.6.2-25.el7.x86_64              5/18
During verification: 1:nfs-utils-1.3.0-0.21.el7.x86_64              6/18
During verification: libpath_utils-0.2.1-25.el7.x86_64              7/18
During verification: libevent-2.0.21-4.el7.x86_64                   8/18
During verification: keyutils-1.5.8-3.el7.x86_64                    9/18
During verification: libref_array-0.1.5-25.el7.x86_64              10/18
During verification: rpcbind-0.2.0-32.el7.x86_64                   11/18
During verification: libtirpc-0.2.4-0.6.el7.x86_64                 12/18
During verification: gssproxy-0.4.1-7.el7.x86_64                   13/18
During verification: 1:quota-nls-4.01-11.el7.noarch                14/18
During verification: 1:quota-4.01-11.el7.x86_64                    15/18
During verification: libtevent-0.9.25-1.el7.x86_64                 16/18
During verification: libbasicobjects-0.1.1-25.el7.x86_64           17/18
During verification: libnfsidmap-0.25-12.el7.x86_64                18/18

Installation:
  nfs-utils.x86_64 1:1.3.0-0.21.el7

Installed dependency related:
  gssproxy.x86_64 0:0.4.1-7.el7           keyutils.x86_64 0:1.5.8-3.el7
  libbasicobjects.x86_64 0:0.1.1-25.el7   libcollection.x86_64 0:0.6.2-25.el7
  libevent.x86_64 0:2.0.21-4.el7          libini_config.x86_64 0:1.2.0-25.el7
  libnfsidmap.x86_64 0:0.25-12.el7        libpath_utils.x86_64 0:0.2.1-25.el7
  libref_array.x86_64 0:0.1.5-25.el7      libtalloc.x86_64 0:2.1.2-1.el7
  libtevent.x86_64 0:0.9.25-1.el7         libtirpc.x86_64 0:0.2.4-0.6.el7
  libverto-tevent.x86_64 0:0.2.5-4.el7    quota.x86_64 1:4.01-11.el7
  quota-nls.noarch 1:4.01-11.el7          rpcbind.x86_64 0:0.2.0-32.el7
  tcp_wrappers.x86_64 0:7.6-77.el7

Has completed!

nfs settings

-Create a directory shared by nfs. This time it's / home / nfs. When creating a directory, you need to change the owner of the directory to nfsnobody.

# mkdir /home/nfs
# ll /home/
Total 0
drwxr-xr-x.3 root root 17 November 8 18:13 nfs

# chown -R nfsnobody:nfsnobody /home/nfs/
# ll /home/
Total 0
drwxr-xr-x.3 nfsnobody nfsnobody 17 November 8 18:13 nfs

-Set the network and options that can be shared with the directory shared by nfs.

# vi /etc/exports
/home/nfs xxx.xxx.xxx.xxx/xx(rw) 

# exportfs
/home/nfs       xxx.xxx.xxx.xxx/xx

About nfs parameters

・ Set the following.

 # /exported/directory xxx.xxx.xxx.xxx/xx(ro/rw)
parameter Explanation
/exported/directory Specify the directory to share
xxx.xxx.xxx.xxx/xx Specify a network that can be shared, no prefix required for hosts
ro The file system to be exported will be read-only
rw The file system to be exported becomes readable and writable

firewall settings

-When using nfs version 4, set the firewall service port to be open below.

# firewall-cmd --permanent --add-service=nfs
success

# firewall-cmd --reload
success

# firewall-cmd --list-all
public (default, active)
  interfaces: eno16780032
  sources:
  services: dhcpv6-client nfs ssh
  ports:
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:

-When using nfs version 3, disable the firewall. It seems that the port in nfs is not fixed.

# systemctl stop firewalld
# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead)since day 2020-11-08 18:34:10 JST; 7s ago
  Process: 9751 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 9751 (code=exited, status=0/SUCCESS)

November 08 18:24:37 localhost.localdomain systemd[1]: Starting firewalld - dyna...
November 08 18:24:37 localhost.localdomain systemd[1]: Started firewalld - dynam...
November 08 18:34:09 localhost.localdomain systemd[1]: Stopping firewalld - dyna...
November 08 18:34:10 localhost.localdomain systemd[1]: Stopped firewalld - dynam...
Hint: Some lines were ellipsized, use -l to show in full.

nfs service start

# systemctl start rpcbind
# systemctl status rpcbind
● rpcbind.service - RPC bind service
   Loaded: loaded (/usr/lib/systemd/system/rpcbind.service; indirect; vendor preset: enabled)
   Active: active (running)since day 2020-11-08 17:24:39 JST; 4min 27s ago
  Process: 9281 ExecStart=/sbin/rpcbind -w ${RPCBIND_ARGS} (code=exited, status=0/SUCCESS)
 Main PID: 9282 (rpcbind)
   CGroup: /system.slice/rpcbind.service
           mq9282 /sbin/rpcbind -w

November 08 17:24:39 localhost.localdomain systemd[1]: Starting RPC bind service...
November 08 17:24:39 localhost.localdomain systemd[1]: Started RPC bind service.
# systemctl start nfs
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
   Active: active (exited)since day 2020-11-08 17:24:45 JST; 4min 46s ago
  Process: 9296 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
  Process: 9294 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
 Main PID: 9296 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nfs-server.service

November 08 17:24:45 localhost.localdomain systemd[1]: Starting NFS server and services...
November 08 17:24:45 localhost.localdomain systemd[1]: Started NFS server and services.
November 08 17:29:23 localhost.localdomain systemd[1]: Started NFS server and services.

rpcbind.nfs if service is not started.service fails to start

Nfs mount from ESXi (nfs client)

-Log in to ESXi of the nfs client. -Press Storage> Datastore> New Datastore. -Select the mount of the NFS datastore and click Next. -Any name, enter the corresponding IP address for the NFS server and the directory to be shared with the NFS share. If the NFS version is NFS4, leave the username / password blank and press Next.

Things to note

· If you do not create an nfs user You have to set the shared directory to have access with nfsnobody. -If you use nfs version 3, you have to disable the firewall.

Recommended Posts

NFS server construction
Server construction procedure Ubuntu18.04 server
Try deploying Rails application to EC2-Part 2 (Server construction)-
Ubuntu18.04 LTS minecraft server java edition construction memorandum
Internal DNS server construction (A record / PTR record only)