关于NFS与autofs结合使用

        前面内容我讲到了NFS以及autofs自动挂载服务,这一节内容我想针对这两个内容的知识做一个补充,主要是以实验的方式呈现。那么在NFS网络文件系统里面我们可以以NFS客户端通过NFS服务端共享去访问所需要的资源,但是我们需要自己进行手动挂载,在操作的便利性比较繁琐,那么我们这个时候就可以运用autofs自动挂载服务,当NFS客户端想要访问对应文件的时候,autofs会动态挂载信息,我们在顺利访问文件的同时也更加便利了

第一步:我们先将NFS共享目录卸载掉。同时在autofs服务程序的主配置文件中会有一个“/misc/etc/auto.misc”参数,这个auto.misc相当于自动挂载的参考文件,它默认已经存在。

[root@blue ~] umount /nfsfile 
[root@blue ~] vim /etc/auto.master
# Sample auto.master file
# This is a 'master' automounter map and it has the following format:
# mount-point [map-type[,format]:]map [options]
# For details of the format look at auto.master(5).
#
/media  /etc/iso.misc
/misc   /etc/auto.misc

第二步:找到这个对应的auto.misc文件,填写本地挂载的路径和NFS服务器的挂载信息:

[root@blue ~]# vim /etc/auto.misc
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage
nfsfile 172.25.0.254:/nfsfile
cd              -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

第三步:重启autofs服务程序,当用户进入到/misc/nfsfile目录时,便会自动挂载共享信息        

[root@blue ~]# systemctl restart autofs
[root@blue ~]# cd /misc/nfsfile
[root@blue nfsfile]# df -h
文件系统               容量  已用  可用 已用% 挂载点
devtmpfs               1.9G     0  1.9G    0% /dev
tmpfs                  2.0G     0  2.0G    0% /dev/shm
tmpfs                  2.0G  9.9M  2.0G    1% /run
tmpfs                  2.0G     0  2.0G    0% /sys/fs/cgroup
/dev/mapper/rhel-root   17G  4.0G   14G   23% /
/dev/sdb1              2.0G   47M  2.0G    3% /newFS
/dev/sda1             1014M  160M  855M   16% /boot
tmpfs                  392M   16K  392M    1% /run/user/42
tmpfs                  392M  3.5M  389M    1% /run/user/0
172.25.0.254:/nfsfile   17G  4.0G   14G   24% /misc/nfsfile

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值