1. install and configure the NFS server
1> to enable the NFS server to provide services, you must start inet, portmap, nfs, and mount.
These four daemon processes are maintained in the background.
2> plan the partitions or directories to be shared.
3> define client Parameters
4> Configure the NFS master configuration file:/etc/exports
5> restart the NFS service
1. Configure the syntax of the/etc/exports file
# Vi/etc/exports
/Export Dir-maproot = daemon host2
/Nvidir2-ro-network 192.168.1.0
Or use the following format
/Optional dir host3 (OPTION)
/Optional dir 192.168.1.12/24 (OPTION)
The first section is the shared directory, which must be an absolute path.
Section 2: some parameters, such as-maproot = daemon, indicate that if the visitor is a root user, the access is converted to a daemon user;-ro: indicates the read-only permission.
Section 3: indicates the client that can be accessed. It can be a host such as host2 or a network segment. The host can be represented by a domain name or an IP address. The domain name supports wildcards, it does not include vertices. For example, * .example.net can be e1.example.net or e2.example.net, but it cannot be s1.e1.example.net.
The third format indicates that parameters such as read/write and read-only can be written in brackets and separated by commas.
2. Activate the service portmap and nfsd
After Portmap is activated, the Sunrpc service with the Port Number 111 is displayed.
# Service portmap restart
# Service nfs restart
3. Client Configuration
3.1 enable the portmap service
3.2 use the mount command to mount the shared directory
Mount-t type-o option device dir
# Mount-t nfs-o hard 192.168.1.22:/folder DIR/tmp/
3.3 In addition to the mount command, you can also use/etc/fstab mounting or autofs mounting.
Ii. Configure an NFS server instance
NFS Server Configuration:
1. Check whether the following software packages are installed on the server.
# Rpm-qa | grep nfs
Nfs-utils-1.0.9-16.e15
Nfs-utils-lib-1.0.8-7.2
2. Configure the NFS server configuration file:/etc/exports
/Sharedir: the shared directory. The permission is restricted by rw and local permissions.
192.168.1.22/24: Allow access from all machines in the 192.168.1.0 network segment
# Vim/etc/exports
# Cat/etc/exports
/1_dir 192.168.1.22/24 (rw)
3. Restart the NFS service.
# Service nfs restart
NFS client Configuration:
1. Confirm to install the portmap package
# Rpm-qa | grep portmap
Portmap-4.0-65.2.2.1
2. Enable the portmap service
# Service portmap restart
3. view the shared directory of an NFS server
192.168.1.22: IP address of the NFS server
# Showmount-e 192.168.1.22
Export list for 192.168.1.22:
/Optional dir 192.168.1.22/24
4. shared directory for mounting servers
-T nfs: The file system format of the mounted file, which can be omitted.
# Mount-t nfs 192.168.1.22:/1_dir/mnt/