[英]How do I configure Linux swap space on AWS Elastic Beanstalk running AWS Linux 2?
The answer to Can I configure Linux swap space on AWS Elastic Beanstalk?我可以在 AWS Elastic Beanstalk 上配置 Linux 交换空间吗? (from 2016) shows how to configure Linux swap space for an AWS Elastic Beanstalk environment using .ebextensions
configuration files. (从 2016 年开始)展示了如何使用.ebextensions
配置文件为 AWS Elastic Beanstalk 环境配置 Linux 交换空间。
However, the AWS docs Customizing software on Linux servers has this note for the newer Amazon Linux 2 platforms:但是, Linux 服务器上的 AWS 文档定制软件针对较新的Amazon Linux 2平台有此说明:
On Amazon Linux 2 platforms, instead of providing files and commands in.ebextensions configuration files , we highly recommend that you use Buildfile.在 Amazon Linux 2 平台上,我们强烈建议您使用 Buildfile,而不是在 .ebextensions 配置文件中提供文件和命令。 Procfile, and platform hooks whenever possible to configure and run custom code on your environment instances during instance provisioning. Procfile 和平台挂钩尽可能在实例供应期间在您的环境实例上配置和运行自定义代码。
How do I configure swap space using this more modern configuration approach?如何使用这种更现代的配置方法配置交换空间?
Buildfile
and Procfile
are not suited for that. Buildfile
和Procfile
不适合。 They serve different purposes - running short and long running commands.它们有不同的用途——运行短期和长期运行的命令。
I would use the platform hooks for that.我会为此使用平台挂钩。 Specifically, prebuild
:具体来说, prebuild
:
Files here run after the Elastic Beanstalk platform engine downloads and extracts the application source bundle, and before it sets up and configures the application and web server .此处的文件在 Elastic Beanstalk 平台引擎下载和提取应用程序源包之后,在它设置和配置应用程序和 web 服务器之前运行。
The rationale is that it's better to create swap now, before the application starts configuring.理由是最好在应用程序开始配置之前立即创建交换。 If the swap creation operation fails, you get notified fast, rather then after you setup your application.如果交换创建操作失败,您会很快收到通知,而不是在您设置应用程序之后。
From the SO link, you could put 01_add-swap-space.sh
into .platform/hooks/prebuild/
folder.从 SO 链接,您可以将01_add-swap-space.sh
放入.platform/hooks/prebuild/
文件夹。 Please make sure that 01_add-swap-space.sh
is executable ( chmod +x
) before you package your appliaction into a zip.在您将 package 应用到 zip 之前,请确保01_add-swap-space.sh
是可执行的( chmod +x
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.