Skip to content

Commit 2a111f7

Browse files
committed
initial commit
1 parent e919cb4 commit 2a111f7

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Using the MariaDB JDBC driver with Amazon Aurora with MySQL compatibility
22

33
## Overview
4-
In this lab, we demonstrate how to use the MariaDB JDBC driver also known as MariaDB Connector/J, to connect to an [Amazon Aurora](https://aws.amazon.com/rds/aurora/) cluster. We use a combination of a small custom Java client program, AWS CLI and a terminal to showcase how the automatic failover capability of the connector allows switching rapidly and seamlessly between master and replica in a failover situation. You can have a quick read through of the following [blog post](https://aws.amazon.com/blogs/database/using-the-mariadb-jdbc-driver-with-amazon-aurora-with-mysql-compatibility/) if you do not wish to complete the lab.
4+
In this lab, we demonstrate how to use the MariaDB JDBC driver also known as MariaDB Connector/J, to connect to an [Amazon Aurora](https://aws.amazon.com/rds/aurora/) cluster. We use a combination of a small custom Java client program, AWS CLI and a terminal to showcase how the automatic failover capability of the connector allows switching rapidly and seamlessly between primary and replica in a failover situation. You can have a quick read through of the following [blog post](https://aws.amazon.com/blogs/database/using-the-mariadb-jdbc-driver-with-amazon-aurora-with-mysql-compatibility/) if you do not wish to complete the lab.
55

66
## Learning objectives
77
In this lab you will learn the following:
@@ -79,15 +79,15 @@ We have just demonstrated how to use the MariaDB JDBC driver known as MariaDB Co
7979

8080
In the second part of this demo, we demonstrate how the MariaDB Connector/J failover capability works with Aurora automatic failover.
8181

82-
To do that, use the DbClient_QueryClusterNodes.java which is a modified version of the DbClient.java that connects to the database cluster and runs a query to read from the INFORMATION_SCHEMA table the endpoint (master or replica) to which the current connection is pointing to. As we can see from the screenshot below the current primary node (master) is auroradbnode-1-us-west-2a
82+
To do that, use the DbClient_QueryClusterNodes.java which is a modified version of the DbClient.java that connects to the database cluster and runs a query to read from the INFORMATION_SCHEMA table the endpoint (primary or replica) to which the current connection is pointing to. As we can see from the screenshot below the current primary node (primary) is auroradbnode-1-us-west-2a
8383

84-
![alt text](img/masterslave.png)
84+
![alt text](img/primaryreplica.png)
8585

8686
Now let’s try to run a query to inserting a record on the database. To better illustrate the failover scenario, we connect to each node endpoint separately and run queries to try adding data to the VENDORS table. That way, we can show that we can’t insert data to the database while connected to the replica endpoint because it has read-only permissions.
8787

88-
### Connecting to the master endpoint
88+
### Connecting to the primary endpoint
8989

90-
This time we use mysql client from a terminal to connect to the master node of our database. The same can also be done with the java client program.
90+
This time we use mysql client from a terminal to connect to the primary node of our database. The same can also be done with the java client program.
9191

9292
mysql -u auroradbtest -h auroradbnode-1-us-west-2a.cgdued2pbbld.us-west-2.rds.amazonaws.com -p
9393
Enter password:
@@ -176,11 +176,11 @@ Note that the above command should return a json format key-value output with de
176176
"DBClusterIdentifier": "auroradbcluster-us-west-2",
177177
...
178178

179-
If we re-run our java client program DbClient_QueryClusterNodes.java again we can see that the previous master node (auroradbnode-2-us-west-2a)is now a replica while the previous replica (auroradbnode-2-us-west-2b) has been promoted to master. See screenshot below.
179+
If we re-run our java client program DbClient_QueryClusterNodes.java again we can see that the previous primary node (auroradbnode-2-us-west-2a)is now a replica while the previous replica (auroradbnode-2-us-west-2b) has been promoted to primary. See screenshot below.
180180

181181
![alt text](img/failover.png)
182182

183-
Similarly, if we rerun the insert query to add data to the VENDORS table while connected to the previous replica endpoint which has now been promoted to master, we are able to successfully add record to the table as shown from the output below.
183+
Similarly, if we rerun the insert query to add data to the VENDORS table while connected to the previous replica endpoint which has now been promoted to primary, we are able to successfully add record to the table as shown from the output below.
184184

185185
mysql -u auroradbtest -h auroradbnode-2-us-west-2b.cgdued2pbbld.us-west-2.rds.amazonaws.com -p
186186
Enter password:

img/failover.png

-596 Bytes
Loading

img/masterslave.png

-68.8 KB
Binary file not shown.

img/primaryreplica.png

66.9 KB
Loading

0 commit comments

Comments
 (0)