阿里云ECS上实现NFS挂载

1. 背景

由于项目需要,现在需要在阿里云上多台服务器上共享一些静态的文件数据。开始时选型方案有:OSS对象存储、NAS存储、自己搭建NFS;考虑成本需要,选择了自己搭建NFS。 项目在阿里金融云上,金融云上产品比公有云贵多了。 下面讲解过程。

注意:你的ECS是否在一个区,且是否在一个安全组。如果两台ECS不在同一个安全组,因此需要在各自的安全组设置规则,在内网进出方向分别添加对方的IP地址。

2. 过程

2.1 服务端

2.1.1 安装    
yum install nfs-utils –y

2.1.2 修改配置文件    
[[email protected] home]# vim /etc/exports    
/home/nfstest 10.0.18.1(rw,sync,no_root_squash)    
/home/nfstest 10.0.16.120(rw,sync,no_root_squash)

#新建目录

mkdir –p /home/nfstest

no_root_squash:登入 NFS 主机使用分享目录的使用者,如果是 root 的话,那么对于这个分享的目录来说,他就具有 root 的权限!这个项目『极不安全』,不建议使用!    
root_squash:在登入 NFS 主机使用分享之目录的使用者如果是 root 时,那么这个使用者的权限将被压缩成为匿名使用者,通常他的 UID 与 GID 都会变成 nobody 那个系统账号的身份;

2.1.3 启动服务    
service rpcbind start #启动端口转发    
service nfs start #启动NFS

chkconfig rpcbind on #rpcbind 加入启动项  
chkconfig nfs on #nfs加入启动项  
启动后如果修改了目录,可执行exprotfs -rv 实现刷新

2.1.4 添加防火墙规则

iptables -I INPUT -p tcp -m multiport --dports 875,2049,111,28300,5076,39927,46286 -j ACCEPT    
iptables -I INPUT -p udp -m multiport --dports 875,2049,111,37747,31166,9292,57181 -j ACCEPT

注意:由于要开放的端口较多且不连续,最好的做法是修改相应的端口。 可以参考我的另外一篇博文

http://pizibaidu.blog.51cto.com/1361909/1662428

2.2 客户端

2.2.1 安装    
yum install nfs-utils –y

2.2.2 挂载    
a. 立一个目录用来作挂接点    
mkdir -p /home/nfs    
b、进行挂接    
mount -t nfs 10.0.16.122:/home/nfstest /home/nfs -o proto=tcp -o nolock    
c、取消挂接    
umount /home/nfs

3. 遇到的问题

3.1 如果客户端不安装nfs-utils会报如下错误:

mount: wrong fs type, bad option, bad superblock on 10.0.16.122:/home/nfstest,    
        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

解决方法:yum install nfs-utils –y

3.2 clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)

挂载时报的错误。

解决方法: 由于服务端防火墙的阻止,需要把所有的端口都加进去。需要把那些端口加入防火墙,可以执行命令: rpcinfo -p 10.0.16.122

或者关掉防火墙

# rpcinfo -p 10.0.16.122

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    
     100011    1   udp    875  rquotad    
     100011    2   udp    875  rquotad    
     100011    1   tcp    875  rquotad    
     100011    2   tcp    875  rquotad    
     100005    1   udp  37747  mountd    
     100005    1   tcp   5076  mountd    
     100005    2   udp  31166  mountd    
     100005    2   tcp  39927  mountd    
     100005    3   udp   9292  mountd    
     100005    3   tcp  28300  mountd    
     100003    2   tcp   2049  nfs    
     100003    3   tcp   2049  nfs    
     100003    4   tcp   2049  nfs    
     100227    2   tcp   2049  nfs_acl    
     100227    3   tcp   2049  nfs_acl    
     100003    2   udp   2049  nfs    
     100003    3   udp   2049  nfs    
     100003    4   udp   2049  nfs    
     100227    2   udp   2049  nfs_acl    
     100227    3   udp   2049  nfs_acl    
     100021    1   udp  57181  nlockmgr    
     100021    3   udp  57181  nlockmgr    
     100021    4   udp  57181  nlockmgr    
     100021    1   tcp  46286  nlockmgr    
     100021    3   tcp  46286  nlockmgr    
     100021    4   tcp  46286  nlockmgr

3.3 nfs rpc.mountd: svc_tli_create: could not open connection for udp6

启动NFS报错如下:    
Starting NFS mountd: rpc.mountd: svc_tli_create: could not open connection for udp6    
rpc.mountd: svc_tli_create: could not open connection for tcp6    
rpc.mountd: svc_tli_create: could not open connection for udp6    
rpc.mountd: svc_tli_create: could not open connection for tcp6    
rpc.mountd: svc_tli_create: could not open connection for udp6    
rpc.mountd: svc_tli_create: could not open connection for tcp6

解决办法:

修改如下配置文件,然后重启服务即可。    
[[email protected] ~]# vi /etc/netconfig    
udp tpi_clts v inet udp - -    
tcp tpi_cots_ord v inet tcp - -    
#udp6 tpi_clts v inet6 udp - -    
#tcp6 tpi_cots_ord v inet6 tcp - -    
rawip tpi_raw - inet - - -    
local tpi_cots_ord - loopback - - -    
unix tpi_cots_ord - loopback - - -

