#####1.samba的多用户挂载#################
在客户端如果用普通的挂载方式没有用过用户验证的人也可以访问samba服务
[root@test ~]# dnf install cifs-utils.x86_64 -y
[root@test ~]# vim /root/smbpass
[root@test ~]# chmod 600 /root/smbpass
[root@test ~]# mount -o credentials=/root/smbpass,sec=ntlmssp,multiuser //192.168.3.110/westosdir /mnt ##①credentials=/root/smbpass指定认证文件 ②sec=ntlmssp指定认证类型 ③multiuser支持多用户
[root@test ~]# su - westos
[westos@test ~]$ ls /mnt ##客户端主机的westos用户没有通过认证
[westos@test ~]$ cifscreds add -u lei 192.168.3.110
[westos@test ~]$ ls /mnt/ ##通过认证可显示
注意:
[westos@test ~]$ cifscreds add -u lei 192.168.3.110 ##当遇到此报错信息
[westos@test ~]$ cifscreds add -u lei -d 192.168.3.110 ##执行此两条命令可解决
[westos@test ~]$ cifscreds clearall
#####2.autofs+samba#####################################
autofs:在客户端实现自动挂载的卸载的软件
[root@test ~]# dnf install autofs.x86_64 -y
[root@test ~]# systemctl start autofs.service
[root@test ~]# vim /etc/auto.master
最终挂载点的上层目录 自动以子策略文件
/mnt /etc/auto.samba
[root@test ~]# vim /etc/auto.samba
最终挂载点 挂载参数 挂载资源
samba -fstype=cifs,username=westos,password=123 ://192.168.3.110/westosdir
[root@test ~]# vim /etc/autofs.conf ##编辑默认卸载等待时间
[root@test ~]# systemctl restart autofs.service
测试:
[root@test ~]# cd /mnt/samba/
[root@test samba]# df
[root@test samba]# cd ##等待资源闲置时间
[root@test ~]# df ##挂载资源自动卸载
#####3.NFS###############
Net File System
一.NFS基本信息
安装包:nfs-utils
服务脚本:nfs-server
共享配置文件:/etc/exports
二.nfs的安装和启用
[root@test ~]# dnf install nfs-utils.x86_64 -y
[root@test ~]# systemctl start nfs-server
[root@test ~]# systemctl status nfs-server
[root@test ~]# firewall-cmd --permanent --add-service=rpc-bind
[root@test ~]# firewall-cmd --permanent --add-service=mountd
[root@test ~]# firewall-cmd --permanent --add-service=nfs
[root@test ~]# firewall-cmd --reload
[root@samba ~]# showmount -e 192.168.3.51
三.nfs配置
[root@test ~]# vim /etc/exports
共享目录 共享参数
/westosdir *(ro)
[root@test ~]# exportfs -rv ##生效
[root@test ~]# chmod 777 /westosdir/
[root@test ~]# ls -ld /westosdir/
测试:
[root@samba ~]# showmount -e 192.168.3.51
[root@samba ~]# mount 192.168.3.51:/westosdir /mnt/
四.nfs配置参数
anonuid=1000,anongid=1000 | 指定用户身份 |
sync | 更改生成后同步数据到服务器 |
async | 实时同步数据到服务器 |
rw | 读写 |
ro | 只读 |
no_root_squash | root用户挂载不转换身份 |
-[root@test ~]# vim /etc/exports
[root@test ~]# exportfs -rv
测试:
[root@samba ~]# cd /mnt/
[root@rhel7 ~]# mount 192.168.3.51:/westosdir /mnt/
[root@rhel7 ~]# cd /mnt/
[root@rhel7 mnt]# touch file2
-[root@test ~]# vim /etc/exports
[root@test ~]# exportfs -rv
测试:
[root@samba ~]# cd /mnt/
[root@samba mnt]# touch file2
[root@test ~]# ll /westosdir/
-[root@test ~]# vim /etc/exports
[root@test ~]# exportfs -rv
测试:
[root@samba mnt]# touch file3
[root@samba mnt]# ll /mnt/
-[root@test ~]# vim /etc/exports
[root@test ~]# exportfs -rv
测试:
[root@samba mnt]# touch file4
[root@samba mnt]# ll /mnt/
五.nfs+autofs
[root@samba ~]# dnf install autofs -y
[root@samba ~]# systemctl start autofs.service
[root@samba ~]# vim /etc/auto.master
[root@samba ~]# vim /etc/auto.nfs
[root@samba ~]# systemctl restart autofs.service
[root@samba ~]# cd /mnt/
[root@samba mnt]# ls
[root@samba mnt]# cd nfs
[root@samba nfs]# df