nfs掛載步驟
服務器端
1.安裝nfs-utils rpcbind
$sudo yum –y install nfs-utils rpcbind
2.文件開放出去配置/etc/exports
例子:/opt/data IP(rw, no_root_squash,no_all_squash,sync)
3.執行配置文件/etc/exports
$exportfs -r
4.Nfs配置生效並使rpcbind和nfs服務開機啟動
$sudo systemctl enable rpcbind
$sudo systemctl enable nfs(當報錯時可改為: $sudo systemctl enable nfs-server.service)
$sudo systemctl start rpcbind
$sudo systemctl start nfs(當報錯時可改為:$sudo systemctl start nfs-server.service)
$sudo systemctl status rpcbind
$sudo systemctl staus nfs(當報錯時可改為:$sudo systemctl status nfs-server.service)
5.查看掛載命令
$showmount –e IP
6.客戶端掛載步驟
1)安裝nfs-utils rpcbind(同上)
2)Nfs配置生效並使rpcbind和nfs服務開機啟動(同上)
3)掛載命令(IP為服務器端ip地址)
$sudo mount –t nfs IP:/opt/data /opt/data
以下為nfs資料
一、NFS服務器的設定
NFS服務器的設定可以通過/etc/exports這個文件進行,設定格式如下:
分享目錄 主機名稱或者IP(參數1,參數2)
/arm2410s 10.22.22.*(rw,sync,no_root_squash)
可以設定的參數主要有以下這些:
rw:可讀寫的權限;
ro:只讀的權限;
no_root_squash:登入到NFS主機的用戶如果是root,該用戶即擁有root權限;
root_squash:登入NFS主機的用戶如果是root,該用戶權限將被限定為匿名使用者nobody;
all_squash:不管登陸NFS主機的用戶是何權限都會被重新設定為匿名使用者nobody。
anonuid:將登入NFS主機的用戶都設定成指定的user id,此ID必須存在於/etc/passwd中。
anongid:同anonuid,但是變成group ID就是了!
sync:資料同步寫入存儲器中。
async:資料會先暫時存放在內存中,不會直接寫入硬盤。
insecure:允許從這台機器過來的非授權訪問。
例如可以編輯/etc/exports為:
/tmp *(rw,no_root_squash)
/home/public 192.168.0.*(rw) *(ro)
/home/test 192.168.0.100(rw)
/home/Linux *.the9.com(rw,all_squash,anonuid=40,anongid=40)
設定好后可以使用以下命令啟動NFS:
/etc/rc.d/init.d/portmap start (在REDHAT中PORTMAP是默認啟動的)
/etc/rc.d/init.d/nfs start
exportfs命令
如果我們在啟動了NFS之后又修改了/etc/exports,是不是還要重新啟動nfs呢?這個時候我們就可以用exportfs命令來使改動立刻生效,該命令格式如下:
exportfs [-aruv]
-a :全部mount或者unmount /etc/exports中的內容
-r :重新mount /etc/exports中分享出來的目錄
-u :umount 目錄
-v :在 export 的時候,將詳細的信息輸出到屏幕上。
二、NFS客戶端的操作:
1、showmout命令對於NFS的操作和查錯有很大的幫助,所以我們先來看一下showmount的用法
showmout
-a :這個參數是一般在NFS SERVER上使用,是用來顯示已經mount上本機nfs目錄的cline機器。
-e :顯示指定的NFS SERVER上export出來的目錄。
2、mount nfs目錄的方法:
mount -t nfs hostname(orIP):/directory /mount/point
