1. Introduction
NFS (abbreviation of Network FileSystem) was first developed by the company Sun. Its biggest function is to allow different machines and different operating systems to share files through the network. In NFS applications, the local NFS client application can transparently read and write files on the remote NFS server, just like accessing local files.
2. Installation and deployment
1. Package installation
yum install -y nfs-utils rpcbind
2. Modify shared configuration
vim /etc/exports
#[分享目录] [第一部主机(权限)] [可用主机名] [可用通配符]
/data/pubilic 172.16.120.0/24(rw) *(ro)
/data/www 172.16.120.0/24(sync,rw,no_root_squash)
Permission parameter description:
parameter | Description |
---|---|
ro | Read-only access |
rw | Read and write access |
sync | Synchronously write data to the memory buffer and disk |
async | Save the data in the memory buffer first, and then write it to disk |
secure | Clients can only connect using ports less than 1024 |
insecure | Allow clients to connect using ports greater than 1024 |
wdelay | Check whether there are related write operations, and if so, execute these write operations together |
no_wdelay | If there is a write operation, it will be executed immediately and should be used in conjunction with sync |
hide | Do not share its subdirectories in the NFS shared directory |
no_hide | Shared NFS directory subdirectories |
subtree_check | If the shared directory is a subdirectory, force NFS to check the permissions of the parent directory |
no_subtree_check | If the shared directory is a subdirectory, do not check the parent directory permissions |
all_squash | UID and GID of shared files map anonymous users |
no_all_squash | Keep UID and GID of shared files |
root_squash | All requests of the root user are mapped to the same permissions as anonymous users |
no_root_squash | The root user has full administrative access to the root directory |
anonuid | Specify the UID of the anonymous user in the /etc/passwd file of the NFS server |
anongid | Specify the GID of the anonymous user in the /etc/passwd file of the NFS server |
noexec | Prevent execution of binary programs on mounted file systems |
sec=mode | Specify the security type of NFS connection authentication |
3.启动服务
systemctl start rpcbind
systemctl start nfs
systemctl enable rpcbind
systemctl enable nfs
4. Common commands #Reload
display share
exportfs -rv #View
remote nfs shared directory
showmount -e 172.16.120.101
5. Client mount
mount -t nfs 172.16.120.101:/data/www /var/html/www