NFS学习笔记

来源:互联网 发布:淘宝宝贝违规怎么处理 编辑:程序博客网 时间:2024/05/17 22:06

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 exportfssudo /etc/init.d/nfs-kernel-server restart
NFS Client

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

sudo apt-get install nfs-commonsudo /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 startStarting portmap:                                          [  OK  ]touch: cannot touch `/var/lock/subsys/portmap': Permission denied[forrest@host ~]$ sudo /etc/init.d/portmap startStarting portmap:                                          [  OK  ][forrest@host ~]$ sudo /etc/init.d/nfs restartShutting 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 startStarting NFS services:                                     [  OK  ]Starting NFS quotas: Cannot register service: RPC: Unable to receive; errno = Connection refusedrpc.rquotad: unable to register (RQUOTAPROG, RQUOTAVERS, udp).                                                           [FAILED]Starting NFS daemon:                                       [FAILED]

可以通过status检查:

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

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

[forrest@host ~]$ sudo mount 10.20.131.157:/home/admin /mnt/efs/wwwPassword: 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 statusrpc.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 startStarting portmap:                                          [  OK  ][root@host mnt]# service nfs startStarting 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 nfsnfs             0:off   1:off   2:off   3:off   4:off   5:off   6:off[root@localhost /]# chkconfig nfs on[root@localhost /]# chkconfig --list nfsnfs             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



原创粉丝点击