日期:2014-05-16  浏览次数:20661 次

Linux下NFS服务器的配置

类型:System V-launched Service
软件包:nfs-utils
进程:nfsd,lockd,rpciod,rpc.{mounted,rquotad,statd}
脚本:nfs,nfslock
端口:由portmap服务指派端口(111)
配置文件:/etc/exports
辅助工具:portmap(必须)
相关命令:rpcinfo -p [IPADD]:查看服务器提供的rpc服务
? ?? ?? ? showmount -e:查看服务共享的目录
Server端:
1./etc/exports格式:
? ?? ?? ?? ?目录? ?? ?? ?? ?? ?? ?? ?选项? ?? ?? ?? ?
例:共享/share目录给192.168.0.x的用户
? ?? ?? ???/share? ?? ?? ?? ?? ? 192.168.0.0/24 (rw)??
2.启动portmap服务:? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?
? ? service portmap start[restart]? ?? ?? ?? ?? ?? ?? ?
3.启动NFS服务:
? ? service nfs start[restart] ? ?? ?? ?? ?? ?? ?? ?? ?
Client端
1.启动portmap服务:? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?
? ? service portmap start[restart]? ?? ?? ?? ?? ?? ?? ?
2.挂载服务器端的共享目录(假设服务器端192.168.0.1):? ?
? ? mount -t nfs 192.168.0.1:/share??/mnt/localshare??

卸载使用umount
# umount? /mnt/localshare??
关机时如果NFS Server上面还有Client联机,建议NFS Server关机之前,要先关掉portmap与nfs这两个系统服务。如果无法正确地将这两个系统服务关掉,那么先以netstat -utlp找出PID,然后使用kill杀掉进程,这样才能正常关机。

?

1. 查看系統有沒有nfs功能
cat /proc/filesystes
2. ntsysv 命令選中nfs
service nfs restart,看能否啟動,如不能正常,可以查看相應的出錯信息
tali /var/log/messages
3. 配置/etc/exports
eg: /home/mis? ? *(rw)
此文件是配置相關的文件和一些權限,上面的設置表示,所有的用戶對/home/mis都有讀寫的權限
4. 執行exportfs -a 表示將所有的更新.
5. service nfs restart
6. 執行mount命令
eg: mount 10.0.1.153:/home/mis??/mnt/mis
7. 常用的命令
showmount
repcinfo
8. 如果在開機時就加載,可在/etc/fstab中加入
ip:/home.mis? ?/mnt/mis nfs intr

?

细解:

?

1 NFS 安装

系统默认已经安装了 NFS 软件包,如果手工安装 NFS ,需要 5 RPM 包。

setup-* :  ?????????? 共享 NFS 目录在 /etc/exports 中定义

initscripts-* ??????? 包括引导过程中装载网络目录的基本脚本