前提条件,确保两个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. 【转帖】系统软件工程师必备技能-进程内存的working set size(WSS)测量

    系统软件工程师必备技能-进程内存的working set size(WSS)测量 2018年12月28日 18:43:01 Linuxer_ 阅读数:145 https://blog.csdn.net ...

  2. Python——Django-__init__.py的内容

    一.告诉Django用pymysql来代替默认的MySQLdb(在__init__.py里) import pymysql #告诉Django用pymysql来代替默认的MySQLdb pymysql ...

  3. 关于rem布局

    实际UI设计稿给过来为了在手机屏幕上显示清晰,设计稿通常为实际标准手机页面的2倍,一般为640px(以ip5的屏幕尺寸320px设计)或者750px(以ip6的屏幕尺寸为375px设计),这是前提. ...

  4. 用Pytorch训练MNIST分类模型

    本次分类问题使用的数据集是MNIST,每个图像的大小为\(28*28\). 编写代码的步骤如下 载入数据集,分别为训练集和测试集 让数据集可以迭代 定义模型,定义损失函数,训练模型 代码 import ...

  5. python版接口自动化测试框架源码完整版(requests + unittest)

    python版接口自动化测试框架:https://gitee.com/UncleYong/my_rf [框架目录结构介绍] bin: 可执行文件,程序入口 conf: 配置文件 core: 核心文件 ...

  6. Oracle jdbc 连接

    所需jar包: ojdbc6.jar 下载地址:https://download.csdn.net/download/xc_oo0/10897959 示例代码: package cnblogs.com ...

  7. POM文件分析记

    pom英文全称:project object model 1.简介 pom.xml文件描述了maven项目的基本信息,比如groupId,artifactId,version等.也可以对maven项目 ...

  8. (二叉树 BFS) leetcode102. Binary Tree Level Order Traversal

    Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, ...

  9. mysql加速导入数据的简单设置

    mysql加速导入数据的简单设置 # 修改前查询参数值 show variables like 'foreign_key_checks'; show variables like 'unique_ch ...

  10. django分页器

    网站页面的分页效果可以通过分页器实现 分页器的使用 urls.py from django.contrib import admin from django.urls import path from ...