In this article we are going to cover How To Create Aurora MySQL RDS in AWS and Connect Aurora MySQL RDS Instance Using EC2 Instance.
Table of Contents
What is Amazon Aurora ?
Amazon Aurora is a fully managed, highly available, and scalable relational database service offered by Amazon Web Services (AWS). It is compatible with both MySQL and PostgreSQL and provides several benefits over traditional database management systems, including high performance, automatic failover, and seamless scaling capabilities. In this article, we’ll focus specifically on Amazon Aurora for MySQL, and the best part is, all the steps we’ll cover can be done without incurring any extra costs because they’re eligible for the Free Tier.
Key Features of Aurora MySQL RDS
- High Availability: Aurora MySQL RDS is designed for high availability with automatic failover. It replicates your database across multiple Availability Zones (AZs), ensuring that if one AZ goes down, your database remains accessible.
- Performance: Aurora is known for its excellent performance. It uses a distributed, SSD-backed storage layer and a database volume that auto-scales up to 64TB per database instance.
- Replication: Aurora MySQL supports read replicas, allowing you to offload read traffic from your primary instance and distribute it across multiple replicas to improve read performance.
- Security: Aurora provides several security features, including encryption at rest and in transit, support for IAM authentication, and integration with AWS Identity and Access Management (IAM) for fine-grained access control.
- Backup and Restore: Automated backups and database snapshots make it easy to recover from accidental data loss or corruption.
- Scalability: Aurora MySQL RDS allows you to scale your database up or down based on your workload. You can also add read replicas to handle increased read traffic.
Prerequisites
Before starting this tutorial, you will need:
- You’ll need an Amazon Web Services (AWS) account. If you don’t have one, you can sign up for a free AWS account.
- Basic knowledge of AWS services and concepts.
Create Aurora MySQL RDS in AWS
- Sign in to the AWS Console:- Open a new web browser window, and go to the AWS Management Console. In the console, type RDS in the search bar and choose RDS under Services to access the Amazon RDS console. This way, you can keep this guide open while working in the AWS console. Just remember, all of this won’t cost you anything extra since it’s eligible for the Free Tier. Follow below step’s:-
- At the top-right corner of the Amazon RDS console, choose the Region where you want to create your DB instance. Currently I’m using Region Singapore. Note: AWS Cloud resources are housed in highly available data center facilities in different areas of the world. You have the ability to choose which Region to host your Amazon RDS activity in.
- In the Create database section, choose Create database.
- Creation Method:
- You now have to select the database engine type, engine version, and the template. For this tutorial, choose the Standard create method and Aurora Mysql as the Engine type. Select the default DB engine version, and Production as the template.
- Settings:
- DB Instance Identifier: This is like giving your database a special name. For this tutorial, use “demo-db.” It should be unique in your chosen location.
- Master Username: Think of it as your username to access the database. We’ll use “admin” in this example.
- Master Password: It’s your secret code to get into the database. Make sure it’s between 8 to 41 characters long and doesn’t contain / (slash), ‘ (single quote), ” (double quote), or @ (at sign).
- Confirm Password: Just type your password again to make sure you didn’t make any mistakes.
- Cluster storage configuration:
- When it comes to configuring storage for an Amazon Aurora MySQL cluster, you benefit from a managed service that simplifies many aspects of storage management. However, it’s essential to understand how storage works within Aurora MySQL to make informed decisions. Here select the Aurora Standard option.
- Instance Configuration:
- DB Instance Class: Think of this as picking the size of your database computer. For this tutorial, just go with the choice called “db.r5.large,” which has 2 virtual CPUs and 16 GB of RAM and Select Memory optimized classes option. It’s good for the normal uses. To see a list of supported instance classes, see Amazon RDS Instance Types.
- Availability or Durability: (Multi-AZ Deployment) For this tutorial, you don’t need to think about this option. It’s a feature that provides high availability by creating a backup copy of your database in a different location. But it’s not necessary here, and it comes with an extra cost. So, just select skip it for now.
- Connectivity:
- Compute Resource: Ignore this option for the tutorial. It’s for connecting your database to another service (such as Bastion Host or Application Server) you might have. Not needed here. See Configure automatic network connectivity with an EC2 instance for more details.
- Network Type: Stick with the default choice, which is IPv4. It’s the standard way computers talk to each other over the internet. Amazon RDS supports both IPv4 & IPv6.
- Virtual Private Cloud (VPC): Choose “Default VPC.” This helps organize your resources in a secure and controlled network environment.
- DB Subnet Group: Go with the default subnet group. It helps manage where your data is stored securely.
- Public Access: Choose “No.” This means if anyone have URL of your database they can access it easily.
- VPC Security Group (Firewall): It’s like setting up a protective barrier around your database, and it will allow connections from your current device. (Remember one thing here add SSH Rule and Allow Port 3306 in VPC Security Group)
- Availability Zone: Select “No preference.” See Regions, Availability Zones, and Local Zones for more details.
- Database Port: Keep it at the default value, which is 3306. It’s the channel through which your database communicates with other services.
- Read replica write forwarding, Database authentication Leave this section default as it is.
- Monitoring:
- Keep the default Enable Enhanced monitoring unchecked for this tutorial. See Overview of Enhanced Monitoring for more details about monitoring.
- Additional configuration:
- Leave this section default as it is.
- And in the end, Choose Create database.
- After Creating an Aurora MySQL RDS Instance, Create a Ubuntu EC2 Machine with simple configuration and launch it.
Connect Aurora MySQL RDS Instance Using EC2 Instance
- After launcing the EC2 Instance, run below command
sudo apt update
- Now we run below command to install Aurora MySQL Client in our EC2 Instance (such as Bastion Host or Application Server)
sudo apt-get install mysql-client
- Now connect to a Aurora MySQL Instance, Here we using below command to connect. Also we substitute the DNS name (Endpoint, use your endpoint of DB) for your DB Instance for <endpoint> and the master user name (mine is admin) that you used for <mymasteruser>. Provide the master password that you add when we creating a database.
mysql -h <endpoint> -P 3306 -u <mymasteruser> -p
- After run the command we can see this as result
So, we successfully connect with our Aurora MySQL Instance.
Conclusion:
You have created, connected to a Aurora MySQL Instance with Amazon RDS. Amazon RDS makes it easy to set up, operate, and scale a relational database in the cloud. It provides cost-efficient and resizable capacity while managing time-consuming database administration tasks, freeing you up to focus on your applications and business.
Related Articles:
Setup Aurora PostgreSQL RDS in AWS [2 Steps]
Reference:
Great work