温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

nfs网络文件系统如何安装

发布时间:2021-11-16 10:42:33 来源:亿速云 阅读:171 作者:小新 栏目:云计算

这篇文章给大家分享的是有关nfs网络文件系统如何安装的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

一:nfs服务器端的安装

  • 1、安装nfs服务

      yum -y install nfs-utils


  • 2、配置发布的路径及访问权限

      vim /etc/exports             增加
      /nfsPrimary *(rw,async,no_root_squash,no_subtree_check)
      /nfsSecondary *(rw,async,no_root_squash,no_subtree_check)


    同时可以指定谁能够挂在这个共享出去的文件夹

      /nfsPrimary liufukinKVM(rw,async,no_root_squash,no_subtree_check)
      /nfsSecondary 192.168.10.*(rw,async,no_root_squash,no_subtree_check)


  • 3、配置nfs需要绑定的端口

      vim /etc/sysconfig/nfs


    找到下面的配置项,并且开启

      LOCKD_TCPPORT=32803
      LOCKD_UDPPORT=32769
      MOUNTD_PORT=892
      RQUOTAD_PORT=875
      STATD_PORT=662
      STATD_OUTGOING_PORT=2020


  • 4、iptables防洪墙开放端口(要在reject之前增加,否则无效)

    vi /etc/sysconfig/iptables

      -A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 111 -j ACCEPT
      -A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 111 -j ACCEPT
      -A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 2049 -j ACCEPT
      -A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 32803 -j ACCEPT
      -A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 32769 -j ACCEPT
      -A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 892 -j ACCEPT
      -A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 892 -j ACCEPT
      -A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 875 -j ACCEPT
      -A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 875 -j ACCEPT
      -A INPUT -s 172.16.10.0/24 -m state --state NEW -p tcp --dport 662 -j ACCEPT
      -A INPUT -s 172.16.10.0/24 -m state --state NEW -p udp --dport 662 -j ACCEPT


    防火墙重启

      service iptables restart


  • 5、关闭selinux或者开启允许模式

      sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
      setenforce 0


  • 6、启动nfs服务器

      service rpcbind start
      service nfs start
      chkconfig rpcbind on
      chkconfig nfs on


二、NFS客户端的操作

  • 1、showmout命令对于NFS的操作和查错有很大的帮助,所以我们先来看一下showmount的用法

      showmout 
      -a :这个参数是一般在NFS SERVER上使用,是用来显示已经mount上本机nfs目录的cline机器。 
      -e :显示指定的NFS SERVER上export出来的目录。


    例如:

      showmount -e 192.168.0.30 
      Export list for localhost: 
      /tmp * 
      /home/linux *.linux.org 
      /home/public (everyone) 
      /home/test 192.168.0.100


  • 2、mount nfs目录的方法:

      mount -t nfs hostname(orIP):/directory /mount/point


    具体例子:

      Linux: mount -t nfs 192.168.0.1:/tmp /mnt/nfs 
      [root[@localhost](https://my.oschina.net/u/570656) /]# showmount -e 192.168.0.169
      Export list for 192.168.0.169:
      /home/opt/RHEL4U5 192.168.0.0/255.255.252.0
      You have new mail in /var/spool/mail/root
      mount -t nfs 192.168.0.169:/home/opt/RHEL4U5 /mnt/soft


    注意:需要安装nfs,否则会报

      mount: wrong fs type, bad option, bad superblock on 125.64.41.244:/data/img,
      missing codepage or helper program, or other error
      (for several filesystems (e.g. nfs, cifs) you might
      need a /sbin/mount.<type> helper program)
      In some cases useful info is found in syslog - try
      dmesg | tail  or so


感谢各位的阅读!关于“nfs网络文件系统如何安装”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

nfs
AI