-
NFS Introduction
-
Scenarios
-
NFS installation and deployment
-
NFS Share
-
The client mount NFS shares
A, NFS introduction
NFS (Network File System) that is a network file system that allows TCP / IP network to share resources between computers on the network. In the application of the NFS, the NFS client's local application can transparently read and write files located on a remote NFS server, just like access local files.
The benefits of NFS: save local storage space, the commonly used data stored on an NFS server and can be accessed through the network, the local terminal will be able to reduce their use of storage space.
NFS system has two main parts:
NFS server machine: by NFS protocol to share files to the network.
NFS client machine: a network mount the NFS share to the local.
Second, the application scenarios
Shared storage server: image server, video server, etc.
Home directory Roaming: the domain user's home directory server
File Server: The content file storage server
Three, NFS installation deployment
Conventions: used in this experiment is centos7.5_x86_64 machine systems, computer name: baism.ayitula.com, IP address 192.168.11.16/24 turn off the firewall and SELINUX..
a, nfs mounting
[the root baism @ ~] # yum the install NFS-utils -Y B, NFS boot [baism the root @ ~] # systemctl-NFS Server enable the Created from the symlink / etc / systemd / System / Multi-User. target.wants / nfs-server.service to /usr/lib/systemd/system/nfs-server.service. c, nfs start because of dependencies between services, let's make sure before you start the NFS rpcbind start [root @ baism ~ ] # systemctl the rpcbind IS Active- Active [baism the root @ ~] # start NFS systemctl D, verification start [baism the root @ ~] # systemctl IS-NFS Active Active
Four, NFS share
teaching sample
New directory / public
Read-only manner shared directory / public system can simultaneously access is 192.168.11.0 domain
New directory / protected
The way to read and write shared directory / protected system access can be 192.168.11.0 domain
Create a shared directory
[root @ baism ~] # mkdir / public
[root @ baism ~] # mkdir / protected
because the client user is to mount nfsnobody, this question requires the client to mount read-write, we are establishing the root user directory, so give other people permission to 7
[root @ baism ~] # chmod 757 / protected / via / etc / exports file defines a shared directory [root @ baism ~] # CAT / etc / exports / public 192.168.11.0/ 24-(ro) / protected 192.168.11.0/24(rw) share format: a shared directory absolute path to unauthorized access or IP network segment (1 rights, privileges 2) permission Description ro read-only access rw read and write access to sync all when requested data is written to the shared async NFS before writing the corresponding request data may secure NFS 1024 or less secure TCP / IP port by sending
NFS transmitted through the port in the insecure above 1024
if multiple users to write NFS directories, grouping the writing (the default) wdelay
no_wdelay If multiple users to write NFS directory, written immediately, when using the async, without this settings.
hide the NFS shared directory does not share its subdirectories
no_hide shared NFS subdirectory of
subtree_check if a shared subdirectory / usr / bin or the like, forced through the parent directory permissions NFS (default)
to no_subtree_check above relative, not check the parent directory permissions
UID all_squash share files and GID mapping anonymous user anonymous, for the public directory.
no_all_squash reserved share files UID and GID (default)
root_squash root user of all requests mapped to as anonymous users the same rights (default)
no_root_squash root user full administrative access have root
anonuid = xxx specify the NFS server / etc / passwd file in the anonymous user's UID
anongid = xxx specify the NFS server / etc / passwd file in the anonymous user's GID
By / etc / exports output does not need to restart the NFS sharing service, simply exportfs command to take effect by NFS shared management can
exportfs - NFS shared file system management list exportfs command: -a or cancel all open shared directories. -o options, ... specify a sharing option, similarly as in exports (5) mentioned. -i Ignore / etc / exports file, so that only default and command-line options specified. -r reshare all directories. It enables / var / lib / nfs / xtab and / etc / exports synchronization. It / etc / exports in the deleted entries from / var / lib / nfs / xtab, the cores share a table is no longer any valid entries removed. -u cancel one or more shared directories. -f In 'new' mode, flush any thing outside the kernel shared table. Any active clients will get the new shared items mountd added in their next request. -v output details. When the shared or unshared show what you are doing. Displays the current list of shares when the display while sharing options. Uninstall all share [root @ baism ~]
# Exportfs -au remount all [root @ baism ~] # exportfs -ar reload the list of shared files / etc / exports, set to take effect [root @ baism ~] # exportfs -r view the shared directory [root @ baism ~] # the exportfs -v / public 192.168.11.0/24(sync,wdelay,hide,no_subtree_check , sec = SYS, RO, Secure, the root_squash, no_all_squash) / protected 192.168.11.0/24(sync,wdelay,hide,no_subtree_check , sec = SYS, RW, Secure, the root_squash, no_all_squash)
Fifth, the client mount the NFS share
Use showmount command to view the remote nfs server shared directory
[root @ Slave ~] # showmount -e 192.168.11.16
Export List for 192.168.11.16:
/ protected 192.168.11.0/24
/ public 192.168.11.0/24 new mount point [root ~ @slave] # mkdir / mnt / public [root @ Slave ~] # mkdir / mnt / protected mount NFS server shared directory [root @ Slave ~] # 192.168.11.16:/public Mount -t nfs / mnt / public / [root @ Slave ~] # 192.168.11.16:/protected Mount -t nfs / mnt / protected / verification mount [root @ Slave ~] # Mount | egrep "(public | protected)" 192.168.11.16:/public ON / mnt / public of the type NFS4 (rw, relatime , Vers
=4.1,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.11.116,local_lock=none,addr=192.168.11.16)
192.168.11.16:/protected on /mnt/protected type nfs4 (rw,relatime,vers=4.1,rsize=524288,wsize=524288,namlen=255,hard, proto = TCP , Port = 0 , Timeo = 600 , Retrans = 2 , sec = SYS , clientaddr = 192.168.11.116 , local_lock = none , addr = 192.168.11.16) test access [the root @ Slave ~] # Touch / mnt / public / the Test Touch: unable to create "/ mnt / public / test" : read-only file system [root @ Slave ~] # Touch / mnt / protected / the Test [root @ Slave ~] # LS / mnt / protected / the -l The total amount of 0 -rw-R & lt - r-- . 1 nfsnobody is nfsnobody is 0 2 dated 28 11:52 Test
Transfer: http://book.ayitula.com/wen-jian-fu-52a1-nfs-fu-wu-qi.html