NFS

Posted 李伟铭

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NFS相关的知识,希望对你有一定的参考价值。

[[email protected] ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[[email protected] ~]# uname -ra
Linux nfs-server 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

[[email protected] ~]# rpm -aq nfs-utils rpcbind
[[email protected] ~]# yum install nfs-utils rpcbind

[[email protected] ~]# rpm -aq nfs-utils rpcbind
nfs-utils-1.2.3-75.el6.x86_64
rpcbind-0.2.0-13.el6_9.x86_64


[[email protected] ~]# /etc/init.d/rpcbind status
rpcbind is stopped

[[email protected] ~]# /etc/init.d/rpcbind start
Starting rpcbind:                                          [  OK  ]
[[email protected] ~]# /etc/init.d/rpcbind status
rpcbind (pid  1634) is running...

[[email protected] ~]# lsof -i :111
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
rpcbind 1634  rpc    6u  IPv4  12217      0t0  UDP *:sunrpc
rpcbind 1634  rpc    8u  IPv4  12220      0t0  TCP *:sunrpc (LISTEN)
rpcbind 1634  rpc    9u  IPv6  12222      0t0  UDP *:sunrpc
rpcbind 1634  rpc   11u  IPv6  12225      0t0  TCP *:sunrpc (LISTEN)

[[email protected] ~]# netstat -lntup|grep rpcbind
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1634/rpcbind       
tcp        0      0 :::111                      :::*                        LISTEN      1634/rpcbind       
udp        0      0 0.0.0.0:961                 0.0.0.0:*                               1634/rpcbind       
udp        0      0 0.0.0.0:111                 0.0.0.0:*                               1634/rpcbind       
udp        0      0 :::961                      :::*                                    1634/rpcbind       
udp        0      0 :::111                      :::*                                    1634/rpcbind       

[[email protected] ~]# chkconfig  --list rpcbind
rpcbind         0:off 1:off 2:on 3:on 4:on 5:on 6:off
[[email protected] ~]# 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

[[email protected] ~]# /etc/init.d/nfs status
rpc.svcgssd is stopped
rpc.mountd is stopped
nfsd is stopped
rpc.rquotad is stopped

[[email protected] ~]# /etc/init.d/nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting RPC idmapd:                                       [  OK  ]

[[email protected] ~]# /etc/init.d/nfs status
rpc.svcgssd is stopped
rpc.mountd (pid 1747) is running...
nfsd (pid 1763 1762 1761 1760 1759 1758 1757 1756) is running...
rpc.rquotad (pid 1742) is running...

[[email protected] ~]# netstat -lntup|grep 2049  
tcp        0      0 0.0.0.0:2049                0.0.0.0:*                   LISTEN      -                  
tcp        0      0 :::2049                     :::*                        LISTEN      -                  
udp        0      0 0.0.0.0:2049                0.0.0.0:*                               -                  
udp        0      0 :::2049                     :::*                                    -                  
[[email protected] ~]# 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
    100011    1   udp    875  rquotad
    100011    2   udp    875  rquotad
    100011    1   tcp    875  rquotad
    100011    2   tcp    875  rquotad
    100005    1   udp  35857  mountd
    100005    1   tcp  35831  mountd
    100005    2   udp  47857  mountd
    100005    2   tcp  35728  mountd
    100005    3   udp  55499  mountd
    100005    3   tcp  55169  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  42835  nlockmgr
    100021    3   udp  42835  nlockmgr
    100021    4   udp  42835  nlockmgr
    100021    1   tcp  56192  nlockmgr
    100021    3   tcp  56192  nlockmgr
    100021    4   tcp  56192  nlockmgr

[[email protected] ~]# chkconfig nfs on
[[email protected] ~]# chkconfig --list nfs
nfs             0:off 1:off 2:on 3:on 4:on 5:on 6:off

 
[[email protected] ~]#  vi /etc/rc.local

 

添加

###
/etc/init.d/rpcbind start
###
/etc/init.d/nfs start

 

编辑共享目录

[[email protected] ~]# vi /etc/exports
/data   192.168.31.0/24(rw,sync)

创建目录

mkdir /data

授权目录

chown -R nfsnobody /data
                         

 

客户端 挂载

[[email protected] ~]# mount -t nfs 192.168.31.29:/data /mnt

 

showmount -e 192.168.31.29

[[email protected] ~]# showmount -e 192.168.31.29
Export list for 192.168.31.29:
/data 192.168.31.0/24
[[email protected] ~]# ls -l /mnt/
total 24
drwxr-xr-x 2 nfsnobody nfsnobody 4096 Jun 12 13:27 li
-rw-r--r-- 1 nfsnobody root        22 Jun 12 13:17 li.txt
drwxr-xr-x 2 nfsnobody nfsnobody 4096 Jun 12 13:26 liweiming
drwxr-xr-x 2 nfsnobody nfsnobody 4096 Jun 12 15:13 mnt
drwxr-xr-x 2 nfsnobody nfsnobody 4096 Jun 12 15:18 nfs-server
drwxr-xr-x 3 nfsnobody nfsnobody 4096 Jun 12 13:30 www
[[email protected] ~]#

[[email protected] ~]# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/sda3             19G  1.5G   17G   9% /
tmpfs                238M     0  238M   0% /dev/shm
/dev/sda1            190M   36M  145M  20% /boot
192.168.31.29:/data   19G  1.5G   17G   9% /mnt

 

以上是关于NFS的主要内容,如果未能解决你的问题,请参考以下文章

nfs是啥

NFS

NFS介绍NFS服务端安装配置NFS配置选项

NFS介绍 NFS服务端安装配置 NFS配置选项

NFS介绍NFS服务端安装配置NFS配置选项

windows 怎么访问nfs服务器