Eci*_*cil 12 redis amazon-elastic-beanstalk
如何在AWS ElasticBeanstalk上安装和配置Redis?有谁知道如何编写.ebextension脚本来实现这一目标?
Sam*_* H. 26
如果您使用ElastiCache(如RDS,但对于Memcached或Redis),接受的答案是很好的.但是,如果您要做的是告诉EB将Redis配置到EC2实例中,它会在其中旋转您的应用程序,您需要一个不同的配置文件,类似于这个要点:
packages:
yum:
gcc-c++: []
make: []
sources:
/home/ec2-user: http://download.redis.io/releases/redis-2.8.4.tar.gz
commands:
redis_build:
command: make
cwd: /home/ec2-user/redis-2.8.4
redis_config_001:
command: sed -i -e "s/daemonize no/daemonize yes/" redis.conf
cwd: /home/ec2-user/redis-2.8.4
redis_config_002:
command: sed -i -e "s/# maxmemory <bytes>/maxmemory 500MB/" redis.conf
cwd: /home/ec2-user/redis-2.8.4
redis_config_003:
command: sed -i -e "s/# maxmemory-policy volatile-lru/maxmemory-policy allkeys-lru/" redis.conf
cwd: /home/ec2-user/redis-2.8.4
redis_server:
command: src/redis-server redis.conf
cwd: /home/ec2-user/redis-2.8.4
Run Code Online (Sandbox Code Playgroud)
重要提示:该命令在按名称字母顺序执行的,所以如果你选择不同的名称比redis_build,redis_config_xxx,redis_server,确保他们是这样的,他们在你所期望的方式执行.
您的另一个选择是使用Docker将您的应用程序与Redis进行容器化,然后将您的应用程序部署为一些Docker容器,而不是您编写的任何语言.此处描述了为Flask应用程序执行此操作.
您可以将它全部集中到一个容器中并以这种方式部署,这样更容易,但扩展性不好,或者您可以使用AWS的Elastic Beanstalk多容器部署.如果您已经使用过docker-compose,则可以使用此工具将其docker-compose.yml转换为AWS所需的格式Dockerrun.aws.json.
Ter*_*ryB 14
AWS Elastic Beanstalk确实通过.ebextensions文件夹提供资源配置.基本上,除了应用程序之外,您还需要告诉Elastic Beanstalk您要配置的内容.用于配置为默认vpc.你需要
创建.ebextensions文件夹
添加一个elasticache.config文件
并包括以下内容.
Resources:
MyCacheSecurityGroup:
Type: "AWS::EC2::SecurityGroup"
Properties:
GroupDescription: "Lock cache down to webserver access only"
SecurityGroupIngress :
- IpProtocol : "tcp"
FromPort :
Fn::GetOptionSetting:
OptionName : "CachePort"
DefaultValue: "6379"
ToPort :
Fn::GetOptionSetting:
OptionName : "CachePort"
DefaultValue: "6379"
SourceSecurityGroupName:
Ref: "AWSEBSecurityGroup"
MyElastiCache:
Type: "AWS::ElastiCache::CacheCluster"
Properties:
CacheNodeType:
Fn::GetOptionSetting:
OptionName : "CacheNodeType"
DefaultValue : "cache.t1.micro"
NumCacheNodes:
Fn::GetOptionSetting:
OptionName : "NumCacheNodes"
DefaultValue : "1"
Engine:
Fn::GetOptionSetting:
OptionName : "Engine"
DefaultValue : "redis"
VpcSecurityGroupIds:
-
Fn::GetAtt:
- MyCacheSecurityGroup
- GroupId
Outputs:
ElastiCache:
Description : "ID of ElastiCache Cache Cluster with Redis Engine"
Value :
Ref : "MyElastiCache"
Run Code Online (Sandbox Code Playgroud)
参考自:"如何将ElasticCache资源添加到Elastic Beanstalk VPC" http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-environment-resources-elasticache.html
| 归档时间: |
|
| 查看次数: |
12762 次 |
| 最近记录: |