[root@zyl /]# cat /etc/redhat-release       #########查看系统

CentOS release 6.5 (Final)

[root@zyl /]# uname -m                      #########查看系统是32位还是64位。这里是64位

x86_64

[root@zyl /]# uname -r                      #########查看内核版本

2.6.32-431.el6.x86_64

[root@zyl /]# rpm -aq nfs-utils portmap rpcbind    #########检查系统是否安装nfs portmap rpcbind

[root@zyl /]# yum grouplist                 #########查看可能批量安装哪些列表。扩展:yum grouplist 列出所有可安装的软件包

Loaded plugins: fastestmirror, security

Setting up Group Process

Loading mirror speeds from cached hostfile

 * base: mirrors.163.com

 * extras: mirrors.163.com

 * updates: mirrors.163.com

base                                | 3.7 kB     00:05   

http://mirrors.163.com/centos/6.8/extras/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.163.com/centos/6.8/extras/x86_64/repodata/repomd.xml: (28, 'Operation too slow. Less than 1 bytes/sec transfered the last 30 seconds')

Trying other mirror.

extras                              | 3.4 kB     00:00     

extras/primary_db                   |  37 kB     00:00     

updates                             | 3.4 kB     00:00     

updates/primary_db                  | 748 kB     00:00     

base/group_gz                       | 226 kB     00:00     

Installed Groups:

   Base

   Compatibility libraries

   Debugging Tools

   Development tools

   Dial-up Networking Support

   E-mail server

   Fonts

   Graphical Administration Tools

   Hardware monitoring utilities

   Legacy UNIX compatibility

   Networking Tools

   Performance Tools

   Perl Support

   Scientific support

   Security Tools

   Web Server

Installed Language Groups:

   Arabic Support [ar]

   Armenian Support [hy]

   Georgian Support [ka]

   Hebrew Support [he]

   Inuktitut Support [iu]

   Lao Support [lo]

   Tajik Support [tg]

Available Groups:

   Additional Development

   Backup Client

   Backup Server

   CIFS file server

   Client management tools

   Console internet tools

   Desktop

   Desktop Debugging and Performance Tools

   Desktop Platform

   Desktop Platform Development

   Directory Client

   Directory Server

   Eclipse

   Emacs

   FCoE Storage Client

   FTP server

   General Purpose Desktop

   Graphics Creation Tools

   Guest Agents

   High Availability

   High Availability Management

   Identity Management Server

   Infiniband Support

   Input Methods

   Internet Applications

   Internet Browser

   Java Platform

   KDE Desktop

   Large Systems Performance

   Legacy X Window System compatibility

   Load Balancer

   Mainframe Access

   Messaging Client Support

   MySQL Database client

   MySQL Database server

   NFS file server

   Network Infrastructure Server

   Network Storage Server

   Network file system client

   Office Suite and Productivity

   PHP Support

   PostgreSQL Database client

   PostgreSQL Database server

   Print Server

   Printing client

   Remote Desktop Clients

   Resilient Storage

   Ruby Support

   SNMP Support

   Scalable Filesystems

   Server Platform

   Server Platform Development

   Smart card support

   Storage Availability Tools

   System Management

   System administration tools

   TeX support

   Technical Writing

   TurboGears application framework

   Virtualization

   Virtualization Client

   Virtualization Platform

   Virtualization Tools

   Web Servlet Engine

   Web-Based Enterprise Management

   X Window System

   iSCSI Storage Client

