[英]Rails Deployment to AWS ElasticBeanstalk/RDS failing
我第一次在AWS上试用ElasticBeanstalk,并设法将我的应用程序环境显示在AWS控制台上,但是部署失败。 我的应用程序已连接到Postgres RDS实例。
日志告诉我,由于应用程序的hstore要求,导致部署失败。 如果该扩展名不存在,我将对其进行安装。
在我的应用程序中,我将此脚本设置作为rake任务:
# lib/tasks/db_enhancements.rake
####### Important information ####################
# This file is used to setup a shared extensions #
# within a dedicated schema. This gives us the #
# advantage of only needing to enable extensions #
# in one place. #
# #
# This task should be run AFTER db:create but #
# BEFORE db:migrate. #
##################################################
namespace :db do
desc 'Also create shared_extensions Schema'
task :extensions => :environment do
# Create Schema
ActiveRecord::Base.connection.execute 'CREATE SCHEMA IF NOT EXISTS shared_extensions;'
# Enable triagram
ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS pg_trgm SCHEMA shared_extensions;'
# Enable Hstore
ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS HSTORE SCHEMA shared_extensions;'
end
end
Rake::Task["db:create"].enhance do
Rake::Task["db:extensions"].invoke
end
Rake::Task["db:test:purge"].enhance do
Rake::Task["db:extensions"].invoke
end
我还要确保在我的ebextensions配置中包括postgres扩展名:
# .ebextensions/packages.config
packages:
yum:
postgresql93-devel: []
部署日志中出现的第一个错误是:
PG::UndefinedObject: ERROR: type "hstore" does not exist
有人可以帮助指导我看看我做错了什么吗?
* PS。 我正在使用EB CLI
我遇到了类似的问题,可以通过以下步骤解决:
识别您的VpcSecurityGroupId
aws rds describe-db-instances --db-instance-identifier <DBInstanceIdentifier>
sg-xxxxxxxxx
编辑您的安全组
现在转到AWS控制台/ VCP / 安全组并使用您的VpcSecurityGroupId搜索
在“入站规则”中,添加其他规则,其类型为:全部TCP,协议:TCP,端口范围:ALL和源:
0.0.0.0/0
连接到RDS控制台
与您的终点一起使用
psql --host=xxxxxxxxxx.xxxxxxxxxx.us-west-2.rds.amazonaws.com --port=5432 --username=dbxxxxx --dbname=ebxxx
为用户dbxxxxx写入密码,并且
ebdb=> CREATE EXTENSION hstore;
这就是全部。 :)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.