After the first look at Amazon Aurora database, let's learn some practical details. I would start with creating a new Aurora database instance.
1. Basic Concepts
Before creating the database instance, let me clarify some basic concepts:
Before creating the database instance, let me clarify some basic concepts:
- First, Aurora database is inherently a database(DB) cluster. It includes at least a primary instance which you can read/write data, and optionally 1-15 read-only replicas. AWSs creates replicas in different availability zones (AZs). Therefore, a typical Aurora DB Cluster looks like this:
What is Amazon Availability Zones (AZ)?
Answer: AWS Service location are composed of Regions and Availability Zones. Each region is a geographic area (or data center). Each region has multiple isolated locations know as Availability Zone. In other words, Availability Zones are in the same geographic location.
- Second, there are three types of end points for the database connection: cluster end point , instance endpoints and reader endpoint. The cluster endpoint connects to the current primary instance of the DB cluster. The instance endpoints are tied to a particular primary or replica instance. For an application, it's always recommended to use the cluster endpoint so that the connection can be maintained during the database fail-overs. The reader endpoint load-balances connections across the Aurora Replicas that are available in a DB cluster.
2. Create the Auroa DB Instance
Amazon documentation [2] has the detailed steps. I would not repeat here. However, let me highlight some important decisions that you need to make during the instance creation:
Amazon documentation [2] has the detailed steps. I would not repeat here. However, let me highlight some important decisions that you need to make during the instance creation:
- Specifying multiple AZ replications with the Multiple-Zone Deployment option: this is useful when you want to enable DB failover across different AZs.
- Differentiating DB Instance Identifier and DB Cluster Identifier: the cluster identified will be used for you to connect to the cluster endpoint which always points to a running primary instance.
- Creating Cross region read replicas: you can create cross region replicas for Aurora DBs with the Create Cross Region Read Replicas within the Instance Action Menu.
3. Connect to the Auroa Database
After the instance is created, you can use the cluster endpoint to connect to the database from your MySQL client shown as follows:
[ec2-user ~]$ mysql -h aws-aurora-cluster.cluster-cserhpfzdaax.us-east-1.rds.amazonaws.com -P 3306 -u oracle -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 242 Server version: 5.6.10 MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Why do I get the "ERROR 1045 (28000): Access denied for user 'auser'@'54.84.309.317' (using password: YES)" when connection to Aurora database?
Answer: You need to check the security group configuration on the endpoint. You need to allow access from the machine where you set up the connection.
Resources
- Rajdeep Singh,Setup AMAZON AURORA DB Cluster, July 30, 2015
- Amazon Documentation, Creating a DB Cluster and Connecting to a Database on an Amazon Aurora DB Instance