Available Language Groups:

   Afrikaans Support [af]

   Albanian Support [sq]

   Amazigh Support [ber]

   Assamese Support [as]

   Azerbaijani Support [az]

   Basque Support [eu]

   Belarusian Support [be]

   Bengali Support [bn]

   Bhutanese Support [dz]

   Brazilian Portuguese Support [pt_BR]

   Breton Support [br]

   Bulgarian Support [bg]

   Catalan Support [ca]

   Chhattisgarhi Support [hne]

   Chichewa Support [ny]

   Chinese Support [zh]

   Coptic Support [cop]

   Croatian Support [hr]

   Czech Support [cs]

   Danish Support [da]

   Dutch Support [nl]

   English (UK) Support [en_GB]

   Esperanto Support [eo]

   Estonian Support [et]

   Ethiopic Support [am]

   Faroese Support [fo]

   Fijian Support [fj]

   Filipino Support [fil]

   Finnish Support [fi]

   French Support [fr]

   Frisian Support [fy]

   Friulian Support [fur]

   Gaelic Support [gd]

   Galician Support [gl]

   German Support [de]

   Greek Support [el]

   Gujarati Support [gu]

   Hiligaynon Support [hil]

   Hindi Support [hi]

   Hungarian Support [hu]

   Icelandic Support [is]

   Indonesian Support [id]

   Interlingua Support [ia]

   Irish Support [ga]

   Italian Support [it]

   Japanese Support [ja]

   Kannada Support [kn]

   Kashmiri Support [ks]

   Kashubian Support [csb]

   Kazakh Support [kk]

   Khmer Support [km]

   Kinyarwanda Support [rw]

   Konkani Support [kok]

   Korean Support [ko]

   Kurdish Support [ku]

   Latin Support [la]

   Latvian Support [lv]

   Lithuanian Support [lt]

   Low Saxon Support [nds]

   Luxembourgish Support [lb]

   Macedonian Support [mk]

   Maithili Support [mai]

   Malagasy Support [mg]

   Malay Support [ms]

   Malayalam Support [ml]

   Maltese Support [mt]

   Manx Support [gv]

   Maori Support [mi]

   Marathi Support [mr]

   Mongolian Support [mn]

   Myanmar (Burmese) Support [my]

   Nepali Support [ne]

   Northern Sotho Support [nso]

   Norwegian Support [nb]

   Occitan Support [oc]

   Oriya Support [or]

   Persian Support [fa]

   Polish Support [pl]

   Portuguese Support [pt]

   Punjabi Support [pa]

   Romanian Support [ro]

   Russian Support [ru]

   Sanskrit Support [sa]

   Sardinian Support [sc]

   Serbian Support [sr]

   Sindhi Support [sd]

   Sinhala Support [si]

   Slovak Support [sk]

   Slovenian Support [sl]

   Somali Support [so]

   Southern Ndebele Support [nr]

   Southern Sotho Support [st]

   Spanish Support [es]

   Swahili Support [sw]

   Swati Support [ss]

   Swedish Support [sv]

   Tagalog Support [tl]

   Tamil Support [ta]

   Telugu Support [te]

   Tetum Support [tet]

   Thai Support [th]

   Tibetan Support [bo]

   Tsonga Support [ts]

   Tswana Support [tn]

   Turkish Support [tr]

   Turkmen Support [tk]

   Ukrainian Support [uk]

   Upper Sorbian Support [hsb]

   Urdu Support [ur]

   Uzbek Support [uz]

   Venda Support [ve]

   Vietnamese Support [vi]

   Walloon Support [wa]

   Welsh Support [cy]

   Xhosa Support [xh]

   Zulu Support [zu]

Done

[root@zyl /]# yum groupinstall "NFS file server" -y 

      #########安装NFS。

Loaded plugins: fastestmirror, security

Loading mirror speeds from cached hostfile

 * base: mirrors.163.com

 * extras: mirrors.163.com

 * updates: mirrors.163.com

Setting up Group Process

Checking for new repos for mirrors

Resolving Dependencies

--> Running transaction check

---> Package nfs-utils.x86_64 1:1.2.3-70.el6 will be installed

--> Processing Dependency: nfs-utils-lib >= 1.1.0-3 for package: 1:nfs-utils-1.2.3-70.el6.x86_64

--> Processing Dependency: libtirpc >= 0.2.1-11 for package: 1:nfs-utils-1.2.3-70.el6.x86_64

--> Processing Dependency: keyutils >= 1.4-4 for package: 1:nfs-utils-1.2.3-70.el6.x86_64

