I. Introduction to NFS Services NFS is the abbreviation for the network file system, which is the web filesystem. A contract for the decentralized file system, developed by Sun, was announced in 1984. The function is to enable different machines, different operating systems to share individual data with each other, so that the application can access the data on the server disk through the network, and it is a way to implement disk file sharing among Unix-like systems. The basic principle of NFS is to "allow different clients and services to share the same file system through a set of RPC", which is independent of the operating system, allowing different hardware and operating systems to share files together. 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 some other transport protocols. And these transport protocols are used for this RPC function. It can be said that NFS itself is a program that uses RPC. Or, NFS is also an RPC SERVER. So whenever you use NFS, you start the RPC service, whether it's NFS server or NFS CLIENT. This allows the server and client to implement the program port correspondence via RPC. You can understand the relationship between RPC and NFS: NFS is a file system, and RPC is responsible for the transfer of information. RPC (Remote Procedure call): RPC was a powerful technique for constructing distributed, client-server based applications. Technology for developing distributed, C/S architecture applications. It is based on extending the notion of conventional, or local procedure calling, so that the called procedure need not Exi St in the same address space as the calling procedure. RPC is rooted in the idea of local procedure calls, unlike the process that RPC involves can be located on different hosts. Linux: Programs that provide RPC services, PORTMAP:111/TCP, 111/UDPRPC: Programming technology, simplifying distributedApplication development, RPC:C-RPC-----RPC---SNFs Client-to-NFS Server II, Linux system version Cat/etc/redhat-releasecentos Relea SE 6.5 (Final) uname-r2.6.32-431.el6.x86_64uname-mx86_64 first shut down the network firewall chkconfig iptables off view firewall Chkconfig--list iptables shutdown selinuxsetenforce 03, server network planning 192.168.2.132nfsserver192.168.2.128nfsclient Four, install NFS software 1, first to see if the System installed NFS, Portmap, Rpcbindrpm-qa|grep nfsrpm-qa|grep portmaprpm-qa|grep rpcbind2, install NFS software in two ways 2.1 through Yum Grouplist view not installed Package Group NFS File server2.1.1 installs Yum groupinstall-y "NFS File Server" 2.2 Through the package group install Yum install-y nfs* rpcbind* Five, start NFS software 1, start Rpcbind/etc/init.d/rpcbind start to view the RPC service running status/etc/init.d/rpcbind status2, start Nfs/etc/init.d/nfs start3, View NFS File system showmount-e localhost if the query is empty, the description does not exist for the remote file system that requires configuration 4 in the NFS configuration file, configure the NFS file System 4.1 mkdir/nfs/data-pv4.2 vim/etc/ exports4.3 cat/etc/exports #nfs share/nfs/data/nfs/data 192.168.2.0/24 (rw) 4.4 Restart Nfs/etc/init.d/nfs reloadshowmount-e Localhostexport list for Localhost:/nfs/data 192.168.2.0/24 Six, configure the NFSClient side 1, open the client side RPC serviceService/etc/init.d/rpcbind start2, boot auto chkconfig rpcbind On3, view the results chkconfig--list rpcbind4, view remote NFSServer file system showmount-e 192.168.2.132Export list for 192.168.2.132:/nfs/data 192.168.2.0/245, create a file directory on this machine Mount remote NFS File System 5.1 Create a local directory mkdir/ webimage5.2 mount NFS File System mount-t NFS 192.168.2.132:/nfs/data//WEBIMAGE/6, verifying whether the mount succeeded in creating a file on NFSServer echo "Hello" >> /nfs/data/a.txt on NFSClient to see if the file was created Ll/webimage/total 4-rw-r--r--. 1 root root 6 Jul 10:45 a.txt Create a file in NFSClient echo "1" >>/webimage/b.txt-bash:b.txt:permission denied at this time the client does not have permission to write Into the file if you solve this problem on the NFSServer side give./nfs/data authorization chmod 777-r/nfs/data/to NFSClient to create a file echo "1" >>/webimage/ B.txt View permissions to create files Ll/webimage/b.txt<span style= "White-space:pre" ></span>-rw-r--r--. 1 nfsnobody nfsnobody 2 Jul 11:05/webimage/b.txt------------------------------------------NFS Server Permissions Issues-----------------------------------------------------------------------If you write files to the NFSServer server through NFSClient the default owning group belongs to the person Is nfsnobody, view this default configuration information in Cat/var/lib/nfs/etab/nfs/data 192.168.2.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) In the configuration file you can see Anonuid, Anongid can view user grep 65534/etc/passwdnfsnobody:x:65534:65534:anonymous NFS user:/var/lib/nfs:/sbin/ Nologin so you can directly modify the NFSServer file directory user belongs to the group Chown-r nfsnobody.nfsnobody/nfs/data/to NFSClient to create a file echo "1" >>/ Webimage/b.txt View permissions to create files Ll/webimage/b.txt-rw-r--r--. 1 nfsnobody nfsnobody 2 Jul 11:05/webimage/ B.txt-------------------------------------------------------------------------------------------------------------------- --------------------------------7. Mount this file system automatically when booting (if NFSServer does not start, NFSClient will skip Mount Mount and will not cause the system to boot) cat/etc/ Rc.local #!/bin/sh## This script would be executed *after* all the other init scripts.# you can put your own initialization Stuff in this if you don ' t# want to do the full Sys V style init stuff.touch/var/lock/subsys/local/bin/mount 192.168.2.1 32:/nfs/data//webimAGE/8, mount the file to the system/etc/fstab (typically do not configure the network file system mount in the Fstab file, because the network file system cannot load in the Linux boot process/etc/fstab than the network priority load) <server>: </remote/export> </local/directory> NFS < options> 0 0192.168.2.132:/nfs/data//webimage/nfs Defaults 0 0 <span Style= "White-space:pre" ></span> work need to set the latter two columns to 0 0 otherwise the system will not start
NFS Summary 1, NFS process Description Ps-ef | Egrep "Rpc|nfs" RPC 1581 1 0 10:03? 00:00:00 Rpcbindrpc Service main process root 1617 2 0 10:05? 00:00:00 [rpciod/0]root 3759 1 0 12:33? 00:00:00 Rpc.rquotad disk quota process root 3763 1 0 12:33? 00:00:00 rpc.mountd Rights Management process root 3769 2 0 12:33? 00:00:00 [Nfsd4]root 3770 2 0 12:33? 00:00:00 [Nfsd4_callbacks]root 3771 2 0 12:33? 00:00:00 [Nfsd]nfs Service Master process root 3772 2 0 12:33? 00:00:00 [Nfsd]root 3773 2 0 12:33? 00:00:00 [Nfsd]root 3774 2 0 12:33? 00:00:00 [Nfsd]root 3775 2 0 12:33? 00:00:00 [Nfsd]root 3776 2 0 12:33? 00:00:00 [Nfsd]root 3777 2 0 12:33? 00:00:00 [Nfsd]root 3778 2 0 12:33? 00:00:00 [nfsd]root 3801 1 0 12:33? 00:00:00 RPC.IDMAPD
NFS Common paths
/etc/exports The NFS service master configuration file, where the NFS-specific shared services are configured, is empty by default.
/usr/sbin/exportfsManagement commands for NFS services. You can load the NFS configuration to take effect, and you can configure the NFS shared directory directly, that is, without configuring/etc/exports for sharing. EXPORTFS-RV Smooth Restart
/usr/sbin/showmount is commonly used to view the client side, to view commands for NFS configuration and mounting results.
/var/lib/nfs/etabfull parameter settings file for NFS configuration file (there are many NFS parameters that are not configured but are default)
/var/lib/nfs/xtab suitable for contos5.x to record information about NFS clients that have been mounted, including IP addresses, centos6.x files that do not contain content
NFS Mount Considerations
1. Put the start command and Mount command of the NFS RPC service into the/etc/rc.local and monitor the system mount after booting through the monitoring software.
2. If you decide to consider placing a mount command in/etc/fstab, then the 5th and 6 columns should be 0. That is, do not backup, do not do disk check.
Shared storage NFS