CSA复习9 nfs

一.nfs

[root@server8 ~]# dnf install nfs-utils -y

linux和linux互传用nfs,服务端和客户端都是此软件
服务端做:

[root@server8 ~]# systemctl start nfs-server.service 
[root@server8 ~]# showmount -e 172.25.254.244
Export list for 172.25.254.244:
[root@server8 ~]# firewall-cmd --permanent --add-service=rpc-bind 
success
[root@server8 ~]# firewall-cmd --permanent --add-service=mountd 
success
[root@server8 ~]# firewall-cmd --reload 
success
[root@server8 ~]# firewall-cmd --permanent --add-service=nfs
success
[root@server8 ~]# firewall-cmd --reload 
success

服务端的火墙需要通过三个软件
此时客户端查看:

[root@client8 ~]# showmount -e 172.25.254.244
Export list for 172.25.254.244:
[root@server8 ~]# vim /etc/exports

在这里插入图片描述在发布文件写,*代表所有人,也可以写IP,ro表示只读

[root@server8 ~]# exportfs -rv

编写完一定要刷新服务,如上命令
此时在客户端查看

[root@client8 ~]# showmount -e 172.25.254.244
Export list for 172.25.254.244:
/haoge *
[root@client8 ~]# mount 172.25.254.244:/haoge /media/
[root@client8 ~]# df
Filesystem             1K-blocks    Used Available Use% Mounted on
devtmpfs                  906280       0    906280   0% /dev
tmpfs                     935304       0    935304   0% /dev/shm
tmpfs                     935304   17972    917332   2% /run
tmpfs                     935304       0    935304   0% /sys/fs/cgroup
/dev/mapper/rhel-root   13092864 5077636   8015228  39% /
/dev/vda1                1038336  233980    804356  23% /boot
tmpfs                     187060    1180    185880   1% /run/user/42
tmpfs                     187060      36    187024   1% /run/user/0
//172.25.254.244/HAOGE  13092864 4850728   8242136  38% /mnt
172.25.254.244:/haoge   13092864 4850688   8242176  38% /media

已经成功把服务端的发布文件挂载在客户端的/media下
2.NFS配置中的参数

[root@server8 ~]# vim /etc/exports

所有参数的添加和删改都在此进行
在这里插入图片描述如图

sync -更改生成后同步到服务器
ro -只读
rw -读写
async -实时同步数据到服务器
(比如在客户端编辑共享文件时,两者在服务端更改的方式不同)
anonuid=1000,anongid=1000 -指定用户的身份,用户的id和组id
no_root_squash -root用户挂载不转变身份

3.autofs自动挂载文件系统服务的部署
客户端做:

[root@client8 ~]# dnf install autofs -y
[root@client8 ~]# systemctl enable --now autofs.service 
Created symlink /etc/systemd/system/multi-user.target.wants/autofs.service → /usr/lib/systemd/system/autofs.service.
[root@client8 ~]# ls -ld /net/
drwxr-xr-x. 2 root root 0 Apr 24 22:45 /net/

开启服务后会自动生成一个目录

[root@client8 ~]# cd /net/
[root@client8 net]# ls
[root@client8 net]# cd 172.25.254.244
[root@client8 172.25.254.244]# ls
haoge

开启服务后,没有挂载但是可以进入244的共享目录中,默认退出后过300秒就会自动卸载

[root@client8 ~]# vim /etc/autofs.conf 

这是配置文件
在这里插入图片描述
若想修改时间在此修改即可
4.autofs+samba
主配置文件写:

[root@client8 ~]# vim /etc/auto.master

在这里插入图片描述子策略文件:
主配置文件怎么写,子配置文件就起什么名字

[root@client8 ~]# vim /etc/auto.samba

在这里插入图片描述

[root@client8 ~]# systemctl restart autofs.service 
[root@client8 ~]# cd /media/
[root@client8 media]# ls
[root@client8 media]# cd samba
[root@client8 samba]# ls
file1   file2  file4  file6  file8  he    xixixi
file10  file3  file5  file7  file9  hehe

以上就是效果
5.auto+nfs
不能在一个主配置文件写两个不同的服务,但是可以写在同一个子配置文件里,所以主配置文件不动,在samba的子配置文件里 添加:

[root@client8 media]# vim /etc/auto.samba

在这里插入图片描述

[root@client8 ~]# cd /media/
[root@client8 media]# ls
nfs  samba
[root@client8 media]# cd nfs/
[root@client8 nfs]# cd /media/samba/
[root@client8 samba]# ls
file1   file2  file4  file6  file8  he    xixixi
file10  file3  file5  file7  file9  hehe
[root@client8 samba]# 

效果也很明显,两个服务可以写在同一个子配置文件,除非 挂载在不同的目录下,可以在主配置文件写不同的服务

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值