--> Processing Dependency: rpcbind for package: 1:nfs-utils-1.2.3-70.el6.x86_64

--> Processing Dependency: python-argparse for package: 1:nfs-utils-1.2.3-70.el6.x86_64

--> Processing Dependency: libgssglue.so.1(libgssapi_CITI_2)(64bit) for package: 1:nfs-utils-1.2.3-70.el6.x86_64

--> Processing Dependency: libgssglue for package: 1:nfs-utils-1.2.3-70.el6.x86_64

--> Processing Dependency: libevent for package: 1:nfs-utils-1.2.3-70.el6.x86_64

--> Processing Dependency: libtirpc.so.1()(64bit) for package: 1:nfs-utils-1.2.3-70.el6.x86_64

--> Processing Dependency: libnfsidmap.so.0()(64bit) for package: 1:nfs-utils-1.2.3-70.el6.x86_64

--> Processing Dependency: libgssglue.so.1()(64bit) for package: 1:nfs-utils-1.2.3-70.el6.x86_64

--> Processing Dependency: libevent-1.4.so.2()(64bit) for package: 1:nfs-utils-1.2.3-70.el6.x86_64

---> Package nfs4-acl-tools.x86_64 0:0.3.3-8.el6 will be installed

--> Running transaction check

---> Package keyutils.x86_64 0:1.4-5.el6 will be installed

--> Processing Dependency: keyutils-libs = 1.4-5.el6 for package: keyutils-1.4-5.el6.x86_64

---> Package libevent.x86_64 0:1.4.13-4.el6 will be installed

---> Package libgssglue.x86_64 0:0.1-11.el6 will be installed

---> Package libtirpc.x86_64 0:0.2.1-11.el6 will be installed

---> Package nfs-utils-lib.x86_64 0:1.1.5-11.el6 will be installed

---> Package python-argparse.noarch 0:1.2.1-2.1.el6 will be installed

---> Package rpcbind.x86_64 0:0.2.0-12.el6 will be installed

--> Running transaction check

---> Package keyutils-libs.x86_64 0:1.4-4.el6 will be updated

---> Package keyutils-libs.x86_64 0:1.4-5.el6 will be an update

--> Finished Dependency Resolution

Dependencies Resolved

===========================================================

 Package           Arch     Version           Repository

                                                     Size

===========================================================

Installing:

 nfs-utils         x86_64   1:1.2.3-70.el6    base   334 k

 nfs4-acl-tools    x86_64   0.3.3-8.el6       base    43 k

Installing for dependencies:

 keyutils          x86_64   1.4-5.el6         base    39 k

 libevent          x86_64   1.4.13-4.el6      base    66 k

 libgssglue        x86_64   0.1-11.el6        base    23 k

 libtirpc          x86_64   0.2.1-11.el6      base    82 k

 nfs-utils-lib     x86_64   1.1.5-11.el6      base    68 k

 python-argparse   noarch   1.2.1-2.1.el6     base    48 k

 rpcbind           x86_64   0.2.0-12.el6      base    51 k

Updating for dependencies:

 keyutils-libs     x86_64   1.4-5.el6         base    20 k


Transaction Summary

===========================================================

Install       9 Package(s)

Upgrade       1 Package(s)


Total download size: 774 k

Downloading Packages:

(1/10): keyutils-1.4-5.el6.x86_64.r |  39 kB     00:00     

(2/10): keyutils-libs-1.4-5.el6.x86 |  20 kB     00:00     

(3/10): libevent-1.4.13-4.el6.x86_6 |  66 kB     00:00     

(4/10): libgssglue-0.1-11.el6.x86_6 |  23 kB     00:00     

(5/10): libtirpc-0.2.1-11.el6.x86_6 |  82 kB     00:00     

(6/10): nfs-utils-1.2.3-70.el6.x86_ | 334 kB     00:00     

(7/10): nfs-utils-lib-1.1.5-11.el6. |  68 kB     00:00     

(8/10): nfs4-acl-tools-0.3.3-8.el6. |  43 kB     00:00     

