NFS File System
1. NFS Service Introduction
1.1 What is NFS service
NFS (Network File System) is a network file system, which allows computers in the network to share resources through the TCP/IP network. In the application of NFS, the client application of the local NFS can transparently read and write files located on the remote NFS server, just like accessing local files, which means that the client PC can mount the directory provided by the NFS server and mount it. After loading, this directory looks like a local disk partition. You can use disk-related commands such as cp, cd, mv, rm, and df.
1.2 Advantages and disadvantages of NFS service
1.2.1 Advantages
a. Save local storage space, store commonly used data on a server and access it through the network
b. Simple and easy to use
c. Convenient deployment is very fast and maintenance is very simple
1.2.2 Disadvantages
a. Limitations are prone to single points of failure, and all clients cannot be accessed if the server is down
b. NFS efficiency/performance is limited under high concurrency
c. The client has no user authentication mechanism, and the data is transmitted in clear text, and the security is general (generally recommended to use in LAN)
d. The data of NFS is clear text, and the integrity of the data is not verified
e. When multiple machines mount NFS server, connection management and maintenance is troublesome
The basic principle of NFS is “to allow different clients and servers to share the same file system through a set of RPC”. It is independent of the operating system and allows different hardware and operating system systems to share files together.
NFS relies on the RPC protocol during file transfer or information transfer. RPC, Remote Procedure Call is a mechanism that enables clients to execute programs in other systems. NFS itself does not provide information transmission protocols and functions, but NFS allows us to share data through the network, because NFS uses some other transmission protocols. And these transfer protocols use this RPC function. It can be said that NFS itself is a program using RPC. Or NFS is also an RPC SERVER. So whenever you use NFS, you must start the RPC service, whether it is NFS SERVER or NFS CLIENT. In this way, SERVER and CLIENT can realize the correspondence of PROGRAM PORT through RPC. The relationship between RPC and NFS can be understood as follows: NFS is a file system, and RPC is responsible for the transmission of information.
2. Related documents
/etc/exports nfs shared directory and definition of shared options
/etc/sysconfig/nfs nfs service configuration file, which can define nfs service port
3. Related Services
rpc related services
rpc.statd check file consistency
rpc.rquotad remote disk quota process
rpc.mountd rights management verification
rpc.lockd multi-user login lock file
nfsd nfs main process
V. Server (192.168.160.3)
Install the server software:
[root@myp ~]# yum install nfs-utils
[root@myp ~]# yum install rpcbind (When using nfs, you will use rpc)
Define a shared directory
edit / etc / exports (in addition to the parameters defined in this document, / var / lib / nfs / etab)
Format: shared directory host name / IP (parameter 1, parameter 2)
The host name/IP can be a network segment or a specific IP (there are three expressions)
192.168.160.3 (specific IP)
192.168.160.0/24 (192.168.160 network segment)
192.168.160.* (192.168.160 network segment)
(Full network segment)
[root@myp lbc]# cat /etc/exports
/data 192.168.160.3(rw,all_squash)
/lbc 192.168.160.9(rw,all_squash)
Parameters:
ro: read-only sharing
rw: read and write
sync: when reading and writing data, the data is synchronized to the hard disk of the nfs server before returning to
async: data is written to the memory buffer first, and the hard disk is only written to the hard disk when it is idle. Efficiency, but the opportunity to lose data.
all_squash: All users are compressed into nfs anonymous users nfsnobody
root_squash: compressed root users into nfs anonymous users
no_root_squash: root users are not compressed.
-Restart the service:
service nfs restart
5. Client configuration (192.168.160.9)
1. Install client software
yum install nfs-utils
2. Check the mounting status of the nfs server
[root@pankajconnect lbc]# showmount -e 192.168.160.3
Export list for 192.168.160.3:
/lbc 192.168.160.9
/data 192.168.160.9
3. Mount the shared directory of the nfs server:
mount -t nfs IP:DIR LOCAL_DIR
This mounting method is only temporary and can be written to the file /etc/rc.local or /etc/fstab
[root@pankajconnect ~]# mkdir /mnt/lbc;mount -t nfs 192.168.160.3:/lbc /mnt/lbc
Thanks for reading this post.