ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Linux下的NFS配置

Linux下的NFS配置

原创 Linux操作系统 作者:dzq0371 时间:2013-07-16 13:45:58 0 删除 编辑

环境:

client: 主机rac2,ip 192.168.0.6

server: 主机rac1,ip 192.168.0.5

 

 1) 在客户端启动portmapnfs服务,单起nfs进程是无法启动的。

[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:39 pts/0    00:00:00 grep portmap

[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:45 pts/0    00:00:00 grep nfs

 

rac1上有一个/disk0分区,看从rac2能否直接连接上rac1

[root@rac1 ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda5             2.9G  2.3G  503M  83% /

/dev/sda1              99M   12M   83M  12% /boot

none                  125M     0  125M   0% /dev/shm

/dev/sda2             7.7G  2.3G  5.1G  32% /home

/dev/sda3             3.9G  2.3G  1.4G  62% /usr

/dev/sda7             2.8G  1.1G  1.6G  40% /var

/dev/sdb5            1004M  1.3M  952M   1% /disk0

 

[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进程(实际上是要启动portmapnfs进程)

[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" 1L, 24C written

[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             2.9G  277M  2.5G  10% /

/dev/sda1              99M   12M   83M  12% /boot

none                  125M     0  125M   0% /dev/shm

/dev/sda2             7.7G   62M  7.3G   1% /home

/dev/sda3             3.9G  2.5G  1.2G  68% /usr

/dev/sda7             2.8G  117M  2.5G   5% /var

192.168.0.5:/disk0   1004M  1.3M  952M   1% /wyl

 

为使下次重起时系统能自动启动portmapnfs进程.在客户端和服务端都要执行.

#chkconfig –level 235 portmap on

#chkconfig –level 235 nfs on

为了客户端下次重起时能自动连接server端的nfs分区.修改客户端/etc/fstab文件.添加

/wyl              192.168.0.5:/disk0

 

总结一下配置过程:

1)      在客户端和服务端均启动portmapnfs,最好是修改为自动启动的进程.

2)      修改服务端/etc/exports文件,定义允许连接的客户端

3)      客户端连接

mount  serverip:目录  客户端目录

4)编辑客户端/etc/fstab以便客户端每次重起后也能连接server.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23009281/viewspace-766380/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-07-14

  • 博文量
    52
  • 访问量
    181651