#####1.samba的多用户挂载#################

在客户端如果用普通的挂载方式没有用过用户验证的人也可以访问samba服务

[[email protected] ~]# dnf install cifs-utils.x86_64 -y

[[email protected] ~]# vim /root/smbpass

samba+autofs+nfs

[[email protected] ~]# chmod 600 /root/smbpass

[[email protected] ~]# mount -o credentials=/root/smbpass,sec=ntlmssp,multiuser //192.168.3.110/westosdir /mnt       ##①credentials=/root/smbpass指定认证文件 ②sec=ntlmssp指定认证类型 ③multiuser支持多用户

samba+autofs+nfs

[[email protected] ~]# su - westos

[[email protected] ~]$ ls /mnt    ##客户端主机的westos用户没有通过认证

samba+autofs+nfs

[[email protected] ~]$ cifscreds add -u lei  192.168.3.110

[[email protected] ~]$ ls /mnt/                                                     ##通过认证可显示

samba+autofs+nfs

注意:

[[email protected] ~]$ cifscreds add -u lei 192.168.3.110    ##当遇到此报错信息

samba+autofs+nfs

[[email protected] ~]$ cifscreds add -u lei -d 192.168.3.110    ##执行此两条命令可解决

[[email protected] ~]$ cifscreds clearall

samba+autofs+nfs

 

#####2.autofs+samba#####################################

autofs:在客户端实现自动挂载的卸载的软件

[[email protected] ~]# dnf install autofs.x86_64 -y

[[email protected] ~]# systemctl start autofs.service

samba+autofs+nfs

[[email protected] ~]# vim /etc/auto.master

最终挂载点的上层目录                自动以子策略文件

/mnt                                             /etc/auto.samba

samba+autofs+nfs

[[email protected] ~]# vim /etc/auto.samba

最终挂载点       挂载参数                                                                         挂载资源

samba             -fstype=cifs,username=westos,password=123               ://192.168.3.110/westosdir

samba+autofs+nfs

[[email protected] ~]# vim /etc/autofs.conf    ##编辑默认卸载等待时间

samba+autofs+nfs

[[email protected] ~]# systemctl restart autofs.service

测试:

[[email protected] ~]# cd /mnt/samba/
[[email protected] samba]# df

samba+autofs+nfs

[[email protected] samba]# cd    ##等待资源闲置时间
[[email protected] ~]# df             ##挂载资源自动卸载

samba+autofs+nfs

#####3.NFS###############

Net File System

一.NFS基本信息

安装包:nfs-utils

服务脚本:nfs-server

共享配置文件:/etc/exports

二.nfs的安装和启用

[[email protected] ~]# dnf install nfs-utils.x86_64 -y

[[email protected] ~]# systemctl start nfs-server

[[email protected] ~]# systemctl status nfs-server

samba+autofs+nfs

[[email protected] ~]# firewall-cmd --permanent --add-service=rpc-bind

[[email protected] ~]# firewall-cmd --permanent --add-service=mountd

[[email protected] ~]# firewall-cmd --permanent --add-service=nfs

[[email protected] ~]# firewall-cmd --reload

samba+autofs+nfs

[[email protected] ~]# showmount -e 192.168.3.51

samba+autofs+nfs

三.nfs配置

[[email protected] ~]# vim /etc/exports

共享目录        共享参数

/westosdir      *(ro)

samba+autofs+nfs

[[email protected] ~]# exportfs -rv  ##生效

samba+autofs+nfs

[[email protected] ~]# chmod 777 /westosdir/

[[email protected] ~]# ls -ld /westosdir/

samba+autofs+nfs

测试:

[[email protected] ~]# showmount -e 192.168.3.51

samba+autofs+nfs

[[email protected] ~]# mount 192.168.3.51:/westosdir /mnt/

samba+autofs+nfs

四.nfs配置参数

anonuid=1000,anongid=1000 指定用户身份
sync 更改生成后同步数据到服务器
async 实时同步数据到服务器
rw 读写
ro 只读
no_root_squash root用户挂载不转换身份

 

 

 

 

 

 

 

-[[email protected] ~]# vim /etc/exports

samba+autofs+nfs

[[email protected] ~]# exportfs -rv

samba+autofs+nfs

测试:

[[email protected] ~]# cd /mnt/

samba+autofs+nfs

[[email protected] ~]# mount 192.168.3.51:/westosdir /mnt/

samba+autofs+nfs

[[email protected] ~]# cd /mnt/
[[email protected] mnt]# touch file2

samba+autofs+nfs

-[[email protected] ~]# vim /etc/exports

samba+autofs+nfs

[[email protected] ~]# exportfs -rv

samba+autofs+nfs

测试:

[[email protected] ~]# cd /mnt/
[[email protected] mnt]# touch file2

[[email protected] ~]# ll /westosdir/

samba+autofs+nfs

-[[email protected] ~]# vim /etc/exports

samba+autofs+nfs

[[email protected] ~]# exportfs -rv

测试:

[[email protected] mnt]# touch file3
[[email protected] mnt]# ll /mnt/

samba+autofs+nfs

 

-[[email protected] ~]# vim /etc/exports

samba+autofs+nfs

[[email protected] ~]# exportfs -rv

测试:

[[email protected] mnt]# touch file4
[[email protected] mnt]# ll /mnt/

samba+autofs+nfs

五.nfs+autofs

[[email protected] ~]# dnf install autofs -y

[[email protected] ~]# systemctl start autofs.service

[[email protected] ~]# vim /etc/auto.master

samba+autofs+nfs

[[email protected] ~]# vim /etc/auto.nfs

samba+autofs+nfs

[[email protected] ~]# systemctl restart autofs.service

[[email protected] ~]# cd /mnt/
[[email protected] mnt]# ls
[[email protected] mnt]# cd nfs
[[email protected] nfs]# df

samba+autofs+nfs

相关文章: