AWS - RDS - mysql instances

http://serverfault.com/questions/599421/highest-value-of-max-connections-in-aws-rds-micro-instance

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)
show variables like 'max_connect_errors'

Blocked because of many connection errors

many connection error
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:932)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:816)
org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Could not open connection
    org.springframework.orm.hibernate4.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:428)
    org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:372)
org.hibernate.exception.GenericJDBCException: Could not open connection
    org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
    org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
    org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
java.sql.SQLException: null,  message from server: "Host 'ip-10-248-46-25.ap-southeast-2.compute.internal' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"
    com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
    com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
    com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1104)
    com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2137)
Once this error happens can't access the database from same URL, but can be done from different URL.

Quick Fix

mysqladmin -h ssssss.ffffffff.ap-ffffff-2.rds.amazonaws.com -u root -p flush-hosts

Solution

By default, mysqld blocks a host after 10 connection errors. For more details on the same please refer to http://dev.mysql.com/doc/refman/5.0/en/blocked-host.html.
Can you try increasing the value of max_connect_errors to see if it resolves your issue? You can find more details for the same at http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_max_connect_errors. You can use the CLI for modifying the parameters as documentedathttp://docs.amazonwebservices.com/AmazonRDS/latest/CommandLineReference/CLIReference-cmd-ModifyDBParameterGroup.html
Follow these steps to increase the MySQL limits and avoid locking the database:
  1. Download the RDS Command Line Toolkit here
  2. Unzip the toolkit and add the following environment variables
    1. Add <unzipped_folder>/bin to the PATH variable
    2. AWS_RDS_HOME=<unzipped_folder>
    3. AWS_CREDENTIAL_FILE=<unzipped_folder>\credential-file-path.template
    4. Optionally, override the default region with EC2_REGION=<region> (e.g. us-west-1)
    5. JAVA_HOME=<JDK location>
  3. Enter a valid access key into the credental-file-path.template file 
    1. You can get the access key from the AWS console under "Security Credentials"
  4. In AWS Console, create a "DB Parameter Group" with the database parameters required
    1. Created one called "mysql-custom"
    2. Changed max_connect_errors=1000
    3. Changed max_connections=1000
  5. Open a command prompt
    1. Change the parameter group of a database with the command: rds-modify-db-instance finance101test --db-parameter-group-name=mysql-custom --region ap-southeast-2
  6. Restart(Reboot) the database
  7. Verify the changes by opening a MySQL command line (i.e. with Navicat) and typing: show variables like 'max_connect_errors';

References

Comments

Popular posts from this blog

API design best practices

DB Connection Issues

Reading Excel Sheet on client side and processing it