(9/10): python-argparse-1.2.1-2.1.e |  48 kB     00:00     

(10/10): rpcbind-0.2.0-12.el6.x86_6 |  51 kB     00:00     

-----------------------------------------------------------

Total                      184 kB/s | 774 kB     00:04     

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : libgssglue-0.1-11.el6.x86_64           1/11 

  Installing : libtirpc-0.2.1-11.el6.x86_64           2/11 

  Updating   : keyutils-libs-1.4-5.el6.x86_64         3/11 

  Installing : keyutils-1.4-5.el6.x86_64              4/11 

  Installing : rpcbind-0.2.0-12.el6.x86_64            5/11 

  Installing : python-argparse-1.2.1-2.1.el6.noarc    6/11 

  Installing : libevent-1.4.13-4.el6.x86_64           7/11 

  Installing : nfs-utils-lib-1.1.5-11.el6.x86_64      8/11 

  Installing : 1:nfs-utils-1.2.3-70.el6.x86_64        9/11 

  Installing : nfs4-acl-tools-0.3.3-8.el6.x86_64     10/11 

  Cleanup    : keyutils-libs-1.4-4.el6.x86_64        11/11 

  Verifying  : keyutils-libs-1.4-5.el6.x86_64         1/11 

  Verifying  : libevent-1.4.13-4.el6.x86_64           2/11 

  Verifying  : 1:nfs-utils-1.2.3-70.el6.x86_64        3/11 

  Verifying  : keyutils-1.4-5.el6.x86_64              4/11 

  Verifying  : rpcbind-0.2.0-12.el6.x86_64            5/11 

  Verifying  : nfs-utils-lib-1.1.5-11.el6.x86_64      6/11 

  Verifying  : libgssglue-0.1-11.el6.x86_64           7/11 

  Verifying  : nfs4-acl-tools-0.3.3-8.el6.x86_64      8/11 

  Verifying  : libtirpc-0.2.1-11.el6.x86_64           9/11 

  Verifying  : python-argparse-1.2.1-2.1.el6.noarc   10/11 

  Verifying  : keyutils-libs-1.4-4.el6.x86_64        11/11 


Installed:

  nfs-utils.x86_64 1:1.2.3-70.el6                          

  nfs4-acl-tools.x86_64 0:0.3.3-8.el6                      


Dependency Installed:

  keyutils.x86_64 0:1.4-5.el6                              

  libevent.x86_64 0:1.4.13-4.el6                           

  libgssglue.x86_64 0:0.1-11.el6                           

  libtirpc.x86_64 0:0.2.1-11.el6                           

  nfs-utils-lib.x86_64 0:1.1.5-11.el6                      

  python-argparse.noarch 0:1.2.1-2.1.el6                   

  rpcbind.x86_64 0:0.2.0-12.el6                            


Dependency Updated:

  keyutils-libs.x86_64 0:1.4-5.el6                         


Complete!

[root@zyl /]# rpm -aq nfs-utils portmap rpcbind             

rpcbind-0.2.0-12.el6.x86_64

nfs-utils-1.2.3-70.el6.x86_64

[root@zyl /]# /etc/init.d/rpcbind start

Starting rpcbind:                                         [  OK  ]

[root@zyl /]# ps -ef|grep rpc

rpc       2802     1  0 08:35 ?        00:00:00 rpcbind

root      2806  1490  0 08:36 pts/0    00:00:00 grep --color=auto rpc

[root@zyl /]# 

[root@zyl /]# 

[root@zyl /]# /etc/init.d/rpcbind  status

rpcbind (pid  2802) is running...

[root@zyl /]# rpcinfo -p localhost(本机的地址)     ####查看中介有没有房源(形象的比方) ,就是查看本机有没有房源

   program vers proto   port  service

    100000    4   tcp    111  portmapper

    100000    3   tcp    111  portmapper

    100000    2   tcp    111  portmapper

    100000    4   udp    111  portmapper

    100000    3   udp    111  portmapper

    100000    2   udp    111  portmapper    ####综上都没房源。对外用111端口     

