1. 程式人生 > >nfs samba 檔案共享

nfs samba 檔案共享

首先會通過比較檔案傳輸和檔案共享兩種資源交換方式來引入Samba服務的理論知識,介紹SMB協議和Samba服務程式的來由和發展過程。通過實戰的部署檔案共享服務來更加深入的瞭解Samba服務中每一行引數的作用,並在實驗最後分別使用Windows系統和Linux系統訪問檔案共享資源,為今後生產環境中靈活使用檔案共享服務打下實戰基礎。

通過配置NFS網路檔案系統服務使得Linux系統之間共享檔案的工作變得更加簡單,實戰部署NFS服務來實現多臺Linux系統之間的資源掛載使用,然後學習Autofs服務來更好的管理裝置掛載資訊,不僅能夠正常的滿足裝置掛載使用的需求,還能進一步降低伺服器頻寬和CPU計算資源不必要的浪費開銷。


Samba服務程式的配置方法跟以前學習過的服務很相似,首先需要先通過yum軟體倉庫來安裝samba服務程式,這款軟體也恰巧是軟體包的名字,很好記吧~:

[[email protected] ~ ]# yum install samba
Loaded plugins: langpacks, product-id, subscription-manager
………………省略部分輸出資訊………………
Installing:
 samba x86_64 4.1.1-31.el7 rhel 527 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 527 k
Installed size: 1.5 M
Is this ok [y/d/N]: y
Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : samba-4.1.1-31.el7.x86_64 1/1 Verifying : samba-4.1.1-31.el7.x86_64 1/1 Installed: samba.x86_64 0:4.1.1-31.el7 Complete!

安裝後開啟Samba服務程式的主配置後發現竟然有320行呢!有沒有被嚇到?但仔細一看發現其實大多都是以#(井號)開頭的註釋資訊行,既然您手中已經擁有了劉遄老師的經驗之書,就肯定不會讓您去“死啃”這些東東的~:

[[email protected] ~]# cat /etc/samba/smb.conf 
# This is the main Samba configuration file. For detailed information about the
# options listed here, refer to the smb.conf(5) manual page. Samba has a huge
# number of configurable options, most of which are not shown in this example.
#
# The Official Samba 3.2.x HOWTO and Reference Guide contains step-by-step
# guides for installing, configuring, and using Samba:
# http://www.samba.org/samba/docs/Samba-HOWTO-Collection.pdf
#
# The Samba-3 by Example guide has working examples for smb.conf. This guide is
# generated daily: http://www.samba.org/samba/docs/Samba-Guide.pdf
#
# In this file, lines starting with a semicolon (;) or a hash (#) are
# comments and are ignored. This file uses hashes to denote commentary and
# semicolons for parts of the file you may wish to configure.
#
# Note: Run the "testparm" command after modifying this file to check for basic
# syntax errors.
#
………………省略部分輸出資訊………………

由於這次配置檔案中的註釋資訊行實在太多,不便於分析裡面的重要引數,因此咱們可以先把配置檔案改個名字,然後使用cat命令讀入主配置檔案內容後通過grep命令-v引數(反向選擇)分別去掉所有以#(井號)和;(分號)開頭的註釋資訊行,對於剩餘的空白行可以再用^$來表示並反選過濾,最後把過濾後的可用引數資訊通過重定向符覆蓋寫入到原始檔名稱中即可。samba服務程式過濾後的引數並不複雜,為了更方便同學們查閱引數功能,劉遄老師在重要引數行後面都寫上了註釋說明:

