NFS作业
作者:互联网
手动搭建一个nfs服务器
1. 开放/nfs/shared目录,供所有用户查阅资料
关闭防火墙
[root@cwt-server ~]# systemctl stop firewalld
[root@cwt-server ~]# systemctl disable firewalld
[root@cwt-server ~]# vim /etc/selinux/config
[root@cwt-server ~]# setenforce 0
安装NFS服务
[root@cwt-server ~]# yum install -y nfs-utils rpcbind
启动NFS服务
[root@cwt-server ~]# systemctl start nfs-server rpcbind
编辑配置文件和共享目录
[root@cwt-server ~]# vim /etc/exports
[root@cwt-server ~]# cat /etc/exports
/nfs/shared *(ro,sync)
[root@cwt-server ~]# systemctl restart nfs-server rpcbind
在客户端关闭防火墙
[root@cwt-client ~]# systemctl stop firewalld
[root@cwt-client ~]# systemctl disable firewalld
[root@cwt-client ~]# vim /etc/selinux/config
[root@cwt-client ~]# setenforce 0
安装NFS服务
[root@cwt-client ~]# yum install -y nfs-utils rpcbind
[root@cwt-client ~]# systemctl start nfs-server rpcbind
在客户端查看共享目录
[root@cwt-client ~]# showmount -e 192.168.40.139
Export list for 192.168.40.139:
/nfs/shared *
创建挂载点目录,挂载
[root@cwt-client ~]# mkdir /hanyuce
[root@cwt-client ~]# mount -t nfs 192.168.40.139:/nfs/shared /hanyuce
2. 开放/nfs/upload目录为172.16.12.0/24网段的数据上传目录,并将所有用户及所属的用户组都映射为nfs-upload,其UID与GID均为300
创建共享目录
[root@cwt-server ~]# mkdir /nfs/upload
创建nfs-upload用户 ,UID和GID为300
[root@cwt-server ~]# useradd -r -u 300 nfs-upload
修改配置文件
[root@cwt-server ~]# cat /etc/exports
/nfs/upload 192.168.40.0/24(ro,anonuid=300,anongid=300,sync)
[root@cwt-server ~]# systemctl restart nfs-server rpcbind
在客户端查看共享目录
[root@cwt-client ~]# showmount -e 192.168.40.139
Export list for 192.168.40.139:
/nfs/upload 192.168.40.0/24
创建挂载点目录,挂载
[root@cwt-client ~]# mkdir /chenwanting
[root@cwt-client ~]# mount -t nfs 192.168.40.139:/nfs/upload /chenwanting
在服务器端设置属主和属组
[root@cwt-server ~]# chown nfs-upload.nfs-upload /nfs/upload
[root@cwt-server ~]# cd /nfs
[root@cwt-server nfs]# ll
总用量 0
drwxr-xr-x. 2 root root 6 7月 2 14:37 shared
drwxr-xr-x. 2 nfs-upload nfs-upload 6 7月 2 15:48 upload
标签:作业,cwt,server,client,nfs,NFS,root,upload 来源: https://blog.csdn.net/cwt0314/article/details/94452036