AWS 自动缩放
AWS Auto-Scaling
我是第一次尝试 AWS 自动缩放,据我所知它会创建实例,例如如果我的 CPU 利用率达到我定义的临界水平。
所以我很好奇,午餐后我花了相当多的时间来配置它和复制数据,如果 AWS 自动扩展我的实例,它将如何配置新实例并将数据移动到它?
您不能在属于自动缩放组的实例上存储您想要保留的任何数据(您可以,但您会丢失它)。
有(至少)两种方法可以回答您的问题:
- 创建一个 'golden image',换句话说 spin-up 一个实例,对其进行配置,安装软件等,然后将其保存为 AMI(亚马逊机器映像)。然后告诉自动缩放组在每次实例启动时使用该 AMI - 启动时它将是 pre-configured。
- 在实例上放置一个脚本,告诉实例在启动时如何配置自身(在用户数据中)。所以基本上每次扩展实例时,它都会运行脚本并执行配置自身所需的所有步骤。
至于您的数据,最佳做法是将您想要保留的任何数据存储在 不在 实例上的数据库或对象存储中 - 比如 RDS, DynamoDB 甚至 S3 对象。
您还可以使用 AWS EFS,将 EC2 实例将共享的 data/scripts 存储在那里,并在每次通过 /etc/fstab 创建新的 EC2 实例时自动挂载它。
将 EFS 配置为挂载到 EC2 实例 (/etc/fstab) 后,您应该创建一个新的 AMI,并使用这个新的 AMI 创建一个新的 Launch Configuration 和 AutoScaling Group,以便新实例自动挂载您的 EFS 并能够使用该共享数据。
https://aws.amazon.com/efs/faq/
Q. What use cases is Amazon EFS intended for?
Amazon EFS is designed to provide performance for a broad spectrum of
workloads and applications, including Big Data and analytics, media
processing workflows, content management, web serving, and home
directories.
Q. When should I use Amazon EFS vs. Amazon Simple Storage Service (S3)
vs. Amazon Elastic Block Store (EBS)?
Amazon Web Services (AWS) offers cloud storage services to support a
wide range of storage workloads.
Amazon EFS is a file storage service for use with Amazon EC2. Amazon
EFS provides a file system interface, file system access semantics
(such as strong consistency and file locking), and
concurrently-accessible storage for up to thousands of Amazon EC2
instances. Amazon EBS is a block level storage service for use with
Amazon EC2. Amazon EBS can deliver performance for workloads that
require the lowest-latency access to data from a single EC2 instance.
Amazon S3 is an object storage service. Amazon S3 makes data available
through an Internet API that can be accessed anywhere.
https://docs.aws.amazon.com/efs/latest/ug/mount-fs-auto-mount-onreboot.html
You can use the file fstab to automatically mount your Amazon EFS file
system whenever the Amazon EC2 instance it is mounted on reboots.
There are two ways to set up automatic mounting. You can update the
/etc/fstab file in your EC2 instance after you connect to the instance
for the first time, or you can configure automatic mounting of your
EFS file system when you create your EC2 instance.
我建议使用共享数据容器,如果它是更新的数据并且可能正在旋转的所有实例都需要更新的数据。
如果它是数据库数据,或者您可以将所需数据存储在数据库中,我会考虑使用 RDS。
如果静态数据仅用于配置转储或配置文件等未被 运行 实例更新的实例,那么我建议从 CloudFlare 中提取它们,否则无法从 iT 的 S3 中提取它们来自存储库。
祝你好运
我是第一次尝试 AWS 自动缩放,据我所知它会创建实例,例如如果我的 CPU 利用率达到我定义的临界水平。
所以我很好奇,午餐后我花了相当多的时间来配置它和复制数据,如果 AWS 自动扩展我的实例,它将如何配置新实例并将数据移动到它?
您不能在属于自动缩放组的实例上存储您想要保留的任何数据(您可以,但您会丢失它)。
有(至少)两种方法可以回答您的问题:
- 创建一个 'golden image',换句话说 spin-up 一个实例,对其进行配置,安装软件等,然后将其保存为 AMI(亚马逊机器映像)。然后告诉自动缩放组在每次实例启动时使用该 AMI - 启动时它将是 pre-configured。
- 在实例上放置一个脚本,告诉实例在启动时如何配置自身(在用户数据中)。所以基本上每次扩展实例时,它都会运行脚本并执行配置自身所需的所有步骤。
至于您的数据,最佳做法是将您想要保留的任何数据存储在 不在 实例上的数据库或对象存储中 - 比如 RDS, DynamoDB 甚至 S3 对象。
您还可以使用 AWS EFS,将 EC2 实例将共享的 data/scripts 存储在那里,并在每次通过 /etc/fstab 创建新的 EC2 实例时自动挂载它。 将 EFS 配置为挂载到 EC2 实例 (/etc/fstab) 后,您应该创建一个新的 AMI,并使用这个新的 AMI 创建一个新的 Launch Configuration 和 AutoScaling Group,以便新实例自动挂载您的 EFS 并能够使用该共享数据。
https://aws.amazon.com/efs/faq/
Q. What use cases is Amazon EFS intended for?
Amazon EFS is designed to provide performance for a broad spectrum of workloads and applications, including Big Data and analytics, media processing workflows, content management, web serving, and home directories.
Q. When should I use Amazon EFS vs. Amazon Simple Storage Service (S3) vs. Amazon Elastic Block Store (EBS)?
Amazon Web Services (AWS) offers cloud storage services to support a wide range of storage workloads.
Amazon EFS is a file storage service for use with Amazon EC2. Amazon EFS provides a file system interface, file system access semantics (such as strong consistency and file locking), and concurrently-accessible storage for up to thousands of Amazon EC2 instances. Amazon EBS is a block level storage service for use with Amazon EC2. Amazon EBS can deliver performance for workloads that require the lowest-latency access to data from a single EC2 instance.
Amazon S3 is an object storage service. Amazon S3 makes data available through an Internet API that can be accessed anywhere.
https://docs.aws.amazon.com/efs/latest/ug/mount-fs-auto-mount-onreboot.html
You can use the file fstab to automatically mount your Amazon EFS file system whenever the Amazon EC2 instance it is mounted on reboots. There are two ways to set up automatic mounting. You can update the /etc/fstab file in your EC2 instance after you connect to the instance for the first time, or you can configure automatic mounting of your EFS file system when you create your EC2 instance.
我建议使用共享数据容器,如果它是更新的数据并且可能正在旋转的所有实例都需要更新的数据。 如果它是数据库数据,或者您可以将所需数据存储在数据库中,我会考虑使用 RDS。
如果静态数据仅用于配置转储或配置文件等未被 运行 实例更新的实例,那么我建议从 CloudFlare 中提取它们,否则无法从 iT 的 S3 中提取它们来自存储库。
祝你好运