[[email protected] ~]# mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
[[email protected] ~]# cat /etc/samba/smb.conf.bak | grep -v "#" | grep -v ";" | grep -v "^$" > /etc/samba/smb.conf
[[email protected] ~]# cat /etc/samba/smb.conf
[global] #全域性引數。
workgroup = MYGROUP #工作組名稱。
server string = Samba Server Version %v #伺服器介紹資訊,引數%v為顯示SMB版本號。
log file = /var/log/samba/log.%m #定義日誌檔案存放位置與名稱,引數%m為來訪的主機名。
max log size = 50 #定義日誌檔案最大容量為50Kb。
security = user #安全驗證的方式,總共有4種。
#share:來訪主機無需驗證口令,更加方便,但安全性很差。
#user:需由SMB服務驗證來訪主機提供的口令後才可建立訪問,更加的安全。
#server:使用獨立的遠端主機驗證來訪主機提供的口令(集中管理帳號)。
#domain:使用PDC來完成驗證
passdb backend = tdbsam #定義使用者後臺的型別,共有3種。
#smbpasswd:使用SMB服務的smbpasswd命令給系統使用者設定SMB密碼。
#tdbsam:建立資料庫檔案並使用pdbedit建立SMB獨立的使用者。
#ldapsam:基於LDAP服務進行帳戶驗證。
load printers = yes #設定是否當Samba服務啟動時共享印表機裝置。
cups options = raw #印表機的選項
[homes] #共享引數
comment = Home Directories #描述資訊
browseable = no #指定共享是否在“網路上的芳鄰”中可見。
writable = yes #定義是否可寫入操作,與"read only"相反。
[printers] #印表機共享引數
comment = All Printers
path = /var/spool/samba #共享檔案的實際路徑(重要)。
browseable = no
guest ok = no #是否所有人可見,等同於"public"引數。
writable = no
printable = yes
12.1.1 配置共享資源

Samba服務程式的配置檔案與前面學習過的Apache服務很相似,包括有全域性配置引數和區域性配置引數。全域性配置引數是Samba服務程式對整體共享環境的設定,是對裡面每個獨立的共享資源都生效的引數,而區域配置引數指的則是一個個獨立可用的共享資源,共享資源的建立方法很簡單,只需要按照下面引數格式寫入配置檔案後重啟服務程式即可~

引數 作用
[linuxprobe] 共享名稱為linuxprobe
comment = Do not arbitrarily modify the database file 警告使用者不要隨意修改資料庫
path = /home/database 共享資料夾在/home/database
public = no 關閉所有人可見
writable = yes 允許寫入操作

第1步:建立用於訪問共享資源的帳戶資訊,在紅帽RHEL7系統中Samba服務程式預設使用的是使用者口令認證模式(user),可以做到僅讓有密碼、受信任的使用者訪問共享資源,驗證的過程也十分的簡單。不過咱們需要為Samba服務程式建立獨立的使用者密碼資料庫後才能登陸使用,另外Samba服務的資料庫要求帳號必須是當前系統中已經存在的使用者,否則日後建立檔案將產生許可權屬性的混亂錯誤。

pdbedit命令用於管理SMB服務的帳戶資訊資料庫,格式為:“pdbedit [選項] 帳戶”,第一次把使用者資訊寫入到資料庫時需要使用-a引數,以後修改使用者密碼、刪除使用者等等操作就不再需要了:

引數 作用
-a 使用者名稱 建立Samba使用者
-x 使用者名稱 刪除Samba使用者
-L 列出使用者列表
-Lv 列出使用者詳細資訊的列表
[[email protected] ~]# id linuxprobe
uid=1000(linuxprobe) gid=1000(linuxprobe) groups=1000(linuxprobe)
[[email protected] ~]# pdbedit -a -u linuxprobe
new password:此處輸入該使用者在Samba服務資料庫中的密碼
retype new password:再次輸入密碼進行確認
Unix username: linuxprobe
NT username: 
Account Flags: [U ]
User SID: S-1-5-21-507407404-3243012849-3065158664-1000
Primary Group SID: S-1-5-21-507407404-3243012849-3065158664-513
Full Name: linuxprobe
Home Directory: \\localhost\linuxprobe
HomeDir Drive: 
Logon Script: 
Profile Path: \\localhost\linuxprobe\profile
Domain: LOCALHOST
Account desc: 
Workstations: 
Munged dial: 
Logon time: 0
Logoff time: Wed, 06 Feb 2036 10:06:39 EST
Kickoff time: Wed, 06 Feb 2036 10:06:39 EST
Password last set: Mon, 13 Mar 2017 04:22:25 EDT
Password can change: Mon, 13 Mar 2017 04:22:25 EDT
Password must change: never
Last bad password : 0
Bad password count : 0
Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

