NFS服務(wù)的開(kāi)啟過(guò)程
在諸多系統(tǒng)中,我們都需要手動(dòng)來(lái)開(kāi)啟和設(shè)置NFS服務(wù)。那么這里我們基于Ubuntu系統(tǒng)來(lái)講解一下相關(guān)的設(shè)置。下面讓我們來(lái)看一下具體的過(guò)程吧。Ubuntu默認(rèn)是沒(méi)有nfs服務(wù)的,所以需要自己安裝。
1、安裝nfs服務(wù)版
apt-get install nfs-kernel-server
2、修改nsf服務(wù)配置文件
vi /etc/exports
在文件中添加nfs的目錄格式如下
/armnfs *(sync,rw)
存盤(pán)退出
3、在根目錄下建立nsf的目錄
mkdir /armnfs
修改該目錄的權(quán)限
chmod 777 -R /armnfs
4、從新啟動(dòng)nfs
/etc/init.d/nfs-kernel-server restart
5、測(cè)試nsf服務(wù)
mount 192.168.1.99:/armnfs/ abc
嵌入式要mount 的時(shí)候 使用
mount -o nolock 192.168.1.99:/armnfs/new8120 /mnt/net
注:在內(nèi)核的配置里面的
Networking options --->選項(xiàng)中
啟用 TCP/IP networking
啟用IP: kernel level autoconfiguration
General setup ---> 選項(xiàng)中 ,
Default kernel command string: (默認(rèn)的內(nèi)核命令行)
加入綠色字中的字符
root=/dev/nfs rw nfsroot=192.168.1.99:/armnfs/ ip=192.168.1.201 init=/linuxrc console=ttyS0
File system ---> Network File System --->選項(xiàng)
啟用NFSfile system support
啟用 Provide NFSv3 client support
啟用 Root file system on NFS#p#
NFS服務(wù)配置:
- less /etc/exports
- /home/xx/ 192.168.0.*(rw,sync)
- $ sudo /etc/init.d/portmap start
- * Starting portmap daemon...
- * Already running. [ OK ]
- $sudo /etc/init.d/nfs-common start
- * StartingNFScommon utilities [ OK ]
- $ sudo /etc/init.d/nfs-kernel-server start
- * Exporting directories forNFSkernel daemon...
- exportfs: /etc/exports [2]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.0.*:/home/xx/".
- Assuming default behaviour ('subtree_check').
- NOTE: this default will change with nfs-utils version 1.1.0
- [ OK ]
- * Starting NFS kernel daemon [ OK ]
- $ showmount -e
- Export list for Qunhome:
- /home/xx 192.168.0.*
注意:似乎都好了,可是 :
- sudo mount 192.168.0.100:/home/xx /mnt
- mount: 192.168.0.100:/home/xx failed, reason given by server: Permission denied
在/etc/exports下寫(xiě)入你的IP地址,不要有*號(hào).例如:(/home/zwg IP(rw,sync,no_root_squash))
原因可能是etc目錄下沒(méi)有hosts.allow和hosts.deny這倆個(gè)文件.
配置portmap的時(shí)候,在etc目錄下就沒(méi)有找到host.allow和hosts.deny這倆個(gè)文件,我是自己新建的這倆個(gè)文件,以前我記得在etc目錄下是有的.
我刪除了安裝文件和所有相關(guān)配置文件,然后一步步重新來(lái),最后成功了
做的改動(dòng)為:
在etchosts中用IP lists 代替 *
還有一種方法:安裝配置NFS服務(wù)的沒(méi)有大問(wèn)題.不妨在括號(hào)里加上no_subtree_check選項(xiàng),這是減少文件共享訪(fǎng)問(wèn)檢查的,如果你的共享目錄在本地沒(méi)有很多讀寫(xiě)請(qǐng)求的話(huà)(man exports).
- On the master node, edit your /etc/hosts.allow file to allow connections from slave nodes. If your cluster LAN is on 192.168.1.0/24, your hosts.allow will look like:
- Code Listing 2.10: hosts.allow
- portmap:192.168.1.0/255.255.255.0
- Edit the /etc/exports file of the master node to export a work directory structure (/home is good for this).
- Code Listing 2.11: /etc/exports
- /home/ *(rw)
把hosts.deny刪除.子網(wǎng)用掩碼的方法表示.