NFS学习笔记

 

NFS学习笔记

Ubuntu下的NFS配置

NFS Server

1. 安装相应的包:nfs-kernel-server

sudo apt-get install nfs-kernel-server

2. 将需要分享的目录export出来

vim /etc/exports
/home/forrest/test IP地址(rw,sync,no_subtree_check)

sudo exportfs
sudo /etc/init.d/nfs-kernel-server restart
NFS Client

1. 安装相应的包: nfs-common

sudo apt-get install nfs-common
sudo /etc/init.d/nfs-common start

2. mount:

mount -t nfs -o rw IP地址:/home/forrest/test /mnt/test

RedHat下的NFS配置

在RedHat下,客户端与服务器端享用一样的软件,一样的启动方式。只是服务器端需要配置一下。

这里先记录一下NFS客户端的操作:

Client
[forrest@host ~]$ /etc/init.d/portmap start
Starting portmap:                                          [  OK  ]
touch: cannot touch `/var/lock/subsys/portmap': Permission denied
[forrest@host ~]$ sudo /etc/init.d/portmap start
Starting portmap:                                          [  OK  ]
[forrest@host ~]$ sudo /etc/init.d/nfs restart
Shutting down NFS mountd:                                  [FAILED]
Shutting down NFS daemon:                                  [FAILED]
Shutting down NFS quotas:                                  [FAILED]
Shutting down NFS services:                                [FAILED]
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
[forrest@host ~]$ sudo mount 10.20.131.157:/home/admin /mnt/efs/www

必须先启动portmap才能启动nfs后台进程,否则会报如下错误:

[forrest@host ~]$ sudo /etc/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]

可以通过status检查:

[forrest@host ~]$ sudo /etc/init.d/portmap status
portmap (pid 19086) is running...

必须启动NFS后台进程才能够mount成功,否则会mount了很久,然后报如下错误:

扫描二维码关注公众号,回复: 1381691 查看本文章
[forrest@host ~]$ sudo mount 10.20.131.157:/home/admin /mnt/efs/www
Password: 
mount.nfs: Input/output error

原因:

Each time that you start the NFS service, a dynamic port number is assigned to nfsd. This assignment is made through the 'Portmapper' daemon. So, before starting NFS, you need to switch on the portmapper service.

可以用如下status检查:

[forrest@host ~]$ sudo /etc/init.d/nfs status
rpc.mountd (pid 19207) is running...
nfsd (pid 19183 19170 19153 19152 19151 19150 19149 19148) is running...
rpc.rquotad (pid 19142) is running...

除了使用/etc/init.d/nfs脚本,我们也可以使用简便的命令——service
如:

[root@host mnt]# service portmap start
Starting portmap:                                          [  OK  ]
[root@host mnt]# service nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]
[root@host mnt]# sudo mount 10.20.131.157:/home/admin /mnt/efs/www
使用chkconfig设置nfs服务在系统重启后自动运行
[root@localhost /]# chkconfig --list nfs
nfs             0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@localhost /]# chkconfig nfs on
[root@localhost /]# chkconfig --list nfs
nfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off

SUSE下的NFS安装与配置

in SUSE, you may need to use

/etc/rc.d/init.d/portmap start 
/etc/rc.d/init.d/nfs start

参考文章:系统mount.nfs: Input/output error


猜你喜欢

转载自arganzheng.iteye.com/blog/976295
nfs