第2步:建立用於共享資源的檔案目錄,不光要考慮到檔案訪問和寫入許可權的問題,而且由於/home目錄是系統中普通使用者的家目錄,因此還需要考慮到檔案上面SELinux安全上下文的監管控制。實際上剛剛過濾掉的註釋資訊中就提醒有了相關的SELinux安全上下文策略的說明,咱們只需要按照給的值進行修改即可,最後再記得執行下restorecon命令讓目錄檔案上面新設定的SELinux安全上下文立即生效下哦~

[[email protected] ~]# mkdir /home/database
[[email protected] ~]# chown -Rf linuxprobe:linuxprobe /home/database
[[email protected] ~]# semanage fcontext -a -t samba_share_t /home/database
[[email protected] ~]# restorecon -Rv /home/database
restorecon reset /home/database context unconfined_u:object_r:home_root_t:s0->unconfined_u:object_r:samba_share_t:s0

第3步:設定SELinux服務對Samba程式訪問個人使用者家目錄的允許策略,過濾篩選出所有與samba服務程式相關的SELinux域策略,根據策略的名稱和經驗選擇出合適的策略條目進行開啟即可:

[[email protected] ~]# getsebool -a | grep samba
samba_create_home_dirs --> off
samba_domain_controller --> off
samba_enable_home_dirs --> off
samba_export_all_ro --> off
samba_export_all_rw --> off
samba_portmapper --> off
samba_run_unconfined --> off
samba_share_fusefs --> off
samba_share_nfs --> off
sanlock_use_samba --> off
use_samba_home_dirs --> off
virt_sandbox_use_samba --> off
virt_use_samba --> off
[[email protected] ~]# setsebool -P samba_enable_home_dirs on

第4步:在Samba服務程式的主配置檔案中根據前面所提到的格式寫入共享資訊,在原始的配置檔案中[homes]引數為共享該使用者的家目錄資料,[printers]引數為共享印表機裝置,這兩項如果您今後的工作中不需要,可以像劉遄老師一樣手動的刪除掉,沒有問題的~

[[email protected] ~]# vim /etc/samba/smb.conf 
[global]
 workgroup = MYGROUP
 server string = Samba Server Version %v
 log file = /var/log/samba/log.%m
 max log size = 50
 security = user
 passdb backend = tdbsam
 load printers = yes
 cups options = raw
[database]
 comment = Do not arbitrarily modify the database file
 path = /home/database
 public = no
 writable = yes

第5步:把上述步驟完成後也就基本完成了Samba服務程式的配置工作了,Samba服務程式叫做smb,因此重啟一下smb服務,清空下iptables防火牆就可以來檢驗配置效果了:

[[email protected] ~]# systemctl restart smb
[[email protected] ~]# systemctl enable smb
 ln -s '/usr/lib/systemd/system/smb.service' '/etc/systemd/system/multi-user.target.wants/smb.service'
