I. SYSTEM environment
# cat/etc/redhat-release CentOS Linux release 7.3.1611 (Core)
Two. Installing NFS Services
1. See if the System has NFS installed
Rpm-qa | grep Nfsrpm-qa | grep rpcbind
2. Install NFS
Yum-y Install Nfs-utils Rpcbind
3. Server-side configuration
Mkdir /nfs-datachmod 666 /nfs-data editing the main profile:/etc/exportsvim /etc/exports / NFS-DATA  192.168.101.128/24 (Rw,no_root_squash,no_all_squash,sync) Common parameter description: RW ro -- The permissions shared by this directory are read-write (read-write) or read-only (read-only), but can eventually be read or written, or file system rwx and identity related. Sync async --sync means that data is written synchronously to the memory and hard disk,async the data is staged in memory, not directly to the hard disk. No_root_squash root_squash --Client Use the NFS file system if the account is root , how can the system determine the identity of this account? By default, the identity of the client root will be compressed by the root_squash settings nfsnobody, the system will be more secure for the server. But if you want to open the client to use the root identity to operate the server's file system, then this will have to open no_root_squash ! all_squash --regardless of the identity of the user who is logged in NFS , His identity will be compressed into anonymous users, usually nobody (nfsnobody) . configuration Effective exportfs -r start Rpcbind, NFS services systemctl start rpcbind.service systemctl start nfs.service Check the registration status of RPC services rpcinfo -p localhost Test:# showmount -e localhostexport list for Localhost:/nfs-data 192.168.101.128/24
4. Client Configuration
Installing the Nfs-utils client yum-y install nfs-utils create mount directory mkdir/data View server-side Mount information: # SHOWMOUNT-E 192.168.101.128Export list for 192.168 .101.128:/nfs-data 192.168.101.128/24 to improve the stability of NFS, using TCP protocol Mounts, NFS defaults to UDP Protocol mount-t NFS 192.168.101.128:/nfs-data/data- o Tcp,nolock
5. Fixed NFS service port (This step is ignored if the firewall is turned off for ease of configuring the firewall)
When NFS starts, it randomly launches multiple ports and registers with RPC, which makes it a bit cumbersome to use iptables to restrict NFS ports, and you can change the configuration file to fix NFS service-related ports. #rpcinfo -p localhost program vers proto port service 100000 4 tcp 111 portmapper 100000 3 tcp 111 portmapper 100000 2 tcp 111 portmapper 100000 4 udp 111 portmapper 100000 3 udp 111 portmapper 100000 2 udp 111 Portmapper 100024 1&nbSp; udp 59175 status 100024 1 tcp 36247 status 100005 1 udp 20048 mountd 100005 1 tcp 20048 mountd 100005 2 udp 20048 mountd 100005 2 tcp 20048 mountd 100005 3 udp 20048 mountd 100005 3 tcp 20048 mountd 100003 3 tcp 2049 nfs 100003 4 tcp 2049 nfs 100227 3 tcp 2049 nfs_acl 100003 3 udp 2049 nfs 100003 4 udp 2049 nfs 100227 3 udp 2049 nfs_acl 100021 1 udp 43725 nlockmgr 100021 3 udp 43725 nlockmgr 100021 4 udp 43725 nlockmgr 100021 1 tcp 45552 Nlockmgr 100021 3 tcp 45552 nlockmgr 100021 4 tcp 45552 nlockmgr Edit configuration file: vim /etc/ sysconfig/nfs rquotad_port=30001 lockd_tcpport=30002 lockd_udpport=30002 mountd_port=30003 statd_port= 30004 Restart Service: systemctl start nfs.service Check again, the port is fixed: rpcinfo -p localhost
This article is from the "Hello World" blog, so be sure to keep this source http://nxyboy.blog.51cto.com/10511646/1933615
Construction and configuration of NFS server under Linux