Arquivo da tag: AWS

AWS RDS PostgreSQL error “remaining connection slots are reserved for non-replication superuser connections”

Amazon has to set the number of connections based on each model’s right to demand a certain amount of memory and connections

MODEL      max_connections innodb_buffer_pool_size
---------  --------------- -----------------------
t1.micro   34                326107136 (  311M)
m1-small   125              1179648000 ( 1125M,  1.097G)
m1-large   623              5882511360 ( 5610M,  5.479G)
m1-xlarge  1263            11922309120 (11370M, 11.103G)
m2-xlarge  1441            13605273600 (12975M, 12.671G)
m2-2xlarge 2900            27367833600 (26100M, 25.488G)
m2-4xlarge 5816            54892953600 (52350M, 51.123G)

But if you want you can change the max connection size to custom by

From RDS Console > Parameter Groups > Edit Parameters,

You can change the value of the max_connections parameter to a custom value.

For closing the connections periodically you can setup a cron job some thing like this.
[code type=sql]
select pg_terminate_backend(procpid)
from pg_stat_activity
where usename = ‘yourusername’
and current_query = ‘
and query_start < current_timestamp - interval '5 minutes';

AWS ElasticBeanstalk And Rails

https://medium.com/@hugooodias/deploying-a-rails-app-to-amazon-elasticbeanstalk-in-2016-c4e833c687c0

https://hackernoon.com/how-to-setup-and-deploy-a-rails-5-app-on-aws-beanstalk-with-postgresql-redis-and-more-88a38355f1ea

https://medium.com/@jatescher/how-to-set-up-a-rails-4-2-app-on-aws-with-elastic-beanstalk-and-postgresql-3f9f29c046e2

Amazon – Create Image

create-image
[--dry-run | --no-dry-run]
--instance-id <value>
--name <value>
[--description <value>]
[--no-reboot | --reboot]
[--block-device-mappings <value>]
[--cli-input-json <value>]
[--generate-cli-skeleton <value>]

http://docs.aws.amazon.com/cli/latest/reference/ec2/create-image.html

Amazon – Fazendo as máquinas do EC2 dormirem

Primeiro instale a linha de commando: Linha de Comando

Ligando às 19h:
0 19 * * * ~/start_instances.sh.

# start_instances.sh
 
export AWS_ACCESS_KEY="UTHEENDZNAPPA20HAI11"
export AWS_SECRET_KEY="eij5ugaiphee6uusheg6eiVaiD0ein8moh7ieS0o"
 
aws ec2 start-instances i-912345ab i-812345bc

Desligando às 7h:
0 7 * * * ~/stop_instances.sh.

# stop_instances.sh
 
export AWS_ACCESS_KEY="UTHEENDZNAPPA20HAI11"
export AWS_SECRET_KEY="eij5ugaiphee6uusheg6eiVaiD0ein8moh7ieS0o"
 
aws ec2 stop-instances i-912345ab i-812345bc

Exemplo de CRONTAB:

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
0 7 * * * ~/stop_instances.sh
0 19 * * * ~/start_instances.sh

Referência