[[email protected] ~]# iptables -F
[[email protected] ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
12.1.2 Windows掛載共享

在Windows系統中不論是在使用由Windows系統還是Linux系統提供的共享資源步驟和方法都是一致的,所以估計同學們以前都會誤以為共享資源都是由Windows系統提供的呢~Samba共享伺服器和Windows客戶端主機的IP地址可以參考下表來設定,在Windows系統中使用共享資源只需在執行中輸入兩個反斜槓後加伺服器主機IP地址即可,如圖12-2所示:

主機名稱 作業系統 IP地址
Samba共享伺服器 紅帽RHEL7作業系統 192.168.10.10
Linux客戶端 紅帽RHEL7作業系統 192.168.10.20
Windows客戶端 微軟Windows7作業系統 192.168.10.30

第12章 使用Samba或NFS實現檔案共享。第12章 使用Samba或NFS實現檔案共享。

圖12-2 在Windows系統中訪問共享資源

只要iptables防火牆已經清空就應該能看到Samba共享資源的登陸介面了,劉遄老師先使用linuxprobe使用者的系統本地密碼嘗試登陸一下,結果會出現如圖12-3一樣的報錯,這就是為了驗證果然在紅帽RHEL7系統中Samba服務程式使用的是獨立的使用者資料庫資訊了,所以即便linuxprobe的使用者名稱稱是相同的,同學們也一定要分清是那個密碼才行~

第12章 使用Samba或NFS實現檔案共享。第12章 使用Samba或NFS實現檔案共享。 圖12-3 訪問Samba共享資源提示出錯

正確輸入linuxprobe帳號以及pdbedit命令設定的密碼後就可以登陸到共享介面中了,如圖12-4所示。咱們還可以嘗試正常的檢視、寫入、更名、刪除檔案等等操作,不過由於Windows系統的快取原因,有可能您第二次登陸的時候依然會報錯,這時需要重新啟動一下您的真機電腦就一定沒問題了(如果依然報錯請檢查上述步驟是否有做錯的地方~)。

第12章 使用Samba或NFS實現檔案共享。第12章 使用Samba或NFS實現檔案共享。

圖12-4 正常使用Samba服務共享的資源

12.1.2 Linux掛載共享

剛剛可能不小心讓大家產生了一些小誤解,認為Samba服務只是為了解決Linux系統和Windows系統的資源共享問題而設計的,其實Samba服務程式還可以實現Linux系統之間的檔案共享哦~同學們可以參考下表來配置下Linux客戶端的網絡卡IP地址,然後在客戶端安裝一下共享資源的支援軟體包(cifs-utils):

主機名稱 作業系統 IP地址
Samba共享伺服器 紅帽RHEL7作業系統 192.168.10.10
Linux客戶端 紅帽RHEL7作業系統 192.168.10.20
Windows客戶端 微軟Windows7作業系統 192.168.10.30
[[email protected] ~]# yum install cifs-utils
Loaded plugins: langpacks, product-id, subscription-manager
rhel | 4.1 kB 00:00 
Resolving Dependencies
--> Running transaction check
---> Package cifs-utils.x86_64 0:6.2-6.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package Arch Version Repository Size
================================================================================
Installing:
 cifs-utils x86_64 6.2-6.el7 rhel 83 k
Transaction Summary
================================================================================
Install 1 Package
Total download size: 83 k
Installed size: 174 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : cifs-utils-6.2-6.el7.x86_64 1/1 
 Verifying : cifs-utils-6.2-6.el7.x86_64 1/1 
Installed:
 cifs-utils.x86_64 0:6.2-6.el7 
Complete!

在Linux系統客戶端上面依次按照Samba服務使用者名稱、密碼、共享域的順序寫入到一個認證檔案中,併為了保證不被其他人隨意看到,最後再把其許可權修改為僅root超級使用者才能夠讀寫:

[[email protected] ~]# vim auth.smb
username=linuxprobe
password=redhat
domain=MYGROUP
[[email protected] ~]# chmod -Rf 600 auth.smb

完成上述步驟後就可以在客戶端上面建立一個用於掛載Samba服務共享資源的目錄檔案,並把掛載資訊寫入到/etc/fstab檔案中,這樣保證遠端共享掛載資訊在伺服器重啟後依然生效:

[[email protected] ~]# mkdir /database
[[email protected] ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Wed May 4 19:26:23 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root / xfs defaults 1 1
UUID=812b1f7c-8b5b-43da-8c06-b9999e0fe48b /boot xfs defaults 1 2
/dev/mapper/rhel-swap swap swap defaults 0 0
/dev/cdrom /media/cdrom iso9660 defaults 0 0 
//192.168.10.10/database /database cifs credentials=/root/auth.smb 0 0
[[email protected] ~]# mount -a

客戶端成功掛載Samba遠端共享資源,進入到掛載目錄中後就可以看到剛剛Windows系統訪問Samba服務共享留下來的檔案啦~當然咱們也是可以讀寫儲存的,是不是覺得很實用呢~

[[email protected] ~]# cat /database/Memo.txt
i can edit it .
12.2 NFS網路檔案系統

如果覺得Samba服務程式配置起來實在很麻煩,而且恰巧需要共享檔案的主機都是Linux系統,那麼劉遄老師非常推薦大家使用NFS服務來共享檔案給客戶端,NFS網路檔案系統(Network Files System)是一個能夠把Linux系統的遠端檔案共享資源掛載到本地目錄的服務,NFS檔案系統協議允許網路中的主機通過TCP/IP協議進行資源共享,能夠讓Linux客戶端像使用本地資源一樣讀寫遠端NFS服務端的檔案內容。另外由於NFS網路檔案系統服務已經在紅帽RHEL7系統中預設安裝好,配置步驟也十分的簡單,因此劉遄老師有時講課會開玩笑說NFS是need for speed,接下來與大家分享下NFS服務配置起來的爽快體驗~請大家先自行用yum軟體倉庫檢查確認下NFS軟體包是否已經安裝好吧:

[[email protected] ~]# yum install nfs-utils
Loaded plugins: langpacks, product-id, subscription-manager
(1/2): rhel7/group_gz | 134 kB 00:00
(2/2): rhel7/primary_db | 3.4 MB 00:00
Package 1:nfs-utils-1.3.0-0.el7.x86_64 already installed and latest version
Nothing to do

第1步:為了檢驗NFS服務配置的效果,咱們本次實驗需要使用到兩臺Linux主機,您可以參考下表對系統網絡卡IP地址進行設定,另外也不要忘記清空iptables防火牆,避免預設的策略禁止了正常的NFS共享服務:

主機名稱 作業系統 IP地址
NFS服務端 紅帽RHEL7作業系統 192.168.10.10
NFS客戶端 紅帽RHEL7作業系統 192.168.10.20
[[email protected] ~]# iptables -F
[[email protected] ~]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]

第2步:在NFS服務端主機上面建立用於NFS檔案共享的目錄,設定較大的許可權來保證其他人也一樣有寫入的許可權:

[[email protected] ~]# mkdir /nfsfile
[[email protected] ~]# chmod -Rf 777 /nfsfile
[[email protected] ~]# echo "welcome to linuxprobe.com" > /nfsfile/readme

第3步:NFS服務程式的配置檔案為/etc/exports,預設裡面是空白沒有內容的,可以按照共享目錄的路徑 允許訪問的NFS資源客戶端(共享許可權引數)的格式來寫入引數,定義要共享的目錄與相應的許可權。例如想要把/nfsfile目錄共享給所有屬於192.168.10.0/24這個網段的使用者主機,並且讓這些使用者擁有讀寫許可權,自動同步記憶體資料到本地硬碟,以及把對方root超級使用者對映為本地的匿名使用者等等特殊許可權引數,那麼就可以按照下面的格式來寫入配置檔案:

引數 作用
ro 只讀預設
rw 讀寫模式
root_squash 當NFS客戶端使用root使用者訪問時,對映為NFS服務端的匿名使用者。
no_root_squash 當NFS客戶端使用root使用者訪問時,對映為NFS服務端的root使用者。
all_squash 不論NFS客戶端使用任何帳戶,均對映為NFS服務端的匿名使用者。
sync 同時將資料寫入到記憶體與硬碟中,保證不丟失資料。
async 優先將資料儲存到記憶體,然後再寫入硬碟,效率更高,但可能造成資料丟失。
[[email protected] ~]# vim /etc/exports
/nfsfile 192.168.10.*(rw,sync,root_squash)

第4步:啟動執行NFS共享服務程式,由於NFS服務在檔案共享過程中是依賴RPC服務進行工作了,RPC服務用於把伺服器地址和服務埠號等資訊通知給客戶端,因此要使用NFS共享服務的話,順手也要把rpcbind服務程式啟動,並且把這兩個服務一起加入到開機啟動項中吧:

[[email protected] ~]# systemctl restart rpcbind
[[email protected] ~]# systemctl enable rpcbind
[[email protected] ~]# systemctl start nfs-server
[[email protected] ~]# systemctl enable nfs-server
ln -s '/usr/lib/systemd/system/nfs-server.service' '/etc/systemd/system/nfs.target.wants/nfs-server.service'

配置NFS客戶端的步驟也十分簡單,首先用showmount命令查詢NFS服務端的遠端共享資訊,輸出格式為“共享的目錄名稱 允許使用客戶端地址”:

引數 作用
-e 顯示NFS服務端的共享列表
-a 顯示本機掛載NFS資源的情況
-v 顯示版本號
[[email protected] ~]# showmount -e 192.168.10.10
Export list for 192.168.10.10:
/nfsfile 192.168.10.*

然後在客戶端系統上面建立一個掛載目錄,使用mount命令的-t引數指定掛載檔案系統的型別,以及後面寫上服務端的IP地址,共享出去的目錄以及掛載到系統本地的目錄。

[[email protected] ~]# mkdir /nfsfile
[[email protected] ~]# mount -t nfs 192.168.10.10:/nfsfile /nfsfile

最後掛載成功後就應該能夠順利檢視到剛剛寫入檔案內容了,當然如果同學們希望遠端NFS檔案共享能一直有效,還可以寫入到fstab檔案中:

[[email protected] ~]# cat /nfsfile/readme
welcome to linuxprobe.com
[[email protected] ~]# vim /etc/fstab 
#
# /etc/fstab
# Created by anaconda on Wed May 4 19:26:23 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root / xfs defaults 1 1
UUID=812b1f7c-8b5b-43da-8c06-b9999e0fe48b /boot xfs defaults 1 2
/dev/mapper/rhel-swap swap swap defaults 0 0
/dev/cdrom /media/cdrom iso9660 defaults 0 0 
192.168.10.10:/nfsfile /nfsfile nfs defaults 0 0
12.3 AutoFs自動掛載服務

不論咱們是想使用前面學習的Samba還是NFS服務,都要把掛載資訊寫入到/etc/fstab中,這樣遠端共享資源就會自動的隨伺服器開機而掛載,雖然這樣一勞永逸確實很方便,但如果掛載的遠端資源很多的話,畢竟會或多或少消耗著伺服器的一定網路頻寬和CPU計算效能。如果掛載後長期不去使用這些服務,那麼無疑這筆損耗是白白被浪費掉了,當然還會有同學說可以每次使用前都執行下mount命令手動的掛載上,這雖然是個不錯的選擇,但每次都要去掛載一下再使用,這樣是不是又很麻煩呢?

AutoFs服務程式與Mount命令不同之處在於它是一種守護程序,只有檢測到使用者試圖訪問一個尚未掛載的檔案系統時才自動的檢測並掛載該檔案系統。換句話說,把掛載資訊填入/etc/fstab檔案後系統將在每次開機時都自動把其掛載,而執行AutoFs服務後則是當用戶需要使用該檔案系統了才會動態的掛載,節約伺服器的網路與系統資源。

[[email protected] ~]# yum install autofs
Loaded plugins: langpacks, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
rhel | 4.1 kB 00:00 
Resolving Dependencies
--> Running transaction check
---> Package autofs.x86_64 1:5.0.7-40.el7 will be installed
--> Processing Dependency: libhesiod.so.0()(64bit) for package: 1:autofs-5.0.7-40.el7.x86_64
--> Running transaction check
---> Package hesiod.x86_64 0:3.2.1-3.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
 Package Arch Version Repository Size
================================================================================
Installing:
 autofs x86_64 1:5.0.7-40.el7 rhel 550 k
Installing for dependencies:
 hesiod x86_64 3.2.1-3.el7 rhel 30 k
Transaction Summary
================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 579 k
Installed size: 3.6 M
Is this ok [y/d/N]: y
Downloading packages:
--------------------------------------------------------------------------------
Total 9.4 MB/s | 579 kB 00:00 
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
 Installing : hesiod-3.2.1-3.el7.x86_64 1/2 
 Installing : 1:autofs-5.0.7-40.el7.x86_64 2/2 
 Verifying : hesiod-3.2.1-3.el7.x86_64 1/2 
 Verifying : 1:autofs-5.0.7-40.el7.x86_64 2/2 
Installed:
 autofs.x86_64 1:5.0.7-40.el7 
Dependency Installed:
 hesiod.x86_64 0:3.2.1-3.el7 
Complete!

生產環境中一般都會同時管理著很多裝置的掛載工作,如果把這些裝置掛載資訊都寫入到autofs服務主配置檔案中的話肯定無疑會讓主配置檔案臃腫不堪,不利於服務執行效率,也不利於日後修改裡面的配置內容,所以在autofs服務程式的主配置檔案中需要按照“掛載目錄 子配置檔案”的格式寫入引數。掛載目錄是裝置要掛載位置的上一級目錄,例如