案例需求
以工坊单位为基础,每个工坊设立一个单独共享资源目录,创建FTP虚拟用户名为zhang1-6;权限限制只有下载没有上传的权限,限制最大带宽60KB;zhang1-6用户的家目录名称对应6个不同的工坊名词缩写;新建的一块20G存储磁盘必须挂载在nfs的共享目录上,每7天晚上21点要求增量备份一次nfs的共享数据,到/backup/weekbackup目录下,存放在以日期命名的目录;每14天清除上上一周的备份数据。
规划节点
IP | 主机名 | 节点 |
---|---|---|
192.168.100.11 | FTP | FTP服务器、NFS客户端 |
192.168.100.12 | NFS | NFS服务器 |
NFS配置
1.NFS主机添加一个20G的硬盘
2.查看
3.两台机关闭防火墙及安全规则
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# setenforce 0
4.两台主机都分别安装并启动nfs服务
[root@localhost ~]# yum install -y nfs-utils rpcbind
[root@localhost ~]# systemctl start nfs
[root@localhost ~]# systemctl enable nfs
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl enable rpcbind
[root@localhost ~]# yum install -y nfs-utils rpcbind
[root@localhost ~]# systemctl start nfs
[root@localhost ~]# systemctl enable nfs
[root@localhost ~]# systemctl start rpcbind
[root@localhost ~]# systemctl enable rpcbind
NFS主机查看nfsnobody用户在不在:
[root@localhost ~]# id nfsnobody
uid=65534(nfsnobody) gid=65534(nfsnobody) groups=65534(nfsnobody)
5.NFS主机创建共享目录并赋予权限
[root@localhost ~]# mkdir /sharedir/yyw
[root@localhost ~]# mkdir /sharedir/xcx
[root@localhost ~]# mkdir /sharedir/saas
[root@localhost ~]# mkdir /sharedir/dsj
[root@localhost ~]# mkdir /sharedir/sg
[root@localhost ~]# mkdir /sharedir/jqr
[root@localhost ~]# chown -R nfsnobody:nfsnobody /sharedir/
[root@localhost ~]# chmod -R 755 /sharedir/
6.NFS主机配置nfs并重载配置
[root@localhost ~]# vim /etc/exports
/sharedir/ *(rw)
/sharedir/yyw 192.168.100.11(rw)
/sharedir/xcx 192.168.100.11(rw)
[root@localhost ~]# systemctl restart nfs //systemctl reload nfs重新加载,exportfs -rv重新挂载
7.检验测试
[root@localhost ~]# showmount -e 192.168.100.12
Export list for 192.168.100.12:
/sharedir *
/sharedir/xcx 192.168.100.11
/sharedir/yyw 192.168.100.11
8.FTP主机创建/nfsdir目录,并将NFS主机的/sharedir挂载至FTP主机的/nfsdir目录下
[root@localhost ~]# mkdir /ftpdir
[root@localhost ~]# mount -t nfs 192.168.100.12:/sharedir /ftpdir
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.4G 0 1.4G 0% /dev
tmpfs 1.4