千家信息网

nfs网络文件系统如何安装

发表于:2025-02-14 作者:千家信息网编辑
千家信息网最后更新 2025年02月14日,这篇文章给大家分享的是有关nfs网络文件系统如何安装的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。一:nfs服务器端的安装1、安装nfs服务 yum -y install
千家信息网最后更新 2025年02月14日nfs网络文件系统如何安装

这篇文章给大家分享的是有关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. helper program)  In some cases useful info is found in syslog - try  dmesg | tail  or so


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

0