[root@zyl /]# /etc/init.d/rpcbind  stop

Stopping rpcbind:                                         [  OK  ]

[root@zyl /]# rpcinfo -p localhost     

rpcinfo: can't contact portmapper: RPC: Remote system error - Connection refused               #######rpc服务没有开。主机这个报错==>>这是自己测试

[root@zyl /]# /etc/init.d/rpcbind  start

Starting rpcbind:                                          [  OK  ]

[root@zyl /]# rpcinfo -p localhost

   program vers proto   port  service

    100000    4   tcp    111  portmapper

    100000    3   tcp    111  portmapper

    100000    2   tcp    111  portmapper

    100000    4   udp    111  portmapper

    100000    3   udp    111  portmapper

    100000    2   udp    111  portmapper      

[root@zyl /]# /etc/init.d/nfs start           启动nfs服务

Starting NFS services:                                     [  OK  ]

Starting NFS quotas:                                       [  OK  ]

Starting NFS mountd:                                       [  OK  ]

Starting NFS daemon:                                       [  OK  ]

Starting RPC idmapd:                                       [  OK  ]

[root@zyl /]# rpcinfo -p localhost       #####启动rpc服务之后出现端口   

   program vers proto   port  service

    100000    4   tcp    111  portmapper

    100000    3   tcp    111  portmapper

    100000    2   tcp    111  portmapper

    100000    4   udp    111  portmapper

    100000    3   udp    111  portmapper

    100000    2   udp    111  portmapper

    100011    1   udp    875  rquotad

    100011    2   udp    875  rquotad

    100011    1   tcp    875  rquotad

    100011    2   tcp    875  rquotad

    100005    1   udp  48811  mountd

    100005    1   tcp  46451  mountd

    100005    2   udp  50017  mountd

    100005    2   tcp  59534  mountd

    100005    3   udp  52072  mountd

    100005    3   tcp  43258  mountd

    100003    2   tcp   2049  nfs

    100003    3   tcp   2049  nfs

    100003    4   tcp   2049  nfs

    100227    2   tcp   2049  nfs_acl

    100227    3   tcp   2049  nfs_acl

    100003    2   udp   2049  nfs

    100003    3   udp   2049  nfs

    100003    4   udp   2049  nfs

    100227    2   udp   2049  nfs_acl

    100227    3   udp   2049  nfs_acl

    100021    1   udp  48251  nlockmgr

    100021    3   udp  48251  nlockmgr

    100021    4   udp  48251  nlockmgr

    100021    1   tcp  34676  nlockmgr

    100021    3   tcp  34676  nlockmgr

    100021    4   tcp  34676  nlockmgr

[root@zyl /]# chkconfig nfs on         ###自启动

[root@zyl /]# chkconfig rpcbind on

[root@zyl /]# chkconfig --list nfs      ###检查

nfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off

[root@zyl /]# chkconfig --list rpcbind  ###检查

rpcbind         0:off   1:off   2:on    3:on    4:on    5:on    6:off

[root@zyl /]# more /etc/init.d/nfs         ###看脚本,主要看rpc和nfs服务启停的时间

#!/bin/sh

#

# nfs           This shell script takes care of starting and stopping

#               the NFS services.

#


# description: NFS is a popular protocol for file sharing across networks.

#              This service provides NFS server functionality, which is \

#              configured via the /etc/exports file.

# probe: true

# config: /etc/sysconfig/nfs


### BEGIN INIT INFO

# Provides: nfs

# Required-Start: $local_fs $network $syslog $rpcbind

[root@zyl /]# more /etc/init.d/rcpbind

/etc/init.d/rcpbind: No such file or directory

[root@zyl /]# more /etc/init.d/rpcbind 

#! /bin/sh

#

# rpcbind       Start/Stop RPCbind

#

# chkconfig: 2345 13 87

# description: The rpcbind utility is a server that converts RPC program \

#              numbers into universal addresses. It must be running on the

 \

