redhat 7.2 NFS服務搭建

Nfs
1.開放/nfs/shared目錄,供所有用戶查詢資料
(服務器端):
vim /etc/exports
在這裏插入圖片描述
touch {1,2,3}
systemctl restart nfs
exportfs -a

(客戶端):
mount 192.168.10.129:/nfs/shared /mnt
cd /mnt
[root@desktop mnt]# ll
總用量 0
-rw-r–r--. 1 root root 0 12月 6 14:01 1
-rw-r–r--. 1 root root 0 12月 6 14:01 2
-rw-r–r--. 1 root root 0 12月 6 14:01 3

2.開放/nfs/upload目錄作爲192.168.200.0/24網段的數據上傳目錄,
並將所有用戶及所屬的用戶組映射爲nfs-upload,其UID和GID均爲201
(服務器端):
vim /etc/exports
在這裏插入圖片描述
groupadd -g 201 nfs-upload
useradd -u 201 -g 201 ufs-upload
chmod o+w /nfs/upload/
cd /nfs/upload/
touch 4 5 6
systemctl restart nfs
exportfs -a
(客戶端):
[root@desktop /]# mount 192.168.10.129:/nfs/upload /mnt
[root@desktop /]# cd /mnt
[root@desktop mnt]# ll
-rw-r–r--. 1 root root 0 12月 6 14:10 4
-rw-r–r--. 1 root root 0 12月 6 14:10 5
-rw-r–r--. 1 root root 0 12月 6 14:10 6
[root@desktop mnt]# touch 7
[root@desktop mnt]# ll
總用量 0
-rw-r–r--. 1 root root 0 12月 6 14:10 4
-rw-r–r--. 1 root root 0 12月 6 14:10 5
-rw-r–r--. 1 root root 0 12月 6 14:10 6
-rw-r–r--. 1 201 201 0 12月 6 14:12 7
服務器端查看用戶映射:
在這裏插入圖片描述
1.將/home/tom目錄僅共享給192.168.171.144這臺主機,並只有用戶tom可以完全訪問該目錄
(服務器端:)
在這裏插入圖片描述
[root@server home]# id tom
uid=1011(tom) gid=1011(tom) 組=1011(tom)
chmod 700 /home/nfs-upload/

(客戶端:)
groupadd -g 1011 tom
useradd -u 1011 -g 1011 tom
su - tom
cd /mnt
[tom@desktop mnt]$ ll
總用量 0
-rw-rw-r–. 1 tom tom 0 12月 6 14:23 123

測試其他用戶權限:
在這裏插入圖片描述
切換用戶到tom:
在這裏插入圖片描述在這裏插入圖片描述

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