简体   繁体   English

aws efs 挂载时连接超时

[英]aws efs connection timeout at mount

I am following this tutorial to mount efs on AWS EC2 instance but when Iam executing the mount command我按照 教程在 AWS EC2 实例上安装 efs 但是当我执行 mount 命令时

sudo mount -t nfs4 -o vers=4.1 $(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone).[EFS-ID].efs.[region].amazonaws.com:/ efs

I am getting connection time out every time.我每次都连接超时。

mount.nfs4: Connection timed out

What may be the problem here?这可能是什么问题?

Thanks in advance!提前致谢!

I found the accepted answer here to be incorrect & insecure, and Bao's answer above is very close - except you don't need NFS Inbound on your EC2 (mount target) security group.我发现此处接受的答案不正确且不安全,而 Bao 的上述答案非常接近 - 除非您的 EC2(挂载目标)安全组不需要 NFS Inbound。 You just need a security group assigned to your EC2 (even with no rules) so that your EFS Security group can be limited to that security group... you know, for security!您只需要为您的 EC2 分配一个安全组(即使没有规则),这样您的 EFS 安全组就可以限制在该安全组中……您知道,为了安全! Here's what I found works:这是我发现的作品:

  • Create a new security group for your EC2 instance.为您的 EC2 实例创建一个新的安全组。 Name it EFS Target , and leave all the rules blank将其命名为EFS Target ,并将所有规则留空
  • Create a new security group for your EFS Mount.为您的 EFS 挂载创建一个新的安全组。 Name it EFS Mount , and in this one add the inbound rule for NFS.将其命名为EFS Mount ,并在其中添加 NFS 的inbound规则。 Set the SOURCE for this rule to the EFS Target security group you created above.将此规则的 SOURCE 设置为您在上面创建的EFS Target安全组。 This limits EFS to only being able to connect to EC2 instances that have the EFS Mount security group assigned (See below).这将 EFS 限制为只能连接到分配了EFS Mount安全组的 EC2 实例(见下文)。 If you're not worried about that, you can select "Any" from the Source dropdown and it'll work just the same, without the added level of security如果您不担心这一点,您可以从 Source 下拉列表中选择“Any”,它会以同样的方式工作,而无需增加安全级别
  • Go to the EC2 console, and add the EFS Target group to your EC2 instance, assuming you're adding the extra security转到 EC2 控制台,并将EFS Target组添加到您的 EC2 实例,假设您要添加额外的安全性
  • Go to the EFS Console, select your EFS and choose Manage File System Access转到 EFS 控制台,选择您的 EFS 并选择管理文件系统访问
    • For each EFS Mount Target (availability zone), you need to add the EFS Mount security group and remove the VPC Default group (if you haven't already)对于每个 EFS 挂载目标(可用区),您需要添加EFS Mount安全组并删除 VPC 默认组(如果您还没有)
  • The mount command in the AWS documentation should work now AWS 文档中的 mount 命令现在应该可以工作了

I don't like how they mixed vernacular here in terms of EC2 being a mount-target, but also EFS has individual mount-targets for each availability zone.我不喜欢他们在这里混合白话,因为 EC2 是挂载目标,而且 EFS 对每个可用区都有单独的挂载目标。 Makes their documentation very confusing, but following the steps above allowed me to mount an EFS securely on an Ubuntu server.使他们的文档非常混乱,但按照上述步骤,我可以在 Ubuntu 服务器上安全地挂载 EFS。

Add type with NFS and port 2049 to the Inbound of your security group that your EC2 instances and EFS running on.将带有 NFS 和端口 2049 的类型添加到运行 EC2 实例和 EFS 的安全组的入站。 It works for me.这个对我有用。

Bao

A different answer here, as I faced a very similar error and none of the answers fit.这里有一个不同的答案,因为我遇到了一个非常相似的错误并且没有一个答案适合。

I was trying to mount a NFS like below (in my case EKS was doing that on my behalf, but I tested the very same command manually in the worker node with the same result):我试图安装一个如下所示的 NFS(在我的情况下,EKS 代表我这样做,但我在工作节点中手动测试了相同的命令,结果相同):

[root@host ~]# mount -t nfs fs-abc1234.efs.us-east-1.amazonaws.com:/persistentvolumes /mnt/test

Output was: mount.nfs: Connection timed out输出为: mount.nfs: Connection timed out

When I simply tried the same command, but using / as the path:当我只是尝试相同的命令,但使用/作为路径:

[root@host ~]# mount -t nfs fs-abc1234.efs.us-east-1.amazonaws.com:/ /mnt/test

It worked like a charm!它就像一个魅力!

I really do not understand how a possible wrong or missing path can lead to a time out kind of error, but that was the only thing that could fix the problem for me, all the network configuration remained the same.我真的不明白可能的错误或丢失路径如何导致time out错误,但这是唯一可以为我解决问题的方法,所有网络配置都保持不变。

As I was using EKS/Kubernetes, I dedcided to mount / , which works, and then use subPath to change the volume mounting point in the container configuration.当我使用 EKS/Kubernetes 时,我决定挂载/ ,它可以工作,然后使用subPath来更改容器配置中的卷挂载点。

I had the same problem and following the Amazon AWS guides it worked for one server of mine but another one didn't want to mount the EFS volume.我遇到了同样的问题,按照 Amazon AWS 指南,它适用于我的一台服务器,但另一台不想挂载 EFS 卷。 Analyzing the local server messages log I've found that the outgoing TCP traffic was BLOCKED even if the associated Security Group was set to allow any outgoing traffic (on any port, any external address etc.).分析本地服务器消息日志,我发现即使关联的安全组设置为允许任何传出流量(在任何端口、任何外部地址等),传出的 TCP 流量也被阻止。 Setting a rule on the Security Group to allow TCP connections from EC2 host to EFS service on port 2049 didn't get any effect while instead setting a specific rule on the local iptable firewall got the job and resolved the issue.在安全组上设置规则以允许从 EC2 主机到端口 2049 上的 EFS 服务的 TCP 连接没有任何效果,而是在本地 iptable 防火墙上设置特定规则得到了工作并解决了问题。 I can't figure out why there was this discrepancy but it worked for me.我不知道为什么会出现这种差异,但它对我有用。 As far as I know the local iptables fw should not be touched and it should obtain the rules directly from the SG from AWS console.据我所知,不应触及本地 iptables fw,它应该直接从 AWS 控制台的 SG 获取规则。

Same issue here.这里同样的问题。 After a while I noticed it picks 3 randoms subnets for the mount-points, one per AZ.过了一会儿,我注意到它为挂载点选择了 3 个随机子网,每个 AZ 一个。

I was unlucky one of these subnets didn't had the correct NACL.我很不幸,其中一个子网没有正确的 NACL。 After assigning the correct subnet/SG per mount point it worked immediately fine using DNS and IP.在为每个挂载点分配正确的子网/SG 后,它使用 DNS 和 IP 立即正常工作。

I got the Answer.我得到了答案。 This is happening when the subnet is blocking the flow.当子网阻塞流时,就会发生这种情况。 Go to subnets (which you have selected while creating the EFS) and allow the traffic to particular target systems.转到子网(您在创建 EFS 时选择的)并允许到特定目标系统的流量。

  1. checkthe EFS file systems subnet.检查 EFS 文件系统子网。
  2. go to subnet转到子网
  3. add a rule添加规则
  4. allow all-traffic ( you can give specific to your target systems)允许所有流量(您可以指定特定于您的目标系统)

This worked in my case这在我的情况下有效

Step 1 - Create a security group allowing NFS traffic inbound.第 1 步 - 创建一个允许 NFS 流量入站的安全组。 Step 2 - The EC2 which will be used for mounting - note down the respective region.第 2 步 - 将用于安装的 EC2 - 记下相应的区域。 Step 3 - Go to EFS - select FileSystem - Network - Edit the security group corresponding to the EC2 region (Step 2) - add security group from Step1步骤 3 - Go 到 EFS - select 文件系统 - 网络 - 编辑 EC2 区域对应的安全组(步骤 2) - 从 Step1 添加安全组

For me it was simply that the an EC2 disk was full .对我来说,这只是EC2 磁盘已满

I've cleaned it, reboot the instance and it worked.我已经清理了它,重新启动实例并且它起作用了。

To check your disk use: df -h or du -h --max-depth=1 /要检查您的磁盘,请使用: df -hdu -h --max-depth=1 /

The Connection timed out on EFS happens due to not adding the Security group with Port 2049 open to security group of the EC2 instance to the EC2 instance on which you are mounting the EFS. 由于未将安装了端口2049的安全组与EC2实例的安全组一起添加到要装载EFS的EC2实例,因此在EFS上发生Connection timed out Adding that sec grp will make the issue go. 添加秒grp将使问题继续下去。

Edit: 编辑:

Along with opening the port 2049 you need to add VPC's default security group for efs to connect to ec2 instance. 在打开端口2049的同时,您需要为efs添加VPC的默认安全组以连接到ec2实例。 As mentioned in the tutorial 正如教程中提到的那样

This ensures that the instance is a member of the security group that the Amazon EFS file system mount target will authorize for connection in Step 2: Create Your Amazon EFS File System. 这可确保实例是Amazon EFS文件系统装入目标将在步骤2:创建Amazon EFS文件系统中授权连接的安全组的成员。

PS: I forgot to add default security group to the instance thats why I was getting connection timeout error. PS:我忘了将默认安全组添加到实例,这就是我收到连接超时错误的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM