分类: LINUX
2007-06-16 21:18:21
环境:
client: 主机rac2,ip 192.168.0.6
server: 主机rac1,ip 192.168.0.5
[root@rac2 init.d]# ./nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: Cannot register service: RPC: Unable to receive; errno = Connection refused
rpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp).
[FAILED]
Starting NFS daemon:
[FAILED]
Starting NFS mountd: Cannot register service: RPC: Unable to receive; errno = Connection refused
mountd: unable to register (mountd, 1, udp).
[FAILED]
Starting RPC idmapd: [ OK ]
[root@rac2 init.d]# ps -ef|grep nfs
证明nfs没有启动。
[root@rac2 init.d]# /etc/init.d/portmap start
Starting portmap: [ OK ]
[root@rac2 init.d]# ps -ef|grep portmap
rpc 3198 1 0 02:39 ? 00:00:00 portmap
root 3202 2998 0 02:
[root@rac2 init.d]# /etc/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
启动正常,检查一下nfs进程是否在。
[root@rac2 init.d]# ps -ef|grep nfs
root 3222 1 0 02:39 ? 00:00:00 [nfsd]
root 3223 1 0 02:39 ? 00:00:00 [nfsd]
root 3224 1 0 02:39 ? 00:00:00 [nfsd]
root 3225 1 0 02:39 ? 00:00:00 [nfsd]
root 3226 1 0 02:39 ? 00:00:00 [nfsd]
root 3227 1 0 02:39 ? 00:00:00 [nfsd]
root 3228 1 0 02:39 ? 00:00:00 [nfsd]
root 3231 1 0 02:39 ? 00:00:00 [nfsd]
root 3260 2998 0 02:
rac1上有一个/disk0分区,看从rac2能否直接连接上rac1
[root@rac1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda5
/dev/sda1
none
/dev/sda2
/dev/sda3
/dev/sda7
/dev/sdb5
[root@rac2 init.d]# mount 192.168.0.5:/disk0 /wyl (/wyl目录必须已存在)
mount: mount to NFS server '192.168.0.5' failed: System Error: Connection refused.
报错信息指的是server端(Rac1)的nfs进程没起来!
在服务端启动nfs进程(实际上是要启动portmap和nfs进程)
[root@rac1 ~]# /etc/init.d/portmap start
Starting portmap: [ OK ]
[root@rac1 ~]# /etc/init.d/nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
Starting RPC idmapd: [ OK ]
再次在客户端连接
[root@rac2 init.d]# mount 192.168.0.5:/disk0 /wyl
mount: 192.168.0.5:/disk0 failed, reason given by server: Permission denied
此报错信息是因为没在server端授权client端来连接,其实道理很简单,必须在服务端来决定哪些IP可以来mount,我的哪个分区可以被mount.
在服务器端编辑/etc/wxports文件
[root@rac1 ~]# vi /etc/exports
/disk0 192.168.0.6(rw)
第一列定义的是服务端哪个分区可以被mount,第二列定义的是哪些客户端IP可以来mount.
注意修改/etc/export后,要重起nfs进程.
vi /etc/exports
/disk0 192.168.0.6(rw)
~
~
~
"/etc/exports"
[root@rac1 ~]# more /etc/exports
/disk0 192.168.0.6(rw)
[root@rac1 ~]# /etc/init.d/nfs restart
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
此时在客户端连接就可以了.
[root@rac2 init.d]# mount 192.168.0.5:/disk0 /wyl
无报错信息.
[root@rac2 init.d]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda5
/dev/sda1
none
/dev/sda2
/dev/sda3
/dev/sda7
192.168.0.5:/disk0
为使下次重起时系统能自动启动portmap和nfs进程.在客户端和服务端都要执行.
#chkconfig –level 235 portmap on
#chkconfig –level 235 nfs on
为了客户端下次重起时能自动连接server端的nfs分区.修改客户端/etc/fstab文件.添加
/wyl 192.168.0.5:/disk0
总结一下配置过程:
1) 在客户端和服务端均启动portmap和nfs,最好是修改为自动启动的进程.
2) 修改服务端/etc/exports文件,定义允许连接的客户端
3) 客户端连接
mount serverip:目录 客户端目录
4)编辑客户端/etc/fstab以便客户端每次重起后也能连接server端.
更多信息,请参考http://blog.chinaunix.net/u/26040/showart_285389.html