Why use NFS
The NFS (Network File system), which is one of the file systems supported by FreeBSD, allows computers in the network to share resources across TCP/IP networks. In an NFS application, a local NFS client application can transparently read and write to files located on the remote NFS server, just as you would access a local file.
NFS was first developed by Sun Corporation,
Simply put: It is possible to use the network, so that different hosts, different operating systems can share storage.
The following are the most obvious benefits of NFS:
1. Saving local storage space, storing common data on one NFS server and network access, the local terminal can reduce the use of its own storage space.
2. The user does not need to have a home directory on every machine in the network, the home directory can be placed on the NFS server and can be accessed on the network.
3. Some storage devices CDROM and zip (a high storage density disk drive and disk) can be used on the network by other machines. This can reduce the number of removable media devices across the network.
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.
First, the preparation phase: (Client and server)
NFS server: 192.168.0.200 Centos6.5 64-bit operating system
NFS Client: 192.168.0.201 Centos6.5 64-bit operating system
Ii. List of software required for NFS server
Nfs-utils: This is the NFS service main program (contains RPC.NFSD, RPC.MOUNTD, daemons)
Rpcbind: This is the centos6.x RPC main program (centos5.x for Portmap)
Third, check whether the software is installed
Both the client and the server have to check
#rpm-qa nfs-utils Rpcbind
If not installed in the system through the Yum command to install the above two packages
#yum install-y nfs-utils Rpcbind
Iv. Start NFS Service-related services
Service-side operation:
#service rpcbind Status View state
#service Rpcbind Start
#service Rpcbind Stop Stop
#service Rpcbind Restart Restart
#chkconfig rpcbind off//boot does not start Rpcbind, boot start rpcbind write to/etc/rc.local, because Rpcbind and NFS have boot order, if you teach the system default rules boot from boot, occasionally boot sequence error, Cause the service to not work properly
Start the NFS service
#service NFS Start Start
View Status #service NFS status
#service NFS Stop Stop
#service NFS REStat Restart
#netstat-ANTP | grep 2049 NFS Default port number 2049
#chkconfig NFS Off//boot does not start NFS, boot Rpcbind write to/etc/rc.local
V. Configuring the NFS Server
The start of NFS is described earlier, and next we configure the NFS server configuration
/etc/exports is the configuration file for the NFS program. And the default is empty
The configuration format for the/etc/exports file is:
NFS Shared directory NFS Client address 1 (parameter 1, parameter 2, Parameter 3 ...) client Address 2 (parameter 1, parameter 2, Parameter 3 ...)
NFS Shared directory NFS client address (parameter 1, parameter 2, Parameter 3 ...)
We are here to share to 192.168.0.0/24 all hosts
Restart the NFS service after the configuration is complete exports
#service NFS Restart
#showmount-E 127.0.0.1 #查看本机挂载情况
#mount-T NFS 192.168.0.200:/cxj/mnt #在本机测试挂载
Vi. Configuring Client for NFS
On the client, execute on 0.201
The client also needs to install the Rpcbind and nfs-utils software, just start the rpcbind.
And then do the following
#showmount-E 192.168.0.200
#mount-T NFS 192.168.0.200:/cxj/mnt
Since then, we have successfully configured, but don't be happy. We just mounted the action, but we don't have permission to perform various operations on the mounted directory.
On the NFS server side configuration:
#grep 65534/etc/passwd
We can now perform various operations on the Mount directory, but we are not done yet. We need to put the Mount command inside the rc.local,
We do not put the Mount command in Fstab, because fstab than the network first boot, will appear to mount not on the network NFS
If you have any questions about this article, please add the following discussion
LINUX6/CENTOS6 NFS Detailed configuration