#              host to be able to make RPC calls on a server on that machi

ne.

#

# processname: rpcbind

# probe: true

# config: /etc/sysconfig/rpcbind



# This is an interactive program, we need the current locale

[ -f /etc/profile.d/lang.sh ] && . /etc/profile.d/lang.sh

# We can't Japanese on normal console at boot time, so force LANG=C.

if [ "$LANG" = "ja" -o "$LANG" = "ja_JP.eucJP" ]; then

[root@zyl /]# ll /etc/exports      ### nfs 的配置文件


-rw-r--r--. 1 root root 0 Jan 12  2010 /etc/exports

[root@zyl /]# cat  /etc/exports    ### 配置文件默认为空  

[root@zyl /]# mkdir /data   ###创建共享目录

mkdir: cannot create directory `/data': File exists    ###已经存在

[root@zyl /]# ll /data/

total 16

-rw-r--r--. 1 root root 111 Jun 20 06:54 html_2016-06-20.tar.gz

-rw-r--r--. 1 root root 156 Jun 24 07:41 www_2016-06-24.tar.ga

-rw-r--r--. 1 root root 156 Jun 25 02:00 www_2016-06-25.tar.ga

-rw-r--r--. 1 root root 111 Jun 24 07:20 www_bak_5.tar.ga


[root@zyl /]# vim /etc/exports 

#shared data for bbs by zhang at 2016627   == >>不要忘记写注释

/data 10.0.0.0/24(rw,sync)             ###r读 w写 ro只读

~                                             sync是写到磁盘,如果是async那就是写到缓存               

                                                                                                                               

~                                                                    

"/etc/exports" 2L, 68C written                     

[root@zyl /]# cat /etc/exports 

#shared data for bbs by zhang at 2016627

/data 10.0.0.0/24(rw,sync)

[root@zyl /]# /etc/init.d/nfs reload(别用restart重启,要用此:平滑重启)    #####重启服务   

[root@zyl /]# vim/etc/init.d/nfs   ==>>nfs的脚本,进去/reload.


#!/bin/sh

#

# nfs           This shell script takes care of starting and stopping

#               the NFS services.

#

# chkconfig: - 30 60

# description: NFS is a popular protocol for file sharing across netw

orks.

#              This service provides NFS server functionality, which

is \

#              configured via the /etc/exports file.

# probe: true

# config: /etc/sysconfig/nfs


### BEGIN INIT INFO

# Provides: nfs

# Required-Start: $local_fs $network $syslog $rpcbind

# Required-Stop: $local_fs $network $syslog $rpcbind

:/res

        rval=$?

        [ $RETVAL -eq 0 ] && RETVAL=$rval

        if [ -n "$RQUOTAD" -a "$RQUOTAD" != "no" ]; then

                status rpc.rquotad

                rval=$?

                [ $RETVAL -eq 0 ] && RETVAL=$rval

        fi

        ;;

  restart)

        $0 stop

        $0 start

        ;;

  reload | force-reload)

        /usr/sbin/exportfs -r

        [ -f /var/lock/subsys/nfs ] && touch /var/lock/subsys/nfs

        ;;

  probe)

        if [ ! -f /var/lock/subsys/nfs ] ; then

[root@zyl /]# 

[root@zyl /]# 

[root@zyl /]# /etc/init.d/nfs reload == exportfs -r    ###可以认为等价

[root@zyl /]# showmount -e localhost               ########先在本机检查,然后客户端检查。-e:显示NFS服务器的输出清单

Export list for localhost:

/data 10.0.0.0/24

[root@zyl /]# 

=======================================================

接下来就是分别server和client上测试:

[root@zylserver /]# cd /data

[root@zylserver data]# ll

total 16

-rw-r--r--. 1 nfsnobody root 111 Jun 20 06:54 html_2016-06-20.tar.gz

-rw-r--r--. 1 nfsnobody root 156 Jun 24 07:41 www_2016-06-24.tar.ga

-rw-r--r--. 1 nfsnobody root 156 Jun 25 02:00 www_2016-06-25.tar.ga

-rw-r--r--. 1 nfsnobody root 111 Jun 24 07:20 www_bak_5.tar.ga

[root@zylserver data]# rm html_2016-06-20.tar.gz 

rm: remove regular file `html_2016-06-20.tar.gz'? y

