zoukankan      html  css  js  c++  java
  • 云服务器Ubuntu 14.04.2和centos7.5实现nfs挂载

    前提条件,确保两个ip可以正常通信

    确认服务端是否安装nfs-utils和rpcbind
    [root@localhost /]# rpm -qa|grep "nfs"
    nfs4-acl-tools-0.3.3-17.el7.x86_64
    libnfsidmap-0.25-19.el7.x86_64
    nfs-utils-1.3.0-0.61.el7.x86_64

    [root@localhost /]# rpm -qa|grep "rpc"
    xmlrpc-c-client-1.32.5-1905.svn2451.el7.x86_64
    libtirpc-0.2.4-0.10.el7.x86_64
    rpcbind-0.2.0-47.el7.x86_64
    xmlrpc-c-1.32.5-1905.svn2451.el7.x86_64

    mkdir /data/sharestore 创建共享目录

    chmod -Rf 777 /data/sharestore 确保其他用户对该目录具备读写权限(该步骤可以不执行)
    服务端配置
    cat /etc/exports
    /data/sharestore *(insecure,rw,no_root_squash,no_all_squash,async)

    exports参数相关可以参考:https://blog.csdn.net/qq_36357820/article/details/78488077

    cat /etc/sysconfig/nfs|grep -v '#'
    LOCKD_TCPPORT=32803
    LOCKD_UDPPORT=32769
    RPCNFSDARGS="-N 4"
    MOUNTD_PORT=10892
    STATD_PORT=10662
    STATD_OUTGOING_PORT=12020
    GSS_USE_PROXY="yes"

    systemctl restart rpcbind
    systemctl restart nfs-server

    systemctl enable rpcbind
    systemctl enable nfs-server

    exportfs -r 使配置文件立即生效

    客户端配置:

    确认是否安装:nfs-common 该包提供showmount等功能

    执行:dpkg-query -l nfs-common

    出现以下信息说明已安装
    Desired=Unknown/Install/Remove/Purge/Hold
    | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
    |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
    ||/ Name Version Architecture Description
    +++-==================================================-==============================-==============================-=========================================================================================================
    ii nfs-common 1:1.2.8-6ubuntu1.2 amd64 NFS support files common to client and server

    mkdir /nfsfile 创建挂载目录

    chmod -Rf 777 /nfsfile(具备读写权限即可,可以不给777)

    showmount -e 服务端ip(如果出现服务端共享的目录信息说明目录共享成功)

    rpcinfo -p 服务端ip地址 ---查看服务端rpc进程(该命令不指定ip地址可以用于获取本地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

        100005    1   udp  20048  mountd

        100005    1   tcp  20048  mountd

        100005    2   udp  20048  mountd

        100005    2   tcp  20048  mountd

        100005    3   udp  20048  mountd

        100005    3   tcp  20048  mountd

        100003    3   tcp   2049  nfs

        100003    4   tcp   2049  nfs

        100227    3   tcp   2049  nfs_acl

        100003    3   udp   2049  nfs

        100003    4   udp   2049  nfs

        100227    3   udp   2049  nfs_acl

        100021    1   udp  31206  nlockmgr

        100021    3   udp  31206  nlockmgr

        100021    4   udp  31206  nlockmgr

        100021    1   tcp  31241  nlockmgr

        100021    3   tcp  31241  nlockmgr

        100021    4   tcp  31241  nlockmgr

    客户端iptables配置策略如下(需要开放的端口请参考以上查询到的rpc进程信息)

    云服务器需要在安全组中允许该端口的ACL策略
    iptables -I INPUT -p tcp -s x.x.x.x --dport 111 -j ACCEPT(x.x.x.x为服务端ip地址)
    iptables -I INPUT -p udp -s x.x.x.x --dport 111 -j ACCEPT
    iptables -I INPUT -p tcp -s x.x.x.x --dport 2049 -j ACCEPT
    iptables -I INPUT -p udp -s x.x.x.x --dport 2049 -j ACCEPT

    iptables -I INPUT -p tcp -s x.x.x.x --dport 20048 -j ACCEPT
    iptables -I INPUT -p udp -s x.x.x.x --dport 20048 -j ACCEPT
    iptables -I INPUT -p tcp -s x.x.x.x --dport 31206 -j ACCEPT
    iptables -I INPUT -p udp -s x.x.x.x --dport 31206 -j ACCEPT

    挂载命令:mount -t nfs 服务端ip地址:/home/nfs /home/nfs

    执行df -h查询目录是否挂载成功

    如系统版本较高导致挂载失败问题可以参考如下:

    https://blog.csdn.net/qq_30951423/article/details/85890581

    Ubuntu 18.04 nfs 默认为协议3和协议4,但是默认启动的是协议2的形式
    如:/data/sharestore *(insecure,rw,no_root_squash,no_all_squash,async)
    若想要求 nfs 支持协议2,就在/etc/default/nfs-kernel-server末尾加一句:
    RPCNFSDOPTS="--nfs-version 2,3,4 --debug --syslog"

    vim /etc/default/nfs-kernel-server
    RPCNFSDOPTS="--nfs-version 2,3,4 --debug --syslog"

  • 相关阅读:
    textarea 滚动条属性设置
    js触发asp.net的Button的Onclick事件
    Asp.Net获取远程数据并保存为文件的简单代码
    《WEB标准拾遗系列》
    .NET基础拾遗系列第一篇
    .NET基础拾遗系列第三篇
    你的知识如何管理(必须看)
    .NET基础拾遗系列第二篇
    随便划两笔
    Sql server 事务的两种用法 (转)
  • 原文地址:https://www.cnblogs.com/caidingyu/p/10438976.html
Copyright © 2011-2022 走看看