zoukankan      html  css  js  c++  java
  • NFS配置

    一,配置nfs服务端

    nfs服务端IP:192.168.1.10

    1,安装nfs

    [root@localhost ~]# yum install -y nfs-utils
    Loaded plugins: product-id, subscription-manager
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    cdrom                                                                                                                                                | 4.1 kB  00:00:00     
    Resolving Dependencies
    --> Running transaction check
    ---> Package nfs-utils.x86_64 1:1.3.0-0.el7 will be installed
    --> Processing Dependency: libtirpc >= 0.2.3-1 for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: libevent for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: libnfsidmap for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: quota for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: rpcbind for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: libevent-2.0.so.5()(64bit) for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: libnfsidmap.so.0()(64bit) for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: libtirpc.so.1()(64bit) for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Running transaction check
    ---> Package libevent.x86_64 0:2.0.21-4.el7 will be installed
    ---> Package libnfsidmap.x86_64 0:0.25-9.el7 will be installed
    ---> Package libtirpc.x86_64 0:0.2.4-0.3.el7 will be installed
    ---> Package quota.x86_64 1:4.01-11.el7 will be installed
    --> Processing Dependency: quota-nls = 1:4.01-11.el7 for package: 1:quota-4.01-11.el7.x86_64
    --> Processing Dependency: tcp_wrappers for package: 1:quota-4.01-11.el7.x86_64
    ---> Package rpcbind.x86_64 0:0.2.0-23.el7 will be installed
    --> Running transaction check
    ---> Package quota-nls.noarch 1:4.01-11.el7 will be installed
    ---> Package tcp_wrappers.x86_64 0:7.6-77.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ============================================================================================================================================================================
     Package                                     Arch                                  Version                                       Repository                            Size
    ============================================================================================================================================================================
    Installing:
     nfs-utils                                   x86_64                                1:1.3.0-0.el7                                 cdrom                                357 k
    Installing for dependencies:
     libevent                                    x86_64                                2.0.21-4.el7                                  cdrom                                214 k
     libnfsidmap                                 x86_64                                0.25-9.el7                                    cdrom                                 45 k
     libtirpc                                    x86_64                                0.2.4-0.3.el7                                 cdrom                                 85 k
     quota                                       x86_64                                1:4.01-11.el7                                 cdrom                                176 k
     quota-nls                                   noarch                                1:4.01-11.el7                                 cdrom                                 91 k
     rpcbind                                     x86_64                                0.2.0-23.el7                                  cdrom                                 55 k
     tcp_wrappers                                x86_64                                7.6-77.el7                                    cdrom                                 79 k
    
    Transaction Summary
    ============================================================================================================================================================================
    Install  1 Package (+7 Dependent packages)
    
    Total download size: 1.1 M
    Installed size: 3.4 M
    Downloading packages:
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Total                                                                                                                                        15 MB/s | 1.1 MB  00:00:00     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : libtirpc-0.2.4-0.3.el7.x86_64                                                                                                                            1/8 
      Installing : rpcbind-0.2.0-23.el7.x86_64                                                                                                                              2/8 
      Installing : 1:quota-nls-4.01-11.el7.noarch                                                                                                                           3/8 
      Installing : tcp_wrappers-7.6-77.el7.x86_64                                                                                                                           4/8 
      Installing : 1:quota-4.01-11.el7.x86_64                                                                                                                               5/8 
      Installing : libevent-2.0.21-4.el7.x86_64                                                                                                                             6/8 
      Installing : libnfsidmap-0.25-9.el7.x86_64                                                                                                                            7/8 
      Installing : 1:nfs-utils-1.3.0-0.el7.x86_64                                                                                                                           8/8 
      Verifying  : 1:nfs-utils-1.3.0-0.el7.x86_64                                                                                                                           1/8 
      Verifying  : libtirpc-0.2.4-0.3.el7.x86_64                                                                                                                            2/8 
      Verifying  : libnfsidmap-0.25-9.el7.x86_64                                                                                                                            3/8 
      Verifying  : libevent-2.0.21-4.el7.x86_64                                                                                                                             4/8 
      Verifying  : tcp_wrappers-7.6-77.el7.x86_64                                                                                                                           5/8 
      Verifying  : 1:quota-nls-4.01-11.el7.noarch                                                                                                                           6/8 
      Verifying  : 1:quota-4.01-11.el7.x86_64                                                                                                                               7/8 
      Verifying  : rpcbind-0.2.0-23.el7.x86_64                                                                                                                              8/8 
    
    Installed:
      nfs-utils.x86_64 1:1.3.0-0.el7                                                                                                                                            
    
    Dependency Installed:
      libevent.x86_64 0:2.0.21-4.el7    libnfsidmap.x86_64 0:0.25-9.el7     libtirpc.x86_64 0:0.2.4-0.3.el7    quota.x86_64 1:4.01-11.el7    quota-nls.noarch 1:4.01-11.el7   
      rpcbind.x86_64 0:0.2.0-23.el7     tcp_wrappers.x86_64 0:7.6-77.el7   
    
    Complete!
    View Code

    2,配置nfs服务端

    [root@localhost ~]# mkdir /nfs          //创建共享目录
    [root@localhost nfs]# vim /etc/exports
    
    /nfs 192.168.1.* (rw,sync,root_squash)  //分别是共享目录、允许访问的客户端、权限(读写、同步内存和硬盘数据、映射root用户为匿名用户)

    3,启动nfs服务端

    [root@localhost nfs]# systemctl is-enabled nfs-server  //查看"nfs-server"是否开机启动
    disabled
    [root@localhost nfs]# systemctl enable nfs-server   //将"nfs-server"加入开机启动
    ln -s '/usr/lib/systemd/system/nfs-server.service' '/etc/systemd/system/nfs.target.wants/nfs-server.service'
    [root@localhost nfs]# systemctl is-enabled rpcbind //查看"rpcbind"是否加入开机启动,"nfs-server"依赖于"rpcbind"
    enabled
    [root@localhost nfs]# systemctl restart rpcbind
    [root@localhost ~]# showmount -e //查看是否共享成功
    Export list for localhost.localdomain:
    /nfs (everyone)
     

    二,通过客户端验证

    1,安装nfs-utils

    [root@localhost ~]# yum -y install nfs-utils
    Loaded plugins: product-id, subscription-manager
    This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
    Resolving Dependencies
    --> Running transaction check
    ---> Package nfs-utils.x86_64 1:1.3.0-0.el7 will be installed
    --> Processing Dependency: libtirpc >= 0.2.3-1 for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: libevent for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: libnfsidmap for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: quota for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: rpcbind for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: libevent-2.0.so.5()(64bit) for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: libnfsidmap.so.0()(64bit) for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Processing Dependency: libtirpc.so.1()(64bit) for package: 1:nfs-utils-1.3.0-0.el7.x86_64
    --> Running transaction check
    ---> Package libevent.x86_64 0:2.0.21-4.el7 will be installed
    ---> Package libnfsidmap.x86_64 0:0.25-9.el7 will be installed
    ---> Package libtirpc.x86_64 0:0.2.4-0.3.el7 will be installed
    ---> Package quota.x86_64 1:4.01-11.el7 will be installed
    --> Processing Dependency: quota-nls = 1:4.01-11.el7 for package: 1:quota-4.01-11.el7.x86_64
    --> Processing Dependency: tcp_wrappers for package: 1:quota-4.01-11.el7.x86_64
    ---> Package rpcbind.x86_64 0:0.2.0-23.el7 will be installed
    --> Running transaction check
    ---> Package quota-nls.noarch 1:4.01-11.el7 will be installed
    ---> Package tcp_wrappers.x86_64 0:7.6-77.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ================================================================================
     Package              Arch           Version                Repository     Size
    ================================================================================
    Installing:
     nfs-utils            x86_64         1:1.3.0-0.el7          cdrom         357 k
    Installing for dependencies:
     libevent             x86_64         2.0.21-4.el7           cdrom         214 k
     libnfsidmap          x86_64         0.25-9.el7             cdrom          45 k
     libtirpc             x86_64         0.2.4-0.3.el7          cdrom          85 k
     quota                x86_64         1:4.01-11.el7          cdrom         176 k
     quota-nls            noarch         1:4.01-11.el7          cdrom          91 k
     rpcbind              x86_64         0.2.0-23.el7           cdrom          55 k
     tcp_wrappers         x86_64         7.6-77.el7             cdrom          79 k
    
    Transaction Summary
    ================================================================================
    Install  1 Package (+7 Dependent packages)
    
    Total download size: 1.1 M
    Installed size: 3.4 M
    Downloading packages:
    --------------------------------------------------------------------------------
    Total                                               47 MB/s | 1.1 MB  00:00     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : libtirpc-0.2.4-0.3.el7.x86_64                                1/8 
      Installing : rpcbind-0.2.0-23.el7.x86_64                                  2/8 
      Installing : 1:quota-nls-4.01-11.el7.noarch                               3/8 
      Installing : tcp_wrappers-7.6-77.el7.x86_64                               4/8 
      Installing : 1:quota-4.01-11.el7.x86_64                                   5/8 
      Installing : libevent-2.0.21-4.el7.x86_64                                 6/8 
      Installing : libnfsidmap-0.25-9.el7.x86_64                                7/8 
      Installing : 1:nfs-utils-1.3.0-0.el7.x86_64                               8/8 
      Verifying  : 1:nfs-utils-1.3.0-0.el7.x86_64                               1/8 
      Verifying  : libtirpc-0.2.4-0.3.el7.x86_64                                2/8 
      Verifying  : libnfsidmap-0.25-9.el7.x86_64                                3/8 
      Verifying  : libevent-2.0.21-4.el7.x86_64                                 4/8 
      Verifying  : tcp_wrappers-7.6-77.el7.x86_64                               5/8 
      Verifying  : 1:quota-nls-4.01-11.el7.noarch                               6/8 
      Verifying  : 1:quota-4.01-11.el7.x86_64                                   7/8 
      Verifying  : rpcbind-0.2.0-23.el7.x86_64                                  8/8 
    
    Installed:
      nfs-utils.x86_64 1:1.3.0-0.el7                                                
    
    Dependency Installed:
      libevent.x86_64 0:2.0.21-4.el7          libnfsidmap.x86_64 0:0.25-9.el7       
      libtirpc.x86_64 0:0.2.4-0.3.el7         quota.x86_64 1:4.01-11.el7            
      quota-nls.noarch 1:4.01-11.el7          rpcbind.x86_64 0:0.2.0-23.el7         
      tcp_wrappers.x86_64 0:7.6-77.el7       
    
    Complete!
    View Code

    2,启动"rpcbind"和"nfs-server",并加入开机启动

    3,挂载服务端的nfs共享目录"/nfs"到客户端"/mnt/nfs"下

    [root@localhost ~]# showmount -e 192.168.1.10  //查看可用共享文件
    Export list for 192.168.1.10:
    /nfs (everyone)
    [root@localhost ~]# mkdir /mnt/nfs
    [root@localhost ~]# mount -t nfs 192.168.1.10:/nfs /mnt/nfs
    [root@localhost ~]# ls /mnt/nfs/
    1  2
    [root@localhost ~]# cat /mnt/nfs/1
    hello

    或者将挂载信息写入"/etc/fstab"中,开机自动挂载

    [root@localhost ~]# vim /etc/fstab
    
    
    #
    # /etc/fstab
    # Created by anaconda on Sat Feb 13 09:29:45 2016
    #
    # Accessible filesystems, by reference, are maintained under '/dev/disk'
    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
    #
    /dev/mapper/rhel-root   /                       xfs     defaults        1 1
    UUID=8d922f42-25a9-42aa-aee2-6e29b1ac7f1a /boot                   xfs     defaults        1 2
    /dev/mapper/rhel-swap   swap                    swap    defaults        0 0
    /dev/cdrom              /media/cdrom            iso9660 defaults        0 0 
    192.168.1.10:/nfs      /mnt/nfs                nfs     defaults        0 0 
  • 相关阅读:
    shell脚本批量启动jar
    springboot最简单的AOP
    springboot 将null字段输出为空串
    随便记录
    MySQL case when 用法
    JavaDate数据返回到前端变数字的问题
    多级菜单无限递归
    linux tomacat 之部署 war包
    linux tomcat部署 之 jre
    leetcode Best Time to Buy and Sell Stock
  • 原文地址:https://www.cnblogs.com/fishhh/p/5188183.html
Copyright © 2011-2022 走看看