首页 > 代码库 > NFS网络文件共享服务介绍及案例
NFS网络文件共享服务介绍及案例
第一个网络文件系统 — 称为 File Access Listener — 由 Digital Equipment Corporation(DEC)在 1976 年开发。Data Access Protocol(DAP)的实施,这是 DECnet 协议集的一部分。比如 TCP/IP,DEC 为其网络协议发布了协议规范,包括 DAP。
NFS 是第一个现代网络文件系统(构建于 IP 协议之上)。NFS于1984年由 Sun Microsystems 推出不久即广为业界及学术界所接受。尽管当时不同的大学及实验室已研发了多种分布式文件系统,然而 NFS 是第一个能够于学术及商业上成功应用的产品。其后升阳为了使 NFS 成为一种标准,于1989年正式公开发布其接口,使得更多厂商能够把 NFS 加入其产品之中。NFS 是一个成功的文件共享方法,但它最大的问题是它不太适合于大型的分布式系统。
标准持续地演化为 NFSv3,在 RFC 1813 中有定义。这一新的协议比以前的版本具有更好的可扩展性,支持大文件(超过 2GB),异步写入,以及将 TCP 作为传输协议,为文件系统在更广泛的网络中使用铺平了道路。在 2000 年,RFC 3010(由 RFC 3530 修订)将 NFS 带入企业设置。Sun 引入了具有较高安全性,带有状态协议的 NFSv4(NFS 之前的版本都是无状态的)。今天,NFS 是版本 4.1(由 RFC 5661 定义),它增加了对跨越分布式服务器的并行访问的支持(称为 pNFS extension)。
C6.4 X86_64 | NFS客户端 | 192.168.142.130 |
C6.4 X86_64 | NFS服务端 | 192.168.142.131 |
[root@nfsserver ~]# cat /etc/redhat-releaseCentOS release 6.4 (Final)
内核版本信息:
[root@nfsserver ~]# uname -nnfsserver[root@nfsserver ~]# uname -r2.6.32-358.el6.x86_64[root@nfsserver ~]# uname -mx86_64[root@nfsserver ~]# uname -aLinux nfsserver 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
- nfs-utils:NFS服务主程序。包括rpc.nfsd、rpc.mountd两个daemons和相关文档说明及执行命令文件等。
- rpcbind:Centos6.x下面RPC主程序(Centos5.x下名字为portmap)。
rpm -aq nfs-utils portmap rpcbind
安装NFS方法:
yum groupinstall "NFS file server" -y或yum install nfs-utils rpcbind -y
1 [root@nfsserver ~]# /etc/init.d/rpcbind start --启动rpcbind服务 2 Starting rpcbind: [ OK ] 3 [root@nfsserver ~]# /etc/init.d/rpcbind status 4 rpcbind (pid 2105) is running... 5 [root@nfsserver ~]# /etc/init.d/nfs start --启动nfs服务 6 Starting NFS services: [ OK ] 7 Starting NFS quotas: [ OK ] 8 Starting NFS mountd: [ OK ] 9 Starting NFS daemon: [ OK ] 10 Starting RPC idmapd: [ OK ]11 [root@nfsserver ~]# /etc/init.d/nfs status 12 rpc.svcgssd is stopped13 rpc.mountd (pid 2160) is running...14 nfsd (pid 2175 2174 2173 2172 2171 2170 2169 2168) is running...15 rpc.rquotad (pid 2156) is running...16 [root@nfsserver ~]# chkconfig nfs on --开启nfs服务17 [root@nfsserver ~]# chkconfig rpcbind on --开启nfs服务18 [root@nfsserver ~]# chkconfig --list nfs 19 nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off 20 [root@nfsserver ~]# chkconfig --list rpcbind 21 rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
1 [root@nfsclient ~]# /etc/init.d/rpcbind start --开启rpcbind服务2 [root@nfsclient ~]# /etc/init.d/rpcbind status 3 rpcbind (pid 2105) is running... 4 [root@nfsclient ~]# chkconfig rpcbind on --开机启动rpcbind服务5 [root@nfsclient ~]# chkconfig --list rpcbind 6 rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@nfsserver ~]# cat /etc/redhat-release CentOS release 6.4 (Final)[root@nfsserver ~]# uname -r2.6.32-358.el6.x86_64[root@nfsserver ~]# uname -mx86_64[root@nfsserver ~]# uname -aLinux nfsserver 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@nfsserver ~]# rpm -aq nfs-utils portmap rpcbind [root@nfsserver ~]# [root@nfsserver ~]# yum install nfs-utils rpcbind -y --yum groupinstall "NFS file server"[root@nfsserver ~]# rpm -aq nfs-utils portmap rpcbind rpcbind-0.2.0-11.el6.x86_64 nfs-utils-1.2.3-39.el6_5.3.x86_64
1 [root@nfsserver ~]# /etc/init.d/rpcbind start 2 Starting rpcbind: [ OK ] 3 [root@nfsserver ~]# ps -ef|grep rpc 4 rpc 2105 1 0 22:06 ? 00:00:00 rpcbind 5 root 2111 1885 0 22:07 pts/0 00:00:00 grep rpc 6 [root@nfsserver ~]# 7 [root@nfsserver ~]# /etc/init.d/rpcbind status 8 rpcbind (pid 2105) is running... 9 [root@nfsserver data]# rpcinfo -p localhost 10 program vers proto port service 11 100000 4 tcp 111 portmapper 12 100000 3 tcp 111 portmapper 13 100000 2 tcp 111 portmapper 14 100000 4 udp 111 portmapper 15 100000 3 udp 111 portmapper 16 100000 2 udp 111 portmapper17 18 [root@nfsserver ~]# /etc/init.d/nfs start 19 Starting NFS services: [ OK ] 20 Starting NFS quotas: [ OK ] 21 Starting NFS mountd: [ OK ] 22 Starting NFS daemon: [ OK ] 23 Starting RPC idmapd: [ OK ]24 [root@nfsserver data]# rpcinfo -p localhost 25 program vers proto port service 26 100000 4 tcp 111 portmapper 27 100000 3 tcp 111 portmapper 28 100000 2 tcp 111 portmapper 29 100000 4 udp 111 portmapper 30 100000 3 udp 111 portmapper 31 100000 2 udp 111 portmapper 32 100011 1 udp 875 rquotad 33 100011 2 udp 875 rquotad 34 100011 1 tcp 875 rquotad 35 100011 2 tcp 875 rquotad 36 100005 1 udp 44185 mountd 37 100005 1 tcp 35754 mountd 38 100005 2 udp 49907 mountd 39 100005 2 tcp 59112 mountd 40 100005 3 udp 50792 mountd 41 100005 3 tcp 60474 mountd 42 100003 2 tcp 2049 nfs 43 100003 3 tcp 2049 nfs 44 100003 4 tcp 2049 nfs 45 100227 2 tcp 2049 nfs_acl 46 100227 3 tcp 2049 nfs_acl 47 100003 2 udp 2049 nfs 48 100003 3 udp 2049 nfs 49 100003 4 udp 2049 nfs 50 100227 2 udp 2049 nfs_acl 51 100227 3 udp 2049 nfs_acl 52 100021 1 udp 50898 nlockmgr 53 100021 3 udp 50898 nlockmgr 54 100021 4 udp 50898 nlockmgr 55 100021 1 tcp 39373 nlockmgr 56 100021 3 tcp 39373 nlockmgr 57 100021 4 tcp 39373 nlockmgr
1 [root@nfsserver ~]# chkconfig nfs on --开启nfs服务2 [root@nfsserver ~]# chkconfig rpcbind on --开启nfs服务3 [root@nfsserver ~]# chkconfig --list nfs 4 nfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off 5 [root@nfsserver ~]# chkconfig --list rpcbind 6 rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
1 [root@nfsserver ~]# mkdir /data2 [root@nfsserver ~]# chowm -r nfsclient.nfsclient /data3 [root@nfsserver ~]# cat >>/etc/exports<<EOF4 #shared data for bbs by arvin at 201410105 /data 192.168.142.0/24(rw,sync)6 EOF7 [root@nfsserver ~]# cat /etc/exports 8 #shared data for bbs by arvin at 20141010 9 /data 192.168.142.0/24(rw,sync)
[root@nfsserver ~]# /etc/init.d/nfs reload[root@nfsserver ~]# showmount -e localhost Export list for localhost: /data 192.168.142.0/24
1 [root@nfsclient ~]# cat /etc/redhat-release 2 CentOS release 6.4 (Final)3 [root@nfsclient ~]# uname -r4 2.6.32-358.el6.x86_645 [root@nfsclient ~]# uname -m6 x86_64[root@nfsclient ~]# uname -a7 Linux nfsserver 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
1 [root@nfsclient ~]# rpm -aq nfs-utils portmap rpcbind 2 [root@nfsclient ~]# 3 [root@nfsclient ~]# yum install nfs-utils rpcbind -y --yum groupinstall "NFS file server"4 [root@nfsclient ~]# rpm -aq nfs-utils portmap rpcbind 5 rpcbind-0.2.0-11.el6.x86_64 6 nfs-utils-1.2.3-39.el6_5.3.x86_64
1 [root@nfsclient ~]# /etc/init.d/rpcbind start 2 Starting rpcbind: [ OK ]3 [root@nfsclient ~]# /etc/init.d/rpcbind status 4 rpcbind (pid 2105) is running...
1 [root@nfsclient ~]# chkconfig rpcbind on 2 [root@nfsclient ~]# chkconfig --list rpcbind 3 rpcbind 0:off 1:off 2:on 3:on 4:on 5:on 6:off
1 [root@nfsclient ~]# showmount -e 192.168.142.131 2 Export list for 192.168.142.131: 3 /data 192.168.142.0/24
1 [root@nfsclient ~]# mount -t nfs 192.168.142.131:/data /mnt 2 [root@nfsclient ~]# df -h 3 Filesystem Size Used Avail Use% Mounted on 4 /dev/sda3 5.8G 1.5G 4.0G 28% / 5 tmpfs 373M 0 373M 0% /dev/shm 6 /dev/sda1 194M 28M 156M 16% /boot 7 192.168.142.131:/data 5.8G 1.6G 4.0G 28% /mnt
NFS网络文件共享服务介绍及案例