时间: 2024-08-30 03:04:19

阿里云ECS上实现NFS挂载的相关文章

navicat远程连接阿里云ECS上的MYSQL报Lost connection to MySQL server at &#39;reading initial communication packet&#39;

问题现象 MySQL 远程连接报错:Lost connection to MySQL server at 'reading initial communication packet' 解决方案 1.检查是否有防火墙限制2.检查 MySQL 是否有访问权限 use mysql; Grant all privileges on *.* to 'root'@'%' identified by '密码' with grant option; flush privileges; 3.检查 my.ini 文

阿里云ECS上APP访问异常或超时

App访问ECS连接超时或访问慢: 具体情况描述: 1.Android.iOS两个版本的App,Android访问部署阿里云ECS上的API经常出现超时和访问慢的情况 2.访问阿里云ECS上的Android API超时问题和访问慢的情况,主要出现在通过公司WiFi网络访问时出现: 3. 在别的地方或者APP用户通过WiFi访问阿里云ECS上的Android API时,访问正常: 4.当Android访问API超时和访问慢的时候,马上关闭Wifi切换到手机数据网络,访问正常; 原因: 导致请求阿里

阿里云ECS上LVM磁盘配置

首先说明机器系统为:ubuntu 16.04 1.首先需要在ubuntu下安装lvm,先需要更新一下ubuntu内软件包 apt-get -y update # 更新软件源 apt-get -y upgrade # 更新已经安装的软件 apt-get -y install lvm2 #安装lvm命令等 2.通过fdisk -l 查看磁盘的属性,找到要添加的磁盘名称.我是阿里云高效云盘所以是:(Disk /dev/vdb) 3.使用fdisk将磁盘进行逻辑分区fdisk /dev/vdbm来查看命

在阿里云ECS上安装docker 1.7.1

1.打开iptables,因为docker需要iptables做net转发,而我的iptables不存在,需要安装 yum install -y iptables touch /etc/sysconfig/iptables service iptables start chkconfig iptables on 2.以下是我安装iptables时的报错图,使用上面的配置可以解决 3.安装docker yum install -y docker-io yum upgrade device-mapp

阿里云ECS上ftp的安装与配置

1.安装 使用chkconfig --list查看系统是否已经安装有vsftpd服务,若有,跳过此步骤. 使用yum命令直接安装,并为塔创建日志文件 [[email protected] /]# yum -y install vsftpd ...... [[email protected] /]# touch /var/log/vsftpd.log 2.ftp服务的启停与开机启动配置 启动ftp服务: [[email protected] /]# service vsftpd start Sta

阿里云ECS CentOS7服务器上部署web项目简单办法

首先在阿里云ECS上租个centOS的linux服务器,选择自带JDK和tomcat的,这样就省得自己敲命令去安装和配置环境了, 租好后 下载2个软件 用google搜索 xshell(用这个软件连接服务器,然后操作服务器)和xftp(用这个软件来进行本地和服务器间的文件传输,有了这个操作服务器上的文件就变成 图形化操作了,对不熟linux的人很有帮助) 接下来到tomcat的bin目录下 启动tomcat,     tomcat是在/home目录下,启动是用./startup.sh命令 但是启

阿里云ECS架设VPN过程总结

原文地址: http://blog.csdn.net/johnnycode/article/details/45543157 最近开发移动项目,数据库服务是架设在电信服务器上,可怜我的联通网络本地调试直接x碎了一地!! 度娘相关资料后,最终决定在阿里云ECS上架设VPN作为跳板来访问电信服务器! 一.原理 1.阿里云ECS上架设VPN. 2.本地连接使用VPN拨号到阿里云ECS. 3.使用阿里云ECS网络访问电信服务器. 使用VPN前效果 64 bytes from xxx.xxx.xxx.xx

阿里云ECS部署node.js及防火墙80端口开启

第一篇竟然是node.js在阿里云ECS上的部署遇到的小问题记录. 很多时候我们排除故障都会掉进小坑,但别小看是小坑,有时候挺烦人挺难缠的,主要还是基础知识匮乏导致思路混乱造成的,在这里记录下,给自己提个醒,也为网友指条明路,别像我一样乱折腾了. 环境描述: 1.阿里云ECS 单核.1G内存.1M带宽,基本就是最低配置了 2.阿里云提供的CentOS 6.5安全加固版 3.node.js 0.10.30 一,安装过程(尽量精简了,教程太多,不多说) #yum install gcc-c++ op

阿里云ECS的1M带宽能干嘛?

阿里云最近正在搞活动的ECS机器,普遍都是1M带宽,因此最近推广阿里云的时候,小编被很多人问道"1M小水管能干吗?".在动辄家庭宽带达百兆的时代,1M带宽确实是个大部分人都会担心的问题.本文就给大家科普下阿里云ECS的固定1M带宽的含义.为了保证文档更新及时,因此请访问(http://wzfw.ltd/)查看最新阿里云优惠活动推荐,小编的幸运券领取地址为(http://wzfw.ltd/qjyl),感谢领券支持! 为了更好的理解,需要先给大家解释个词"下行带宽"和&