一、基於Linux下NFS文件系統的自動掛載方式,
前期準備環境兩臺Linux服務器:
準備一臺NFS服務器端(系統環境centos6.5,ip地址192.168.100.100)
準備需要掛載NFS服務端的NFS客戶端(系統環境centos6.5,ip地址192.168.100.101)
實施:
現在server端安裝NFS保證能正常訪問,我們這裏通過yum工具安裝即可
[[email protected] ~]# yum install nfs-utils rpcbind -y
通過修改NFS配置,共享/data/share/目錄
[[email protected] ~]# mkdir /data/share
[[email protected] ~]# 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是否正常
[[email protected] ~]# showmount -e 192.168.100.100
Export list for 192.168.100.100:
/data/share 192.168.100.0/24客戶端安裝NFS客戶端及autofs並啓動相關服務
[[email protected] ~]# yum install rpcbind nfs-utils -y
[[email protected] ~]# yum install autofs -y
[[email protected] ~]# /etc/init.d/rpcbind start
[[email protected] ~]# /etc/init.d/autofs start
配置客戶端自動掛載(autofs)NFS服務端共享目錄
[[email protected] ~]# 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爲掛載動作
[[email protected] ~]# 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服務,並檢查自動掛載文件是否生效
[[email protected] ~]# /etc/init.d/autofs restart
[[email protected] ~]# cd /mnt/nfsdata
[[email protected] 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
[[email protected] 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