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 
启动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 ~]# mkdir /nfs/shared -p
[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(rw,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
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值