linux 自动挂载 nfs,Linux NFS自动挂载autofs配置

一、基于Linux下NFS文件系统的自动挂载方式,

前期准备环境两台Linux服务器: 准备一台NFS服务器端(系统环境centos6.5,ip地址192.168.100.100)

准备需要挂载NFS服务端的NFS客户端(系统环境centos6.5,ip地址192.168.100.101)

实施: 现在server端安装NFS保证能正常访问,我们这里通过yum工具安装即可

[root@nfsserver ~]# yum install nfs-utils rpcbind -y

通过修改NFS配置,共享/data/share/目录

[root@nfsserver ~]# mkdir /data/share

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

##########shared data for bbs by oldboy at 20160825

#/data/share           192.168.100.0/24(rw,sync,hide)

/data/share           192.168.100.0/24(rw,sync,anonuid=555,anongid=555,all_squash)

检查NFS是否正常

[root@nfsserver ~]# showmount -e 192.168.100.100

Export list for 192.168.100.100:

/data/share 192.168.100.0/24

客户端安装NFS客户端及autofs并启动相关服务

[root@nfsclient ~]# yum install rpcbind nfs-utils -y

[root@nfsclient ~]# yum install autofs -y

[root@nfsclient ~]# /etc/init.d/rpcbind start

[root@nfsclient ~]# /etc/init.d/autofs start

配置客户端自动挂载(autofs)NFS服务端共享目录

[root@nfsclient ~]# 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).

#

/misc   /etc/auto.misc

/mnt    /etc/auto.misc  timeout=60#/mnt为挂载点   /etc/auto.misc为挂载动作

[root@nfsclient ~]# 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

cd              -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

# the following entries are samples to pique your imagination

#linux          -ro,soft,intr           ftp.example.org:/pub/linux

#boot           -fstype=ext2            :/dev/hda1

#floppy         -fstype=auto            :/dev/fd0

#floppy         -fstype=ext2            :/dev/fd0

#e2floppy       -fstype=ext2            :/dev/fd0

#jaz            -fstype=ext2            :/dev/sdc1

#removable      -fstype=ext2            :/dev/hdd

nfsdata         -fstype=nfs             192.168.100.100:/data/share

6.重新启动autofs服务,并检查自动挂载文件是否生效

[root@nfsclient ~]# /etc/init.d/autofs restart

[root@nfsclient ~]# cd /mnt/nfsdata

[root@nfsclient nfsdata]# ls -l

total 0

-rw-r--r-- 1 oldgirl oldgirl 0 Aug 27 00:14 andy

-rw-r--r-- 1 oldgirl oldgirl 0 Aug 27 00:10 oldboy

-rw-rw-r-- 1 oldgirl oldgirl 0 Aug 27 00:10 oldgirl

[root@nfsclient nfsdata]# df -h

Filesystem                       Size  Used Avail Use% Mounted on

/dev/mapper/vg_muban-moban_root   38G  1.9G   34G   6% /

tmpfs                            491M     0  491M   0% /dev/shm

/dev/sda1                        194M   29M  155M  16% /boot

192.168.100.100:/data/share       38G  1.9G   34G   6% /mnt/nfsdata

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值