前提条件,确保两个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进程信息)

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"

阿里云服务器Ubuntu 14.04.2和centos7.5实现nfs挂载的更多相关文章

  1. 阿里云服务器Ubuntu 16.04 3安装mysql

    .更新系统 apt-get update [注意:要在root用户下] .安装mysql-server apt-get install mysql-serverapt-get install mysq ...

  2. 阿里云服务器ubuntu安装redis2.8.13

    阿里云服务器ubuntu安装redis2.8.13 2014-09-04 16:14 |  coding云 |  2198次阅读 | 暂无评论   一.下载redis 可以先下载到本地,然后ftp到服 ...

  3. 服务器 阿里云服务器Ubuntu挂载数据盘

    服务器 阿里云服务器Ubuntu挂载数据盘  转自:http://www.codingyun.com/article/24.html coding云运行在阿里云的Ubuntu 12.04 64位操作系 ...

  4. 阿里云服务器ubuntu安装java运行环境

    服务器 阿里云服务器ubuntu安装java运行环境 转:http://www.codingyun.com/article/45.html 今天来给大家介绍一下在阿里云ubuntu服务器下安装java ...

  5. 阿里云服务器(Ubuntu16.04 64位)远程连接

    购买阿里云服务器 1.打开阿里云官方网站,账号登录,选择产品中的云服务器 ECS 2.根据自身需求,选择合适的阿里云服务器系统,(1)点击一键购买,(2)选择地域,(3)根据自身需求,选择系统,这里选 ...

  6. 阿里云服务器(Ubuntu16.04 64位)的使用

    购买阿里云服务器 1.打开阿里云官方网站,账号登录,选择产品中的云服务器 ECS 2.根据自身需求,选择合适的阿里云服务器系统,(1)点击一键购买,(2)选择地域,(3)根据自身需求,选择系统,这里选 ...

  7. 阿里云服务器 Ubuntu 安装 LNMP

    1.设定实例化服务器IP密码. 2.设定安全组件端口 80 和 3306 系统默认提供端口 22. //阿里云需要设定安全组件端口必须设定. 3.安装一键lnmp系统. 教程地址 https://ln ...

  8. 阿里云 Server (Ubuntu 12.04) 配置 FTP

    来自 http://blog.csdn.net/zgrjkflmkyc/article/details/45510345 这个是阿里云的官方用户手册  http://bbs.aliyun.com/re ...

  9. 阿里云服务器ECS Ubuntu16.04 初次使用配置教程(图形界面安装)

    原文链接:? 传送门 前一阵子购买了阿里云的云服务器ECS(学生优惠),折腾了一阵子后对有些东西不太满意,所以就重新初始化了磁盘,刚好要重新安装图形界面,于是就顺手写了这么一篇文章. 第一次登陆服务器 ...

随机推荐

  1. Linux 系统中五笔输入法有些字打不出来(已解决)

    最近在使用CentOS7 桌面版本,在用五笔打字时,有些字打不出来,比如“覆盖”.但是在WIN下能打出来. 从网上查找原因,原来是需要改成GBK字符集.方法如下: 修改文件 vim /usr/shar ...

  2. BEX5下集成FullCalendar

    实现版本 BEX5 3.6 集成前准备: 直接网上查找FullCalendar获得插件文件 fullcalendar.min.css fullcalendar.min.js fullcalendar. ...

  3. Quickstart: Embed a Power BI Report Server report using an iFrame in SharePoint Server

    In this quickstart you will learn how to embed a Power BI Report Server report by using an iFrame in ...

  4. shutil模块和几种文件上传Demo

    一.shutil模块 1.介绍 shutil模块是对os中文件操作的补充.--移动 复制 打包 压缩 解压 2.基本使用 1. shutil.copyfileobj(文件1, 文件2, 长度) 将文件 ...

  5. bzoj 1058: [ZJOI2007]报表统计 (Treap)

    链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1058 题面; 1058: [ZJOI2007]报表统计 Time Limit: 15 Sec ...

  6. python学习日记(OOP——反射)

    反射 反射就是通过字符串的形式,导入模块:通过字符串的形式,去模块寻找指定函数,并执行.利用字符串的形式去对象(模块)中操作(查找/获取/删除/添加)成员,一种基于字符串的事件驱动! hasattr ...

  7. HTTP 404 Not Found Error with .woff or .woff2 Font Files

      如果是 ERR_ABORTED 404 (Not Found) WOFF2,则有可能是文件不存在

  8. 【转】如何在 GitHub 上找到你要的代码?

    [来源]

  9. mac开发环境搭建篇(2)--brew与mysql

    [brew]:参考 https://www.cnblogs.com/zoulifeng2017/p/7514139.html 安装brew: 终端执行:/usr/bin/ruby -e "$ ...

  10. linux 触摸屏驱动

    目录 linux 触摸屏驱动 输入子系统怎么写? 触摸屏事件 事件分类 事件设置 硬件配置 设计思路 完整程序 测试 ts_lib 使用 问题小结 title: linux 触摸屏驱动 tags: l ...