溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

nfs網(wǎng)絡(luò)文件系統(tǒng)--學(xué)習(xí)筆記

發(fā)布時間:2020-03-02 08:25:32 來源:網(wǎng)絡(luò) 閱讀:96 作者:15128179570 欄目:系統(tǒng)運維

本次實驗的環(huán)境是redhat 7.0系統(tǒng)
nfs服務(wù)可以將遠程linux服務(wù)器上的文件共享資源掛載到本地linux主機上,本地的linux主機可以基于TCP/IP協(xié)議,像使用本地目錄文件一樣去操作遠程共享的目錄文件。

1. 服務(wù)器端

1.1 安裝

[root@localhost Desktop]# yum install nfs-utils -y

# 關(guān)閉iptables
[root@localhost Desktop]# iptables -F
[root@localhost Desktop]# system^C
[root@localhost Desktop]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]

1.2 創(chuàng)建共享目錄

[root@localhost Desktop]# mkdir /nfsdir
# 確保共享目錄有權(quán)限,其他人可以讀寫
[root@localhost Desktop]# chmod -Rf 777 /nfsdir

1.3 配置nfs

主配置文件/etc/exports
格式:共享目錄的路徑 允許訪問的nfs客戶端IP(共享權(quán)限參數(shù)),nfs客戶端IP和權(quán)限之間沒有空格。
權(quán)限的參數(shù):

參數(shù) 作用
ro 只讀
rw 讀寫
root_squash 當(dāng)nfs客戶端以root管理員訪問時,映射為nfs服務(wù)器的匿名用戶
no_root_squash 芳nfs客戶端以root管理員訪問時,映射為nfs服務(wù)器的root管理員
all_saquash 無論nfs客戶端使用什么賬戶訪問,均映射為nfs服務(wù)器的匿名用戶
sync 同時將數(shù)據(jù)寫入到內(nèi)存與硬盤中,保證數(shù)據(jù)不丟
async 優(yōu)先將數(shù)據(jù)保存到內(nèi)存,然后再寫入硬盤;這樣效率高,但有可丟失數(shù)據(jù)
[root@localhost Desktop]# vim /etc/exports
/nfsdir 192.168.137.*(rw,sync,root_squash)

1.4 啟動

# 啟動RPC,nfs需要使用RPC服務(wù)
[root@localhost Desktop]# systemctl restart rpcbind.service 
[root@localhost Desktop]# systemctl enable rpcbind.service 
# 啟動nfs
[root@localhost Desktop]# systemctl restart nfs-server
[root@localhost Desktop]# systemctl enable nfs-server
ln -s '/usr/lib/systemd/system/nfs-server.service' '/etc/systemd/system/nfs.target.wants/nfs-server.service'

2. 客戶端

2.1 安裝nfs-utils工具

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

2.2 查詢服務(wù)端共享信息

showmount 命令的參數(shù)

參數(shù) 作用
-e 顯示nfs服務(wù)器的共享列表
-a 顯示本機掛載的fns資源
[root@localhost ~]# showmount -e 192.168.137.10
Export list for 192.168.137.10:
/nfsdir 192.168.137.*

2.3 掛載

[root@localhost ~]# mkdir /nfsdir
[root@localhost ~]# mount -t nfs 192.168.137.10:/nfsdir /nfsdir
[root@localhost ~]# df -Th
Filesystem             Type      Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root  xfs        18G  3.0G   15G  17% /
devtmpfs               devtmpfs  985M     0  985M   0% /dev
tmpfs                  tmpfs     994M  140K  994M   1% /dev/shm
tmpfs                  tmpfs     994M  8.9M  986M   1% /run
tmpfs                  tmpfs     994M     0  994M   0% /sys/fs/cgroup
/dev/sda1              xfs       497M  112M  385M  23% /boot
/dev/sr0               iso9660   3.5G  3.5G     0 100% /media/cdrom
192.168.137.10:/nfsdir nfs4       18G  3.0G   15G  17% /nfsdir

測試成功

向AI問一下細節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI