![](/img/trans.png)
[英]How do I read an CSV file in an EC2 instance folder as oppose to an S3 bucket in AWS?
[英]AWS S3 bucket is not remounting after restarting EC2 Instance
我使用S3fs将我的 S3 存储桶安装到我的 EC2 实例上,并且能够读取、写入我的 S3 存储桶。 但重启我的 EC2 实例后,S3 存储桶会自动卸载。 我发现要使其持久化并在每次重新启动时自动挂载,我们需要将以下条目添加到 /etc/rc.local
/usr/bin/s3fs myS3bucket -o use_cache=/tmp -o allow_other -o multireq_max=5 /myS3bucket
但它仍然没有在重新启动时安装。
你浏览过官方文档吗?
您还可以通过在 /etc/fstab 中输入以下行来在启动时挂载:
s3fs#mybucket /path/to/mountpoint fuse _netdev,allow_other 0 0
或者
(……)
注意 2:您可能还需要确保 netfs 服务在启动时启动
网络挂载首先需要网络访问。
我能够通过将其作为systemd
服务运行来使其工作。
创建服务文件 - /usr/lib/systemd/system/mybucket-mount.service
[Unit] Description = Mount S3 Bucket my-bucket Wants=network-online.target After=network.target network-online.target [Service] Type=oneshot RemainAfterExit=yes ExecStart = /usr/bin/s3fs my-bucket /MyBucketMount/ -o uid=500,gid=501,iam_role=MyRole,use_cache=/tmp,endpoint=ap-south-1,url=https://s3.amazonaws.com ExecStop=/bin/umount /MyBucketMount/ [Install] WantedBy = multi-user.target
创建链接
ln -sf /usr/lib/systemd/system/mybucket-mount.service /etc/systemd/system/multi-user.target.wants/mybucket-mount.service
启用服务
systemctl enable mybucket-mount.service
启动服务
systemctl start mybucket-mount.service
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.