Linux NFS自動掛載autofs配置

一、基於Linux下NFS文件系統的自動掛載方式,

前期準備環境兩臺Linux服務器:

  1. 準備一臺NFS服務器端(系統環境centos6.5,ip地址192.168.100.100)

  2. 準備需要掛載NFS服務端的NFS客戶端(系統環境centos6.5,ip地址192.168.100.101)

實施:

  1. 現在server端安裝NFS保證能正常訪問,我們這裏通過yum工具安裝即可

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

  2. 通過修改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)

  3. 檢查NFS是否正常

    [root@nfsserver ~]# showmount -e 192.168.100.100
    Export list for 192.168.100.100:
    /data/share 192.168.100.0/24

  4. 客戶端安裝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

  5. 配置客戶端自動掛載(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

        

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章