[root@zylserver data]# ll

total 12

-rw-r--r--. 1 nfsnobody nfsnobody   0 Jun 26 01:00 ddd

-rw-r--r--. 1 nfsnobody root      156 Jun 24 07:41 www_2016-06-24.tar.ga

-rw-r--r--. 1 nfsnobody root      156 Jun 25 02:00 www_2016-06-25.tar.ga

-rw-r--r--. 1 nfsnobody root      111 Jun 24 07:20 www_bak_5.tar.ga

[root@zylserver data]# 

========================================================

遇到的问题总结:

1.

[root@zyl /]# showmount -e localhost

clnt_create: RPC: Program not registered

解决方法:

由于网络原因nfs服务被中断,重新开启nfs服务然后在客户端重新mount 

service nfs restart 或 /etc/rc.d/init.d/nfs restart


2.有关NFS客服端开机自启动挂载:a b:

a:

[root@nfsserver data]# which mount

/bin/mount


vi /etc/rc.local

/bin/mount -t nfs 192.168.21.128:/data /nfsdir/     ***用全路径吧。

***这种挂载方式不会影响系统开机

b:

vi  /etc/fstab

你现在可以动手测试。反正我的测试结果是挂载不了,且总结为:不要在 /etc/fstab中配置网络文件系统,本地的文件系统是可以的:fstab启动优先于网络。


3.查看挂载信息:

 a.grep data(挂载目录)/proc/mounts    

 b.mount /proc/mounts 

 

4.

[root@zylclient mnt]# mount -t nfs 192.168.21.128:/date /mnt

mount.nfs: access denied by server while mounting 192.168.21.128:/date

仔细检查server端口:/etc/exports


5.

[root@zylclient nfsdir]# showmount -e 192.168.21.128         

clnt_create: RPC: Port mapper failure - Unable to receive: errno 111 (Connection refused)

解决:

[root@zyl data]# /etc/init.d/nfs status

rpc.svcgssd is stopped

rpc.mountd (pid 3026) is running...

nfsd (pid 3041 3040 3039 3038 3037 3036 3035 3034) is running...

rpc.rquotad (pid 3022) is running...

[root@zyl data]# /etc/init.d/rpcbind status

rpcbind (pid  3123) is running...

[root@zyl data]# rpc.mountd          ####关键于此

[root@zyl data]# showmount -e 


Export list for localhost:

/data 192.168.21.131/24


[root@zylclient nfsdir]# showmount -e 192.168.21.128

Export list for 192.168.21.128:

/data 192.168.21.131/24

 

6.防火墙开启导致

[root@zylclient nfsdir]# showmount -e 192.168.21.128

clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host) 


解决:

[root@zyl data]# /etc/init.d/iptables stop

iptables: Setting chains to policy ACCEPT: filter          [  OK  ]

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Unloading modules:     


[root@zylclient nfsdir]# showmount -e 192.168.21.128

Export list for 192.168.21.128:

/data 192.168.21.131/24        


7.[root@zylclient mnt]# mount -t nfs -o nosuid,rw  192.168.21.128:/data /mnt

mount.nfs: Stale file handle

解决:1.是由于server端共享的目录在共享期间做出了移动目录,又创建了同名字的目录导致的,即在共享期间对该共享目录进行了移除操作,只需要在客户端重新挂下就OK 。2.mount -a:把所有的分区挂载信息重新mount 一边,之后在查看nfs分区挂载正常。

8..exportfs:

1)exportfs -rv =/etc/init.d/nfs reload    

2)举例:

[root@nfsserver data]# exportfs -o sync,rw 192.168.21.0/24:/d==不用重启nfs

不用vi /etc/exports 要重启,是修改的配置生效。

============================================================