版權聲明:轉載時請以超鏈接形式標明文章原始出處和作者信息及本聲明
http://blog.csdn.net/wenshuangzhu/article/details/44079473
1.Server端
1.1 檢查是否已經安裝NFS服務
檢查是否安裝nfs-kernel-server:
vms240:~ # rpm -aq|grep nfs
nfs-client-1.2.1-2.6.6
yast2-nfs-common-2.17.7-1.1.2
nfs-kernel-server-1.2.1-2.6.6
nfs-doc-1.2.1-2.6.6
yast2-nfs-server-2.17.7-1.1.2
limal-nfs-server-perl-1.5.3-0.2.11
nfsidmap-0.20-1.20
limal-nfs-server-1.5.3-0.2.11
yast2-nfs-client-2.17.12-0.1.81
若沒有安裝則插入SUSE安裝盤,運行yast2安裝即可,比較簡單。
1.2 啓動NFS服務
vms240:~ # service nfsserver start
Starting kernel based NFS server: idmapd mountd statdnfsd sm-notify done
1.3 查看NFS運行狀態
vms240:~ # service nfsserver status
Checking for kernel based NFS server: idmapd running
mountd running
statd running
nfsd running
1.4 查看已有的共享目錄
vms240:~ # showmount -e
Export list for vms240:
1.5 設置共享目錄
vms240:~ # vi /etc/exports
# See the exports(5) manpage for a description of thesyntax of this file.
# This file contains a list of all directories thatare to be exported to
# other computers via NFS (Network File System).
# This file used by rpc.nfsd and rpc.mountd. Seetheir manpages for details
# on how make changes in this file effective.
/home/xws *(rw,sync,no_root_squash,no_all_squash,no_subtree_check)
註釋:
/home/xws 是你想共享出去的目錄。
* 表示可以訪問的IP範圍,這裏是所有ip地址都可以訪問,當然也可以寫上具體的IP地址或者hostname來代替。
rw可讀寫權限。
sync同步寫入存儲器。
no_all_squash 保留共享文件的UID和GID(默認)。
no_root_squash 表示root用戶具有根目錄的完全管理訪問權限。
no_subtree_check不檢測子目錄,提高性能。
上面的配置比較經典,客戶端訪問的時候直接登入不用驗證。
1.6 重新加載NFS
vms240:~ # exportfs -rv
exporting *:/home/xws
1.7 配置NFS開機自啓動
vms240:~ # chkconfig nfsserver on
vms240:~ # chkconfig --list nfsserver
nfsserver 0:off 1:off 2:off 3:on 4:off 5:on 6:off
2. Client端
2.1 檢查是否已經安裝RPCBIND服務
檢查客戶端是否已安裝rpcbind包(SUSE11默認安裝此服務,並且開機自啓動):
vms216:~ # rpm -aq|grep rpcbind
rpcbind-0.1.6+git20080930-6.15
2.2 掃瞄可以使用的NFS共享目錄
vms216:~ # showmount -e 172.16.54.240
Export list for 172.16.54.240:
/home/xws *
2.3 創建掛載點目錄
vms216:~ # mkdir /home/test
2.4 利用mount指令來掛載共享目錄
到客戶端機器的/home/test目錄:
vms216:~ # mount -t nfs 172.16.54.240:/home/xws /home/test
掛載成功後,只要進入/home/test目錄,就等於到了172.16.54.240的/home/xws共享目錄中。
2.5 查看已掛載的NFS共享盤
vms216:~ # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.9G 381M 9.0G 4% /
devtmpfs 1.6G 136K 1.6G 1% /dev
tmpfs 1.6G 0 1.6G 0% /dev/shm
/dev/sda2 1004M 43M 910M 5% /boot
/dev/sda10 101G 27G 69G 28% /home
/dev/sda9 50G 27G 20G 58% /home/database
/dev/sda5 20G 3.3G 16G 18% /opt
/dev/sda7 9.9G 264M 9.1G 3% /tmp
/dev/sda6 15G 3.1G 11G 23% /usr
/dev/sda3 15G 333M 14G 3% /var
172.16.54.240:/home/xws
101G 25G 71G 26% /home/test
2.6 配置開機自動掛載
vms216:~ # vi /etc/init.d/after.local
增加下面一行內容並保存文件:
mount -t nfs 172.16.54.240:/home/xws /home/test
修改文件權限爲可執行:
vms216:~ # chmod +x /etc/init.d/after.local
2.7 卸載NFS盤
vms216:~ # umount /home/test
1.1 檢查是否已經安裝NFS服務
檢查是否安裝nfs-kernel-server:
vms240:~ # rpm -aq|grep nfs
nfs-client-1.2.1-2.6.6
yast2-nfs-common-2.17.7-1.1.2
nfs-kernel-server-1.2.1-2.6.6
nfs-doc-1.2.1-2.6.6
yast2-nfs-server-2.17.7-1.1.2
limal-nfs-server-perl-1.5.3-0.2.11
nfsidmap-0.20-1.20
limal-nfs-server-1.5.3-0.2.11
yast2-nfs-client-2.17.12-0.1.81
若沒有安裝則插入SUSE安裝盤,運行yast2安裝即可,比較簡單。
1.2 啓動NFS服務
vms240:~ # service nfsserver start
Starting kernel based NFS server: idmapd mountd statdnfsd sm-notify done
1.3 查看NFS運行狀態
vms240:~ # service nfsserver status
Checking for kernel based NFS server: idmapd running
mountd running
statd running
nfsd running
1.4 查看已有的共享目錄
vms240:~ # showmount -e
Export list for vms240:
1.5 設置共享目錄
vms240:~ # vi /etc/exports
# See the exports(5) manpage for a description of thesyntax of this file.
# This file contains a list of all directories thatare to be exported to
# other computers via NFS (Network File System).
# This file used by rpc.nfsd and rpc.mountd. Seetheir manpages for details
# on how make changes in this file effective.
/home/xws *(rw,sync,no_root_squash,no_all_squash,no_subtree_check)
註釋:
/home/xws 是你想共享出去的目錄。
* 表示可以訪問的IP範圍,這裏是所有ip地址都可以訪問,當然也可以寫上具體的IP地址或者hostname來代替。
rw可讀寫權限。
sync同步寫入存儲器。
no_all_squash 保留共享文件的UID和GID(默認)。
no_root_squash 表示root用戶具有根目錄的完全管理訪問權限。
no_subtree_check不檢測子目錄,提高性能。
上面的配置比較經典,客戶端訪問的時候直接登入不用驗證。
1.6 重新加載NFS
vms240:~ # exportfs -rv
exporting *:/home/xws
1.7 配置NFS開機自啓動
vms240:~ # chkconfig nfsserver on
vms240:~ # chkconfig --list nfsserver
nfsserver 0:off 1:off 2:off 3:on 4:off 5:on 6:off
2. Client端
2.1 檢查是否已經安裝RPCBIND服務
檢查客戶端是否已安裝rpcbind包(SUSE11默認安裝此服務,並且開機自啓動):
vms216:~ # rpm -aq|grep rpcbind
rpcbind-0.1.6+git20080930-6.15
2.2 掃瞄可以使用的NFS共享目錄
vms216:~ # showmount -e 172.16.54.240
Export list for 172.16.54.240:
/home/xws *
2.3 創建掛載點目錄
vms216:~ # mkdir /home/test
2.4 利用mount指令來掛載共享目錄
到客戶端機器的/home/test目錄:
vms216:~ # mount -t nfs 172.16.54.240:/home/xws /home/test
掛載成功後,只要進入/home/test目錄,就等於到了172.16.54.240的/home/xws共享目錄中。
2.5 查看已掛載的NFS共享盤
vms216:~ # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 9.9G 381M 9.0G 4% /
devtmpfs 1.6G 136K 1.6G 1% /dev
tmpfs 1.6G 0 1.6G 0% /dev/shm
/dev/sda2 1004M 43M 910M 5% /boot
/dev/sda10 101G 27G 69G 28% /home
/dev/sda9 50G 27G 20G 58% /home/database
/dev/sda5 20G 3.3G 16G 18% /opt
/dev/sda7 9.9G 264M 9.1G 3% /tmp
/dev/sda6 15G 3.1G 11G 23% /usr
/dev/sda3 15G 333M 14G 3% /var
172.16.54.240:/home/xws
101G 25G 71G 26% /home/test
2.6 配置開機自動掛載
vms216:~ # vi /etc/init.d/after.local
增加下面一行內容並保存文件:
mount -t nfs 172.16.54.240:/home/xws /home/test
修改文件權限爲可執行:
vms216:~ # chmod +x /etc/init.d/after.local
2.7 卸載NFS盤
vms216:~ # umount /home/test