I'm new to AWS services and I'm trying to deploy a simple Django app to Elastic Beanstalk. I found this documentation that says "to decouple your database instance from your environment, you can run a database instance in Amazon RDS and configure your application to connect to it on launch."
I followed this documentation to set up a PostgreSQL DB and uploaded my source code. When I deployed the project, the health check passed. So I tried to follow the URL to my site, and it just tries to load forever.
I checked the error logs (/var/log/httpd/error_log) and found OperationalError: (2013, "Lost connection to MySQL server at 'reading initial communication packet', system error: 0").
Why is it trying to connect to a MySQL when I want to use the PostgreSQL database?
Related
I am working on a project, where I want to replicate data from a source Aurora Mysql to Kinesis with AWS data migration service (DMS).
I am able to connect to source Mysql DB from mysql command and can see whole database:
mysql --host=<host>.amazonaws.com --port=8200 --user=<user> -p
But when I am starting replication task of DMS, DMS is giving connection issue with source DB. Connection with destination (Kinesis) is fine.
Testing connection for source DB from DMS, giving error:
Test Endpoint failed: Application-Status: 1020912, Application-Message: Cannot connect to ODBC provider ODBC general error., Application-Detailed-Message: RetCode: SQL_ERROR SqlState: HY000 NativeError: 2003 Message: [unixODBC][MySQL][ODBC 8.0(w) Driver]Can't connect to MySQL server on '.compute-1.amazonaws.com' (110)
I tried from AWS docs but I am not able to figure out the issue. In the network ACL of VPC, I have allowed ALL incoming traffic for its VPC.
Faced the same issue, not sure if you have figured out the solution. Network setup was fine, was using the same VPC for both RDS and DMS Replication instance, there was no issue with security group, however the issue was with the version of DMS.
RDS MySQL version is 5.7, the ODBC driver present in the higher version doesn't seem to work with the RDS instance or probably something is limiting connection to RDS MySQL 5.7 in DMS, launched a new replication instance in DMS with version 3.3.3 and the DB connectivity worked fine, also data movement is happening fine
Problem
I launched a MySQL RDS instance and was able to successfully connect to it using MySQL Workbench. However, I am still not able to connect to it from my local workstation using the following URI:
'mysql+pymysql://user:password#db_identifier.XXXXXXXXXX.us-east-1.rds.amazonaws.com:3306/db_name'
or the same URI without the port:
'mysql+pymysql://user:password#db_identifier.XXXXXXXXXX.us-east-1.rds.amazonaws.com/db_name'
The error that I receive when I specify this as my database URI and execute a db.create_all() command is:
sqlalchemy.exc.OperationalError:
(pymysql.err.OperationalError)
(2003, "Can't connect to MySQL server on 'db_identifier.XXXXXXXXXX.us-east-1.rds.amazonaws.com'
([WinError 10060] A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection failed because
connected host has failed to respond)")
Question
What can I do to connect using pymysql? And why would it connect with MySQL Workbench and not through this URI?
Context
I am following the tutorial here. This uses SQLAlchemy to execute the SQL statements in Python.
The RDS instance (and its associated subnet/VPC) have the following:
a security group open on port 3306
NACL rules that allow incoming and outgoing traffic
Public Accessibility set to "Yes"
Check my answer on this post, it could be something about the "Public accesibility" option in your rds "Connectivity and Security" section as described here;
https://stackoverflow.com/a/63514997/2934184
We have create private cloud instance but I am unable to connect to it using MYSQL workbench, php or a ODBC client.
From the same compute instance I can connect using mysql -h IP -u user -p *****. With GCP services I usually find gotcha in some document and I have tried digging everything possible. Here below error from a ODBC client:
BIP2393E: Database error: ODBC return code '-1' from data source ''DEVA'' using ODBC driver manager ''/opt/iib-10.0.0.20/ie02/lib/libodbcinterface.so''.
The integration node received an error when processing a database operation. The ODBC return code was '-1'. See the following messages for information obtained from the database about this error.
Use the following messages to determine the cause of the error. Typical problems are an incorrect data source, or table names. Correct either the database or the integration node configuration. Use the mqsicvp command to test connectivity to this database.
BIP2322E: Database error: SQL State ''HY000''; Native Error Code '2003'; Error Text ''[unixODBC][MySQL][ODBC 5.3(a) Driver]Can't connect to MySQL server on '1x.1x.1x.1x' (110)''.
The error has the following diagnostic information: SQL State ''HY000'' SQL Native Error Code '2003' SQL Error Text ''[unixODBC][MySQL][ODBC 5.3(a) Driver]Can't connect to MySQL server on 'x.x.x.x' (110)''
This message may be accompanied by other messages describing the effect on the integration node itself. Use the reason identified in this message with the accompanying messages to determine the cause of the error. Use the mqsicvp command to test connectivity to this database.
If I try and use a local proxy I get below:
BIP8299I: User 'user' from security resource name 'BIGDEVA' will be used for the connection to datasource 'DEVA'.
BIP8290I: Verification passed for the ODBC environment.
2020/07/16 20:29:41 New connection for "sql-instance"
2020/07/16 20:31:49 couldn't connect to "sql-instance": dial tcp x.x.x.x:3307: connect: connection timed out
BIP2393E: Database error: ODBC return code '-1' from data source ''DEVA'' using ODBC driver manager ''/opt/iib-10.0.0.20/ie02/lib/libodbcinterface.so''.
The integration node received an error when processing a database operation. The ODBC return code was '-1'. See the following messages for information obtained from the database about this error.
Use the following messages to determine the cause of the error. Typical problems are an incorrect data source, or table names. Correct either the database or the integration node configuration. Use the mqsicvp command to test connectivity to this database.
BIP2322E: Database error: SQL State ''08S01''; Native Error Code '2013'; Error Text ''[unixODBC][MySQL][ODBC 5.3(a) Driver]Lost connection to MySQL server at 'reading initial communication packet', system error: 0''.
The error has the following diagnostic information: SQL State ''08S01'' SQL Native Error Code '2013' SQL Error Text ''[unixODBC][MySQL][ODBC 5.3(a) Driver]Lost connection to MySQL server at 'reading initial communication packet', system error: 0''
This message may be accompanied by other messages describing the effect on the integration node itself. Use the reason identified in this message with the accompanying messages to determine the cause of the error. Use the mqsicvp command to test connectivity to this database.
Private cloud instance I meant that the network it sits in has no internet access, I guess it was not needed. Subnet A holds the client VM and Subnet B holds the DB instance and they have SA account based firewall rules. Though we found the issue as the firewall was open on service accounts on the VM so using a mysql client was working but apparently GKE POD subnet need it's own firewall rules and it doesn't inherit VM SA account/tag rules whereas a standalone docker container on it's own does.
I've been successfully using the Google cloud_sql_proxy on multiple Compute Engine instances for some time, until today, one instance at a time, the proxy started to show the following error pattern:
2017/05/30 13:28:07 New connection for "project-id-1234:us-central1:sql_instance"
2017/05/30 13:28:07 couldn't connect to "project-id-1234:us-central1:sql_instance": Post https://www.googleapis.com/sql/v1beta4/projects/project-id-1234/instances/sql_instance/createEphemeral?alt=json: stream error: stream ID 1; PROTOCOL_ERROR
2017/05/30 13:28:41 New connection for "project-id-1234:us-central1:sql_instance"
2017/05/30 13:28:41 Thottling refreshCfg(project-id-1234:us-central1:sql_instance): it was only called 33.490705951s ago
2017/05/30 13:28:41 couldn't connect to "project-id-1234:us-central1:sql_instance": Post https://www.googleapis.com/sql/v1beta4/projects/project-id-1234/instances/sql_instance/createEphemeral?alt=json: stream error: stream ID 1; PROTOCOL_ERROR
When trying to connect directly to MySQL (while using the proxy) I get error 2013 (HY000):
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0 "Internal error/check (Not system error)"
What I've tried
Restarting the cloud_sql_proxy yielded a temporary fix until finally both my Compute Engine instances are unable to connect to my Cloud SQL instance and the proxies show only this result.
Restarting the Cloud SQL instance and both Compute Engine instances.
Eliminating the proxy: I added the appropriate networks to my SQL instance's Authorized Networks, and updated all applications to use the public IP. This restored functionality to my production apps, but now I'm using a public connection instead of local/proxy.
Some research
I came across a similar issue relating to Google Cloud SQL that yielded the same MySQL error above, but it appears to have only affected connecting to Cloud SQL from external, non GCE/GKE networks.
A few others have reported the same issue also started for them this morning on the Google Cloud SQL Discuss group.
My team started seeing the same issue appear today, with GKE managed servers. Same as you saw: restarts of servers and DB did nothing.
We tried doing an update of the version of Google Cloud Proxy we were using from v1.05 to v1.09 and the problem went away (for now).
I know that's not much of an explanation but give it a try to see if that helps you.
I've got a a Rails app configured and working with MySql2 gem. I've got it successfully deployed with K8s on GKE. I've got my service account set up to have access to all things GKE GCE and SQl related. I've given the GKE permissions to SQL. I've followed this strictly:
https://github.com/GoogleCloudPlatform/container-engine-samples/tree/master/cloudsql
I still am getting this error when I pull the app up in a browser:
"Lost connection to MySQL server at 'reading initial communication packet', system error: 0"
From what I understand this indicates that the proxy does not have access to the gcloud SQL instance.
Please, it's been days! I need help! Don't even know how to trouble shoot!
Thanks in advance