NFS服務的開啟過程
在諸多系統中,我們都需要手動來開啟和設置NFS服務。那么這里我們基于Ubuntu系統來講解一下相關的設置。下面讓我們來看一下具體的過程吧。Ubuntu默認是沒有nfs服務的,所以需要自己安裝。
1、安裝nfs服務版
apt-get install nfs-kernel-server
2、修改nsf服務配置文件
vi /etc/exports
在文件中添加nfs的目錄格式如下
/armnfs *(sync,rw)
存盤退出
3、在根目錄下建立nsf的目錄
mkdir /armnfs
修改該目錄的權限
chmod 777 -R /armnfs
4、從新啟動nfs
/etc/init.d/nfs-kernel-server restart
5、測試nsf服務
mount 192.168.1.99:/armnfs/ abc
嵌入式要mount 的時候 使用
mount -o nolock 192.168.1.99:/armnfs/new8120 /mnt/net
注:在內核的配置里面的
Networking options --->選項中
啟用 TCP/IP networking
啟用IP: kernel level autoconfiguration
General setup ---> 選項中 ,
Default kernel command string: (默認的內核命令行)
加入綠色字中的字符
root=/dev/nfs rw nfsroot=192.168.1.99:/armnfs/ ip=192.168.1.201 init=/linuxrc console=ttyS0
File system ---> Network File System --->選項
啟用NFSfile system support
啟用 Provide NFSv3 client support
啟用 Root file system on NFS#p#
NFS服務配置:
- 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下寫入你的IP地址,不要有*號.例如:(/home/zwg IP(rw,sync,no_root_squash))
原因可能是etc目錄下沒有hosts.allow和hosts.deny這倆個文件.
配置portmap的時候,在etc目錄下就沒有找到host.allow和hosts.deny這倆個文件,我是自己新建的這倆個文件,以前我記得在etc目錄下是有的.
我刪除了安裝文件和所有相關配置文件,然后一步步重新來,最后成功了
做的改動為:
在etchosts中用IP lists 代替 *
還有一種方法:安裝配置NFS服務的沒有大問題.不妨在括號里加上no_subtree_check選項,這是減少文件共享訪問檢查的,如果你的共享目錄在本地沒有很多讀寫請求的話(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刪除.子網用掩碼的方法表示.