CentOS7 configure NFS (Network File System) and its use

1. The server configuration

1.1. NFS installation

yum  -y install nfs*

 

1.2. NFS and see if the installation RPCBIND

rpm -qa | grep nfs
rpm -qa | grep rpcbind

 

 

 

1.3. Creating a shared directory and shared

1.3.1. mkdir / mnt / nfs

mkdir / mnt / nfs

 

1.3.2.  vim /etc/exports

vim /etc/exports
/mnt/nfs 192.168.58.130/*(rw,ro,no_root_squash,no_all_squash,sync)

 

 

 

Note: "* " and "( " there is no space between

1.4. Start NFS and RPCBIND, is set to boot from the start

systemctl start nfs
systemctl start rpcbind
systemctl enable nfs
systemctl enable rpcbind
service nfs start
service rpcbind start

 

1.5. Check whether to share success

showmount -e localhost / 192.168 . 58,129

 

 

 

2. Client Configuration

2.1. NFS installation

yum  -y install nfs*

 

2.2. NFS and see if the installation RPCBIND

rpm -qa | grep nfs
rpm -qa | grep rpcbind

 

2.3. Start NFS and RPCBIND, is set to boot from the start

systemctl start nfs
systemctl start rpcbind
systemctl enable nfs
systemctl enable rpcbind
service nfs start
service rpcbind start

 

2.4. Create a mount directory

mkdir /data

 

2.5. Check whether to share success

showmount -e localhost / 192.168 . 58,129

 

 

 

2.6. Network mounts

mount -t nfs -o nolock 192.168.58.129:/mnt/nfs /data

 

2.7. Check whether to mount a successful

df -TH

 

3. Once mounted as read-only access

Conditions 1: / etc / exports in the shared directory must be "rw";

Condition 2: / etc / exports can be no spaces between the host and the IP authority;

Condition 3: / etc / exports client user can specify the mapping of ID.

Conditions 4: exportfs -arv

Conditions 5: service nfs restart

Conditions 6: service rpcbind restart

/ Etc / exports only the user identification UID and mapping GID, regardless of the user name.

 

 Configuration details:

##############输出目录:###################

输出目录是指NFS系统中需要共享给客户机使用的目录;

##############客户端:####################

客户端是指网络中可以访问这个NFS输出目录的计算机

#############客户端常用的指定方式###########

    指定ip地址的主机:192.168.0.200

    指定子网中的所有主机:192.168.0.0/24 192.168.0.0/255.255.255.0
    指定域名的主机:nfs.cnhzz.com
    指定域中的所有主机:*.cnhzz.com
    所有主机:*

##################选项:####################

选项用来设置输出目录的访问权限、用户映射等。

NFS主要有3类选项:
1)访问权限选项
    设置输出目录只读:ro
    设置输出目录读写:rw
2)用户映射选项
    all_squash:将远程访问的所有普通用户及所属组都映射为匿名用户或用户组(nfsnobody);
    no_all_squash:与all_squash取反(默认设置);
    root_squash:将root用户及所属组都映射为匿名用户或用户组(默认设置);
    no_root_squash:与rootsquash取反;
    anonuid=xxx:将远程访问的所有用户都映射为匿名用户,并指定该用户为本地用户(UID=xxx);
    anongid=xxx:将远程访问的所有用户组都映射为匿名用户组账户,并指定该匿名用户组账户为本地用户组账户(GID=xxx);
3)其它选项
    secure:限制客户端只能从小于1024的tcp/ip端口连接nfs服务器(默认设置);
    insecure:允许客户端从大于1024的tcp/ip端口连接服务器;
    sync:将数据同步写入内存缓冲区与磁盘中,效率低,但可以保证数据的一致性;
    async:将数据先保存在内存缓冲区中,必要时才写入磁盘;
    wdelay:检查是否有相关的写操作,如果有则将这些写操作一起执行,这样可以提高效率(默认设置);
    no_wdelay:若有写操作则立即执行,应与sync配合使用;
    subtree_check:若输出目录是一个子目录,则nfs服务器将检查其父目录的权限(默认设置);
    no_subtree_check:即使输出目录是一个子目录,nfs服务器也不检查其父目录的权限,这样可以提高效率;

 

Guess you like

Origin www.cnblogs.com/hx1998/p/11260286.html