I. Introduction to NFS
NFS is the abbreviation for the network file system, which is the web filesystem. A type of distributed file contract, developed by Sun Company. The function is to allow different machines, different operating systems to share personal data through the network, so that the application can access the data on the server disk through the network.
NFS relies on the RPC protocol during file transfer or information transfer. RPC, remote procedure invocation (Procedure call), is a mechanism that enables clients to perform programs in other systems. NFS itself does not provide the protocol and functionality for transmitting information, but NFS allows us to share information over the network, because NFS uses the transport protocol provided by RPC, which can be said to be a program used by the PRC.
NFS server, RPC protocol, client can be understood as the relationship between listings, intermediaries, tenants:
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/82/03/wKiom1dHrUmxCO7zAAC0QiLEz9A270.png "title=" NFS build. png "Width=" "height=" 338 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:450px;height:338px; "alt=" Wkiom1dhrumxco7zaac0qilez9a270.png "/>
Second, the system environment
CentOS Release 6.7 (Final) 2.6.32-573.el6.i686
NFS ip:172.16.1.31
Web ip:172.16.1.8
/etc/init.d/iptables status
Iptables: Firewall is not running
Selinux:getenforce Permissive
Third, start to build
1) Software Installation, NFS only need to install two software, in general, as the system default software installed
"Rpcbind" CentOS under the RPC main program
"Nfs-utils" NFS service main program, including basic commands and monitoring Programs for NFS
[email protected] ~]# Yum install rpcbind nfs-utils |
2) Turn on RCP service
[[email protected] ~]#/etc/init.d/rpcbind start |
View Rpcbind Service ports
[Email protected] ~]# Netstat-antlp|grep Rpcbind TCP 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1368/rpcbind |
See if there is a port registration on the RPC service at this time
[Email protected] ~]# 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 |
3) Turn on NFS service
[[email protected] ~]#/etc/init.d/nfs start |
Now RPC should be able to see a lot of newly registered NFS ports.
[[email protected] ~]# rpcinfo-p localhost 100003 2 TCP 2049 NFS 100003 4 TCP 2049 nfs 100227 3 TCP 2049 nfs_acl |
Set up two services to boot from
[Email protected] ~]# chkconfig rpcbind on [[email protected] ~]# chkconfig NFS on |
4) server-side configuration shared directory (/data)
Confirm Rpcbind, NFS service process is normal before configuration
[Email protected] ~]#/ETC/INIT.D/NFS status [Email protected] ~]#/etc/init.d/rpcbind status [Email protected] ~]# ps-ef|egrep "Rpc|nfs" RPC 1368 1 0 00:14? 00:00:00 Rpcbind Rpcuser 1391 1 0 00:14? 00:00:00 RPC.STATD Root 1440 2 0 00:14? 00:00:00 [rpciod/0] Root 1449 1 0 00:14? 00:00:00 Rpc.rquotad Root 1454 1 0 00:14? 00:00:00 Rpc.mountd Root 1461 2 0 00:14? 00:00:00 [NFSD4] Root 1462 2 0 00:14? 00:00:00 [Nfsd4_callbacks] Root 1463 2 0 00:14? 00:00:00 [NFSD] Root 1464 2 0 00:14? 00:00:00 [NFSD] Root 1465 2 0 00:14? 00:00:00 [NFSD] Root 1466 2 0 00:14? 00:00:00 [NFSD] |
Create a shared directory and authorize ("Nfsnobody")
#nfsnobody User is automatically created after the RPC, NFS process is enabled
[Email protected] ~]# Mkdir/data [Email protected] ~]# chown-r nfsnobody.nfsnobody/data |
Modifying a server-side configuration file (/etc/exports)
[Email protected] ~]# vim /etc/exports
#share/data by Oldboy for Bingbing at 20160524 /data 172.16.1.0/24 (Rw,sync) #### /data1 172.16.1.0/24 (rw,sync,all_squash,anonuid=65534, anongid=65534) |
Attention!
#此时可以修改 "Anonuid" value to modify the NFS default virtual user, provided that the user exists in the system, you can specify "-s/sbin/nologin"
View System-loaded configurations
[Email protected] ~]# Cat/var/lib/nfs/etab /data 172.16.1.0/24 (rw,sync,wdelay,hide,nocrossmnt,secure,root_squash,no_all_squash,no_subtree_check,secure_ Locks,acl,anonuid=65534,anongid=65534,sec=sys,rw,root_squash,no_all_squash) |
Re-smooth Load service
[Email protected] ~]#/etc/init.d/nfs Reload |
Verify that the service, directory, and other configurations are correct and sharing is successful
[Email protected] ~]# SHOWMOUNT-E Export list for nfs01: /data 172.16.1.0/24 |
5) Client Configuration
The client only needs to install the Rpcbind program and confirm that the service is OK
[Email protected] ~]#/etc/init.d/rpcbind status Rpcbind (PID 1361) is running... |
Mount NFS Shared Directory
[Email protected] ~]# mount-t NFS 172.16.1.31:/data/mnt [Email protected] ~]# df-h Filesystem Size used Avail use% mounted on /dev/sda3 6.9G 1.3G 5.2G 20%/ Tmpfs 503M 0 503M 0%/dev/shm /DEV/SDA1 190M 33M 147M 19%/boot 172.16.1.31:/data 6.9G 1.3G 5.2G 20%/mnt |
Auto mount on Boot
echo "Mount-t nfs172.16.1.31:/data/mnt" >>/etc/rc.local |
In addition, the implementation of automatic NFS sharing can also be implemented in/ets/fstab, but at this time the system to open the NETFS service
Because of the possibility of the system in the restart process, first implement mount, and then start the network, there is a mount unsuccessful problem
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/82/07/wKioL1dIBbWzlBewAABkfQ1ndr0059.png "title=" zd6@9u {8opijm5n4fmofojm.png "alt=" Wkiol1dibbwzlbewaabkfq1ndr0059.png "/>
Open Netfs Service
[Email protected] ~]# chkconfig netfs on |
This article comes from the "change from every day" blog, so be sure to keep this source http://lilongzi.blog.51cto.com/5519072/1783858
NFS Build process under Linux