實驗01:NFS共享設置
實驗目標
NFS共享設置
實驗步驟
配置NFS服務器
[root@svr5/]# vim /etc/exports
/root 192.168.4.6(rw,sync)
啓用RPC機制
[root@svr5/]# service rpcbind restart
停止 rpcbind: [確定]
正在啓動 rpcbind: [確定]
啓用nfs服務
[root@svr5/]# service nfs restart
關閉 NFS 守護進程: [確定]
關閉 NFS mountd: [確定]
關閉 NFS quotas: [確定]
關閉 NFS 服務: [確定]
Shutting down RPCidmapd: [確定]
啓動 NFS 服務: [確定]
關掉 NFS 配額: [確定]
啓動 NFS mountd: [確定]
啓動 NFS 守護進程: [確定]
正在啓動 RPC idmapd: [確定]
查看共享文件
[root@svr5/]# showmount -e 192.168.4.5
Export list for192.168.4.5:
/root 192.168.4.6
客戶機測試
啓用RPC機制
[root@svr5/]# service rpcbind restart
停止 rpcbind: [確定]
正在啓動 rpcbind: [確定]
查看共享文件
[root@svr5/]# showmount -e 192.168.4.5
Export list for192.168.4.5:
/root 192.168.4.6
掛載共享目錄
[root@pc205桌面]# mount 192.168.4.5:/root/ /mnt/nfsdir/(掛載)
[root@pc205桌面]# mount(查看)
................................
192.168.4.5:/root/on /mnt/nfsdir type nfs (rw,vers=4,addr=192.168.4.5,clientaddr=192.168.4.28)
[root@pc205桌面]# df -hT /mnt/nfsdir/(查看)
Filesystem Type Size Used Avail Use% Mounted on
192.168.4.5:/root/nfs 39G 3.4G 34G 10% /mnt/nfsdir
檢查權限
[root@pc205桌面]# cd /mnt/nfsdir/
bash:cd: /mnt/nfsdir/: 權限不夠
3. 修改共享設置,再重新發布
服務器上:
[root@svr5 /]# vim /etc/exports
/root 192.168.4.28(rw,sync,no_root_squash)
[root@svr5 /]# exportfs -rv
exporting 192.168.4.28:/root
客戶機上:
[root@pc205桌面]# umount /mnt/nfsdir/
[root@pc205桌面]# mount 192.168.4.5:/root/ /mnt/nfsdir/
[root@pc205桌面]# cd /mnt/nfsdir/
[root@pc205nfsdir]# touch pc205.txt
[root@pc205nfsdir]# ls
anaconda-ks.cfg install.log.syslog 公共的 視頻 文檔 音樂
install.log pc205.txt 模板 圖片 下載 桌面
squash相關權限驗證
服務器修改配置
創建文件
[root@svr5/]# mkdir -m 777 /public
配置文件
[root@svr5/]# vim /public/welcome.txt
This is NFS Server
配置NFS文件
[root@svr5/]# vim /etc/exports
/root 192.168.4.28(rw,sync,no_root_squash)
/public 192.168.4.0/24(rw)
[root@svr5/]# exportfs -rv
exporting192.168.4.0/24:/public
exporting192.168.4.28:/root
客戶端測試
創建掛載點
[root@pc205nfsdir]# mkdir /mnt/nfsdir2/
掛載
[root@pc205nfsdir]# mount 192.168.4.5:/public /mnt/nfsdir2/
切換用戶
[root@pc205nfsdir]# su - zhangsan
[zhangsan@pc205~]$ cd /mnt/nfsdir2/
[zhangsan@pc205nfsdir2]$ touch zhs.txt
[zhangsan@pc205nfsdir2]$ ls -lh zhs.txt
-rw-rw-r--. 1zhangsan zhangsan 0 9月 14 03:04 zhs.txt
修改NFS共享設置
[root@svr5/]# vim /etc/exports
...............................
/public 192.168.4.0/24(rw,all_squash)
[root@svr5/]# exportfs -rv
exporting192.168.4.0/24:/public
exporting192.168.4.28:/root
客戶端再測試
[zhangsan@pc205~]$ cd /mnt/nfsdir2/
[zhangsan@pc205nfsdir2]$ touch zhs-new.txt
[zhangsan@pc205nfsdir2]$ ls -lh zhs-new.txt
-rw-rw-r--. 1nfsnobody nfsnobody 0 9月 14 03:11 zhs-new.txt
問題和經驗總結
故障現象:
1.[root@pc205 桌面]# showmount -e 192.168.4.5
clnt_create: RPC:Port mapper failure - Unable to receive: errno 113 (No route to host)
解決辦法:、
檢查防火牆是否關閉,關閉防火牆後再看結果
故障現象:
2.[root@pc205 桌面]# mount 192.168.4.5:/root/ /mnt/nfsdir/
mount.nfs: accessdenied by server while mounting 192.168.4.5:/root/
解決辦法:檢查配置文件中的ip地址與客戶端的ip是否一致,不一致則修改ip;若一致,在查看給的權限是否允許掛載這個操作,修改權限