gpt4 book ai didi

amazon-vpc - 为 ECS 集群上的 EFS 卷指定正确的 AZ 挂载点 - CloudFormation

转载 作者:行者123 更新时间:2023-12-03 07:45:57 24 4
gpt4 key购买 nike

查看 this在 ECS 中挂载 EFS 卷以持久保存 docker 卷的示例,我不确定如何为实例所在的可用区提供正确的挂载点。我的堆栈中有两个可用区,需要插入正确的挂载点在 cfn-init 的这一部分中:

01_mount:
command: !Join [ "", [ "mount -t nfs4 -o nfsvers=4.1 ", !ImportValue '!Ref FileSystem', ".efs.", !Ref 'AWS::Region', ".amazonaws.com:/ /", !Ref MountPoint ] ]
02_fstab:
command: !Join [ "", [ "echo \"", !ImportValue '!Ref FileSystem', ".efs.", !Ref 'AWS::Region', ".amazonaws.com:/ /", !Ref MountPoint, " nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 0 0\" >> /etc/fstab" ] ]
03_permissions:
command: !Sub "chown -R ec2-user:ec2-user /${MountPoint}"

最佳答案

如果您在 VPC 中使用 DNS 设置并且在 VPC 配置中具备其他必要的先决条件,则挂载 EFS 文件系统时不再需要使用特定于可用区的挂载目标。

File system DNS name – Using the file system's DNS name is your simplest mounting option. The file system DNS name will automatically resolve to the mount target’s IP address in the Availability Zone of the connecting Amazon EC2 instance. You can get this DNS name from the console, or if you have the file system ID, you can construct it using the following convention:

file-system-id.efs.aws-region.amazonaws.com

(emphasis added)

http://docs.aws.amazon.com/efs/latest/ug/mounting-fs-mount-cmd-dns-name.html

此功能于 2016 年 12 月推出,距该服务发布预览版几个月后。以前,上面显示的主机名样式必须在前面加上您想要的可用区域。该选项仍然受支持,但该选项有效地消除了这种尴尬的配置要求,无论是在 docker 中还是在具有 fstab 安装的普通实例上。

请参阅引用页面,了解必须具备的 VPC 配置元素,此解决方案才能在您的 VPC 中运行。

关于amazon-vpc - 为 ECS 集群上的 EFS 卷指定正确的 AZ 挂载点 - CloudFormation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43619578/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com