 NFS服務(wu)端和(he)ftfp客戶(hu)端配置的(de)詳細步驟
							時間:2018-08-10      來源(yuan):未知
							NFS服務(wu)端和(he)ftfp客戶(hu)端配置的(de)詳細步驟
							時間:2018-08-10      來源(yuan):未知 
							配置 tftp 服務的步驟:
1.若/etc/xinetd.d/下(xia)存在 tftp,執行下(xia)列操作(zuo)
1)關閉 xinetd 服務
$sudo service xinetd stop 2)刪除 tftp 文件
$sudo rm /etc/xinetd.d/tftp
3) 啟(qi)動(dong) xinetd 服(fu)務
$sudo service xinetd start
2.安裝 tftp 客戶端和服(fu)務器端
$sudo apt-get install tftp-hpa
$sudo apt-get install tftpd-hpa
3. 修改 tftpd-hpa 配置文(wen)件
$vim /etc/default/tftpd-hpa
修改 “/var/lib/tftpboot” 為 “/tftpboot”
修改 "--secure" 為 "--secure -c" 允許上傳新文(wen)件
4.若(ruo)/tftpboot 不存(cun)在(zai),創(chuang)建該目(mu)錄 $sudo mkdir /tftpboot
$sudo chmod 777 /tftpboot
5.重啟 tftpd-hpa 服務(wu)
$sudo service tftpd-hpa restart
若服務重啟成功,能查看(kan)到(dao)相應的進程
$ps -ef |grep in.tftpd
至此 tftp 服務已經安裝完成了,下(xia)面可以對其進行一下(xia)測(ce)(ce)試。(假設在當前目錄下(xia)有一個測(ce)(ce)試文件 test.txt)
$tftp 127.0.0.1
tftp> put test.txt
Sent 1018 bytes in 0.0 seconds
tftp> get test.txt
Received 1018 bytes in 0.1 seconds
tftp> quit
$
通過(guo) get 命令(ling),可以(yi)把當前目(mu)錄(lu)下的 test.txt 文(wen)件(jian),通過(guo) tftp 上傳(chuan)到它的服務文(wen)件(jian)目(mu)錄(lu)。這(zhe)時,在/tftpboot 下面會出現 test.txt 文(wen)件(jian)。通過(guo) put 命令(ling),可以(yi)從/tftpboot 下,下載(zai) test.txt 文(wen)件(jian)。這(zhe)樣就驗證了 tftp 服務配置的正確性。當文(wen)件(jian)上傳(chuan)與下載(zai)結束后,可以(yi)通過(guo) quit 命令(ling)退出。
在 ubuntu 下(xia)安(an)裝、配置 nfs 服務的步驟如下(xia):
1、安(an)裝 nfs
Ubuntu 上默認是(shi)沒有安(an)裝(zhuang) nfs 服(fu)務(wu)器(qi)的(de),因此(ci)我們(men)首(shou)先安(an)裝(zhuang) nfs 服(fu)務(wu)器(qi)端: $sudo apt-get install nfs-kernel-server
2、配(pei)置/etc/exports
nfs 允許掛載的目(mu)錄及權限(xian)在(zai)文(wen)件/etc/exports 中進行了定義。
例(li)如(ru),我們要(yao)將根(gen)目(mu)錄(lu)下的 rootfs 目(mu)錄(lu)共享出(chu)來,那么(me)我們需要(yao)在(zai)/etc/exports 文件末尾添加如(ru)下一行:/rootfs *(rw,sync,no_root_squash)
其(qi)中:/rootfs 是(shi)(shi)要(yao)共享的(de)目錄,*代表允許所有的(de)網絡段訪問(wen),rw 是(shi)(shi)可(ke)讀寫(xie)權(quan)限,sync 是(shi)(shi)資料同步寫(xie)入內存和(he)硬盤,no_root_squash 是(shi)(shi) nfs 客戶(hu)(hu)端(duan)分享目錄使用者的(de)權(quan)限,如果客戶(hu)(hu)端(duan)使用的(de)是(shi)(shi) root 用戶(hu)(hu),那么對于該(gai)共享目錄而(er)言,該(gai)客戶(hu)(hu)端(duan)就(jiu)具有 root 權(quan)限。其(qi)它 nfs 常用的(de)參數有:
ro 只讀訪問
rw 讀寫訪問 sync 所有數據在請(qing)求時寫入共(gong)享(xiang)
async nfs 在寫入(ru)數(shu)據前可以響應請求
secure nfs 通(tong)過 1024 以下(xia)的安全 TCP/IP 端口發送(song)
insecure nfs 通(tong)過 1024 以(yi)上(shang)的端口發(fa)送
wdelay 如果多個用戶要寫入(ru) nfs 目錄,則歸組寫入(ru)(默認)
no_wdelay 如果多個(ge)用(yong)(yong)戶要寫(xie)入(ru) nfs 目(mu)錄,則立即寫(xie)入(ru),當使用(yong)(yong) async 時,無需此設置。 hide 在(zai) nfs 共(gong)(gong)享目(mu)錄中不(bu)共(gong)(gong)享其子目(mu)錄
no_hide 共享 nfs 目(mu)錄的子目(mu)錄
subtree_check 如果共享/usr/bin 之類的子目(mu)錄時,強制 nfs 檢查父目(mu)錄的權限(默認) no_subtree_check 和上面相(xiang)對,不檢查父目(mu)錄權限
all_squash 共享文件(jian)的 UID 和 GID 映射(she)匿名用戶 anonymous ,適合公用目錄。
no_all_squash 保留共享文件的(de) UID 和 GID(默認)
root_squash root 用(yong)戶的所(suo)有請(qing)求映射成如 anonymous 用(yong)戶一樣(yang)的權(quan)限(默(mo)認(ren)) no_root_squas root 用(yong)戶具有根目錄的完全管理訪問權(quan)限
anonuid=xxx 指定(ding) nfs 服(fu)務器/etc/passwd 文件中(zhong)匿名(ming)用戶的 UID anongid=xxx 指定(ding) nfs 服(fu)務器/etc/passwd 文件中(zhong)匿名(ming)用戶的 GID
3、重啟(qi)服務
$sudo /etc/init.d/portmap restart
$sudo /etc/init.d/nfs-kernel-server restart
4、測(ce)試(shi) nfs
此時可以運行以下命令來(lai)顯(xian)示一下共(gong)享出來(lai)的目錄:
$showmount -e
或(huo)者可以(yi)使用以(yi)下命(ming)令把它掛載在本地磁(ci)盤上,例如將/rootfs 掛載到/mnt 下:
$ sudo mount -t nfs localhost:/rootfs /mnt
可(ke)以(yi)運(yun)行 df 命令查看(kan)是否掛載成(cheng)功。查看(kan)后可(ke)以(yi)使用以(yi)下命令卸載:
$ sudo umount /mnt

