Using an AWS Elastic Load Balancer for MySQL Cluster

1

I have a web server which connects to a MySQL cluster (it's Galera cluster)... the cluster works fine (if I update a record on the first instance of MySQL, it is automatically updated on the second instance). The problem is I need a load balancer between the web server and MySQL instances...

So What I have done is to setup an AWS Network Load Balancer (NLB works on Network Layer, TCP in my case)... I have added the 2 instances of MySQL to the NLB's Target group (their private IPs).

enter image description here

Now I go ahead an update the connection string in my Web Server to connect to the NLB:

<add name="MyDB" connectionString="Server=my-nlb-ap-southeast-2.amazonaws.com; Port=3306; Database=mydb; Uid=user1; Pwd=mypassword; Protocol=TCP" providerName="MySql.Data.MySqlClient"/>

But I get the following error:

[MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.] MySql.Data.MySqlClient.NativeDriver.Open() +1734 MySql.Data.MySqlClient.Driver.Open() +60 MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) +309
MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection() +18
MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() +290
MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() +151
MySql.Data.MySqlClient.MySqlPool.GetConnection() +60
MySql.Data.MySqlClient.MySqlConnection.Open() +1588
MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(DbConnection connection) +182
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)

When I try to connect to MySQL from my web server, I get the following:

enter image description here

enter image description here

This indicates that the web server is able to reach the MySQL instance through the NLB, but I don't know why the connection string is not working.

I have opened all the IPs on port 3306 , and I can connect to MySQL through NLB from my local computer which is not in the VPC:

enter image description here

But the web server connection string is not working...


I am not entirely sure if it's even possible to use an NLB for this purpose?

mysql
amazon-web-services
load-balancing
amazon-elb
asked on Stack Overflow Dec 16, 2019 by Hooman Bahreini • edited Aug 12, 2020 by Hooman Bahreini

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0