nfs configuration of centos7

NFS is an acronym for Network File System, that is network file system. The client by way of the mount NFS server shared data directory is mounted to a local directory.

nfs Why RPC?
Because NFS support many functions, different functions will use a different program to start, therefore, NFS corresponding function corresponding port can not be fixed.
No fixed port caused by a communication failure between the client and server, so it is necessary to RPC from help.
NFS will be randomly drawn start when several ports and port-related proactive service registry access and functional information to RPC, RPC uses a fixed port 111 to listen for requests from the NFS client
and NFS server returns the correct information to the client port, so that the client and server data can be transmitted.

The server IP is 192.168.186.130 practice client IP is 192.168.186.131

A, NFS service installation configuration

nfs-utils、rpcbind

#   yum install nfs-utils rpcbind

Second, start the rpcbind service

#  systemctl restart rpcbind.service

Check the service status  

# systemctl status rpcbind.service

View rpc

#   lsof -i :111
#   netstat -lntup|grep rpcbind

If the command is not found -bash perform the following command

#  yum install net-tools lsof

To view ports information to rpc nfs service registration

#   rpcinfo -p localhost

Check whether the rpcbind boot

#   chkconfig --list rpcbind

Third, start the NFS service

#    systemctl start nfs.service

View Status

#   systemctl status nfs.service

To view ports information rpc registered again

#   rpcinfo -p localhost

Four, NFS common process Detailed

#  ps -ef|egrep "rpc|nfs"
Copy the code
rpc       13166      1  0 09:01 ?        00:00:00 ./rpcbind
root      13202      2  0 09:02 ?        00:00:00 [rpciod/0]
root      13210      1  0 09:02 ?        00:00:00 rpc.rquotad
root      13214      1  0 09:02 ?        00:00:00 rpc.mountd
root      13220      2  0 09:02 ?        00:00:00 [nfsd4]
root      13221      2  0 09:02 ?        00:00:00 [nfsd4_callbacks]
root      13222      2  0 09:02 ?        00:00:00 [nfsd]
root      13223      2  0 09:02 ?        00:00:00 [nfsd]
root      13224      2  0 09:02 ?        00:00:00 [nfsd]
root      13225      2  0 09:02 ?        00:00:00 [nfsd]
root      13226      2  0 09:02 ?        00:00:00 [nfsd]
root      13227      2  0 09:02 ?        00:00:00 [nfsd]
root      13228      2  0 09:02 ?        00:00:00 [nfsd]
root      13229      2  0 09:02 ?        00:00:00 [nfsd]
root      13252      1  0 09:02 ?        00:00:00 rpc.idmapd
Copy the code

nfsd (rpc.nfsd) main process, mainly the management client can login the server, login ID is discrimination.
mountd (rpc.mountd) NFS file system management, rights management to sign those
rpc.lockd (non-essential) to lock files for clients simultaneously write
rpc.statd (non-essential) to check file consistency
rpc.idmapd name mapping background process

5, configuration NFS boot from the start

# chkconfig rpcbind on
# chkconfig nfs on
# chkconfig --list rpcbind
# chkconfig --list nfs
Six, NFS server configuration
#   vi /etc/exports
exports configuration file format:
FS shared directory NFS Client Address 1 (parameter 1, parameter 2, ...) Client Address 2 (parameter 1, parameter 2, ...)
NFS Client Address:
Specify the IP: 192.168.0.1 
192.168.0.0/24: Specifies the subnet all hosts 
specified by the host domain name: test.com 
specified domain for all hosts: * .test.com 
all hosts: *
parameter:
Copy the code
ro: directory read-only 
rw: read-write directory 
sync: synchronize data written to disk and memory buffers, low efficiency, but can ensure the consistency of data 
async: the first data stored in the memory buffer, write only when necessary the disk 
all_squash: all ordinary users and the respective group of remote access are mapped to an anonymous user or user group (nfsnobody) 
no_all_squash: and all_squash negated (the default setting) 
root_squash: the root user and the respective groups are mapped to an anonymous user or users group (the default setting) 
no_root_squash: and rootsquash negated 
anonuid = xxx: all users remote access are mapped to the anonymous user, and specify that the user is a local user (UID = xxx) 
anongid = xxx: all the user groups remote access They are mapped to the anonymous user account group
Copy the code
E.g:
# /data/tmp 192.168.186.131(rw,sync,all_squash)
The need to create a shared directory on the server
# mkdir -p /data/tmp
# chown nfsnobody.nfsnobody /data/tmp

Nfs reload configuration

#  exportfs -rv

View nfs mount server case

# Showmount -e localhost

Seven mount test

Create a directory on the client

# mkdir -p /data/tmp2
# mount -t nfs 192.168.186.130:/data/tmp /data/tmp2

Mount View

# df -h

Create a file in the server tmp

# touch /data/tmp/1.txt

Is there a file to view the client tmp2

# Ls / data / tmp2

Uninstall mount

# umount /data/tmp2

Guess you like

Origin www.cnblogs.com/soymilk2019/p/11026622.html
Recommended