What is NFS
Network file system, the main function is to allow different hosts to share files or directories through the network (usually LAN)
NFS belongs to the local file storage service
Disadvantage 1:
1234567 |
windows上无法使用 如果想实现windows与Linux系统结合,采用文件数据共享 a. FTP服务 b.samba服务 |
Disadvantage 2:
12345 |
在高并发场景,以及存储量比较高的场景,对数据安全性要求比较高的场景 需要采用分布式存储:Moosefs(mfs)、FastDFS 无法在服务器中看到真实的文件信息 |
Scenarios for NFS shared network file system applications
Mainly used to store data uploaded by users on the Web server, pictures, attachments, videos, audio, avatars
NFS File system has meaning
achieve data sharing, consistent data consistency
Software implementation: Local file system NFS, Distributed File System MFS
Hardware implementation: IBM (server minicomputer mainframe storage DS V7000 V5000) Oracle EMC = go to IoE
How NFS Network file systems work
After setting up a shared directory/video on the server Side of NFS, other clients with access to the NFS server can attach the shared directory/video to a mount point on the client's local site (which is actually a directory, which can be assigned at will). The two NFS client local mount points in the figure are/v/video and/video, respectively, and the mount points for different clients can vary.
After the client is properly mounted, you can view all the data in the directory that is shared by the NFS server-side/video through the/v/video or/video directory where the NFS client's mount point resides. When viewed on the client side, the/video directory on the NFS server is equivalent to the client's local disk partition or directory, with almost no difference in usage, based on NFS share permissions granted by the NFS servers and Local system permissions on the shared directory, as long as the operation is mounted on the specified NFS client Video or/v/video directory, you can easily access the data to the/video directory on the NFS server side.
NFS Service Workflow
To implement the NFS service, first the RPC service is started, and then the NFS service, when the NFS service starts, it sends the registration port information of the NFS service to the RPC service, and when the client requests the NFS service, it sends a request to the RCP service. The RPC service then replies the port back to the client (the port that the RPC itself is returned to), and the client can transmit data via the port request.
NFS Service Deployment NFS server-side installation
First verify that the software is installed, and install the NFS service-related software without installing it
[[email protected] ~]# Rpm-qa |grep nfs[[email protected] ~]# rpm-qa |grep RPC
If it is not installed, install the Rpcbind nfs-utils Service program and verify that the installation is successful
Yum install-y nfs-utils Rpcbindrpm-qa nfs-utils rpcbind
Writing an NFS configuration file
[Email protected] ~]# cat/etc/exports/data 172.16.1.0/24 (Rw,sync)
Configuration file Content Introduction
Part I:/data specifying shared directory information (indicating directory information that local NFS services need to share) Part II: 172.16.1.0/24 Specifies a network segment information that allows the specified network segment host to be mounted to the third part of my local shared directory: (RW, Sync) means to define shared parameter information (which means that the client accesses the directory's permission settings) RW indicates read and write, permissions set on the shared directory, Sync sync parameters, data is written to NFS server memory and is immediately synced to disk = = stored directly on the hard disk
Configuration file Parameters Introduction
RW read and write Ro read -only sync parameters, the data is written to the NFS server memory, will be synchronized to the disk immediately-advantages: security, disadvantage: poor performance async async, first to memory, regardless of data to the hard disk No_root_ Squash indicates that the root user does not map root_squash that the root user does the mapping All_squash that all users are mapped
Create a shared directory and set permissions
[Email protected] ~]# mkdir/data-p[[email protected] ~]# chown-r Nfsnobody.nfsnobody/data/[[email protected] ~]# LL- D/data/drwxr-xr-x 2 nfsnobody nfsnobody 4096 Oct 12:06/data/Description: The NFS shared directory management user is nfsnobody, this user is not created, and the NFS software is automatically created when installing
Start the service
Start the RPC service first
[Email protected] ~]#/etc/init.d/rpcbind startstarting rpcbind: [ OK ]
Rpcbind Startup Information View
[[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 If the NFS service is not started, this information
Second, start the NFS service [Email protected] ~]#/etc/init.d/nfs startstarting NFS Services: [ OK ]starting NFS quotas: [ OK ] Starting NFS Mountd: [ OK ]starting NFS daemon: [ OK ]starting RPC idmapd: [ OK] ]
View information after NFS startup[[email protected] ~]# rpcinfo-p localhost program vers proto Port service 100000 4 TCP 111 Portmap Per 100000 3 TCP 111 Portmapper 100000 2 TCP 111 portmapper 100000 4 UDP 111 Portmappe R 100000 3 UDP 111 portmapper 100000 2 UDP 111 portmapper 100011 1 UDP 875 Rquotad 100011 2 UDP 875 Rquotad 100011 1 tcp 875 Rquotad 100011 2 tcp 875 Rquotad 100005 1 UDP 41601 mountd 100005 1 tcp 26925 mountd 100005 2 udp 27046 mountd 100005 2 tcp 32480 MOUNTD 100005 3 UDP 61072 mountd 100005 3 tcp 39844 mountd 100003 2 TCP 2049 NFS 100003 3 TCP 2049 NFS 100003 4 TCP 2049 NFS 100227 2 TCP 2049 nfs_acl 100227 3 TCP 2049 Nfs_acl 100003 2 UDP 2049 NFS 100003 3 UDP 2049 NFS 100003 4 UDP 2049 NFS 100227 2 UDP 2049 Nfs_acl 100227 3 UDP 2049 nfs_acl 100021 1 udp 22703 nlockmgr 100021 3 udp 22703 nlockmgr 100021 4 UDP 22703 nlockmgr 100021 1 tcp 26776 nlockmgr 100021 3 tcp 26776 nlockmgr 100021 4 t CP 26776 Nlockmgr
Viewing mount information for NFS services [Email protected] ~]# showmount-e localhostexport list for 10.0.0.31:/data 172.16.1.0/ 24 Note: localhost can be replaced with an IP address here: Server-side Deployment configuration complete
Client for NFS Deployment
The first thing is to see if the software has been downloaded and installed
In fact, the client does not need to install NFS, but does not install the NFS software client can not use the Showmount command, and does not recognize the NFS file system type
After the confirmation is finished, the service can be started directly or not.
Check to see if there are directories on the NFS server that can be shared mounted
[Email protected] ~]# rpm-qf ' which showmount ' nfs-utils-1.2.3-75.el6.x86_64
[[email protected] mnt]# showmount-e 172.16.1.31Export list for 172.16.1.31:/data 172.16.1.0/24
Description: Showmount command used, need to install nfs-utils software
Mount the NFS client and set directory permissions
Mount-t NFS 172.16.1.31:/data/mntchown-r Nfsnobody.nfsnobody/mnt
Check test [[email protected] mnt]# df-hfilesystem Size used Avail use% mounted On/dev/sda3 8.8G 1.5G 6.9G 18%/tmpfs 238M 0 238M 0%/dev/shm/dev/sda1 190M 35M 146M 19%/ Boot172.16.1.31:/data 8.8G 1.5G 6.9G 18%/mnt
Then process the file test
The local NFS client makes the redaction data equivalent to the operations performed in the NFS server-side shared directory
Processing files on the client
[email protected] mnt]# Touch szsn.txt
[Email protected] mnt]# lltotal 0-rw-r--r--1 nfsnobody nfsnobody 0 Oct 11:25 szsn.txt
Committed to youth [[email protected] mnt]# \rm-f szsn.txt
Check on the service side
[Email protected] data]# lltotal 0-rw-r--r--1 nfsnobody nfsnobody 0 Oct 11:25 szsn.txt
Committed to juvenile [[email protected] data]# Lltotal 0
This is the completion of the building, Bo Master where there is not good to write, welcome to point out that I will definitely improve.
Linux NFS Storage Service Deployment