2019-05-08 14:48:31 3586瀏覽
今天千鋒扣丁學(xué)堂Linux培訓(xùn)老師給大家分享一篇關(guān)于如何使用autofs掛載NFS共享的詳細介紹,首先比如給你的網(wǎng)絡(luò)文件系統(tǒng)(NFS)配置一個基本的自動掛載功能。大多數(shù)Linux文件系統(tǒng)在引導(dǎo)時掛載,并在系統(tǒng)運行時保持掛載狀態(tài)。對于已在fstab中配置的任何遠程文件系統(tǒng)也是如此。但是,有時你可能希望僅按需掛載遠程文件系統(tǒng)。例如,通過減少網(wǎng)絡(luò)帶寬使用來提高性能,或出于安全原因隱藏或混淆某些目錄。autofs軟件包提供此功能。在本文中,我將介紹如何配置基本的自動掛載。
alan@workstation1:~$ sudo getent passwd carl sarah [sudo] password for alan: carl:x:1020:1020:Carl,,,:/home/carl:/bin/bash sarah:x:1021:1021:Sarah,,,:/home/sarah:/bin/bash alan@workstation1:~$ sudo getent hosts 127.0.0.1 localhost 127.0.1.1 workstation1.mydatacenter.net workstation1 10.10.1.5 tree.mydatacenter.net tree
alan@workstation1:~$ sudo apt-get install nfs-common autofs
alan@workstation1:~$ cd /etc; ll auto* -rw-r--r-- 1 root root 12596 Nov 19 2015 autofs.conf -rw-r--r-- 1 root root 857 Mar 10 2017 auto.master -rw-r--r-- 1 root root 708 Jul 6 2017 auto.misc -rwxr-xr-x 1 root root 1039 Nov 19 2015 auto.net* -rwxr-xr-x 1 root root 2191 Nov 19 2015 auto.smb* alan@workstation1:/etc$
/mnt/tree /etc/auto.misc /home/tree /etc/auto.home
alan@workstation1:/etc$ sudo mkdir /mnt/tree /home/tree
ourfiles -fstype=nfs tree:/share/ourfiles
* -fstype=nfs tree:/home/&
alan@workstation1:/etc$ sudo service autofs restart
carl@workstation1:~$ cd /mnt/tree carl@workstation1:/mnt/tree$ ls carl@workstation1:/mnt/tree$ cd ourfiles carl@workstation1:/mnt/tree/ourfiles$
carl@workstation1:~$ mount tree:/mnt/share/ourfiles on /mnt/tree/ourfiles type nfs4 (rw,relatime,vers=4.0,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=10.10.1.22,local_lock=none,addr=10.10.1.5)
【關(guān)注微信公眾號獲取更多學(xué)習(xí)資料】 【掃碼進入HTML5前端開發(fā)VIP免費公開課】
查看更多關(guān)于“Linux培訓(xùn)資訊”的相關(guān)文章>>