简体   繁体   English

如何在运行 AWS Linux 2 的 AWS Elastic Beanstalk 上配置 Linux 交换空间?

[英]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. BuildfileProcfile不适合。 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.

相关问题 运行 AWS Deep Learning Base AMI (Amazon Linux 2) 时,如何在 Elastic Beanstalk 中设置 WSGI? - How do I set up WSGI in Elastic Beanstalk when running AWS Deep Learning Base AMI (Amazon Linux 2)? 如何测试已安装的全局软件包在运行Linux Ubuntu的Elastic Beanstalk中是否正常工作 - How do I test if an installed global package is working in Elastic Beanstalk running Linux Ubuntu 如何在Linux环境中将.NET(C#)程序发布到AWS BeanStalk? - How to publish a .NET (C#) program to AWS BeanStalk in a Linux environment? 在 Linux 上的 AWS Elastic Beanstalk 中部署多个 ASP.NET 核心应用程序(使用 Kestrel 服务器) - Deploying Multiple ASP.NET Core apps in AWS Elastic Beanstalk on Linux (Use Kestrel Server) 如何在AWS Elastic beantalk上安装清漆缓存? - How to install varnish cache on AWS elastic beanstalk? 如何在Linux上检索交换空间的详细用法 - How can I retrieve detailed usage of swap space on linux 如何在AWS上配置d2.xlarge linux实例 - How to configure d2.xlarge linux instance on AWS Elastic Beanstalk 上的 PostgreSQL (Amazon Linux 2) - PostgreSQL on Elastic Beanstalk (Amazon Linux 2) 在使用 AWS Elastic Beanstalk 创建实例时运行命令 - Running commands upon creation of instances using AWS Elastic Beanstalk 在AWS Elastic Beanstalk上连接到Mysql - Connecting to Mysql on AWS Elastic Beanstalk
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM