👉Introduction
AWS RDS (Relational Database Service) is a managed database service provided by Amazon Web Services (AWS). It allows you to easily set up, operate, and scale relational databases in the cloud without needing to manage the underlying infrastructure.
Importance in Cloud Computing:
Simplicity: RDS simplifies database management tasks such as provisioning, patching, backup, and scaling, allowing developers to focus more on application development rather than database administration.
- Scalability: It offers scalable database solutions with options to increase compute and storage resources as your application demands grow, ensuring performance without downtime.
- Reliability: AWS manages critical database tasks such as backups, automatic failover, and recovery, enhancing the reliability and availability of your database deployments.
- Security: RDS integrates with AWS IAM (Identity and Access Management) for fine-grained access control, along with encryption at rest and in transit, ensuring data security compliance.
Cost-efficiency: With pay-as-you-go pricing and options like reserved instances, RDS optimizes costs by matching resources to actual usage, eliminating upfront hardware costs and maintenance overhead.
Creating an RDS (Relational Database Service) instance on AWS involves several straightforward steps through the AWS Management Console. Here’s a step-by-step guide:
Prerequisites
Have an AWS account. If you don’t have one, sign up here and enjoy the benefits of the Free-Tier Account
- On the AWS console, search for EC2 and click on it to open the EC2 console
2. Click on Launch instance and launch an instance with the following configuration:
Image: Amazon Linux 2 AMI
instance type: t2.micro
security group: Allow ssh(Port 22) and MySQL/Aurora(Port 3306)
DB Instance identifier — database-instance (You can set your own preferred DB Instance identifier)
Master username — rdsuser (You can set your own preferred Master username)
Master password — Pa55w0rd (You can set your own preferred Master password)
Instance configuration — db.t2.micro
Storage type — General Purpose SSD (gp2)
Allocated storage — 20
Enable storage autoscaling — uncheck
Existing security groups — remove the default and add the security group you used for the EC2 (Allows SSH and MYSQL/Aurora traffic)
Under Additional configuration, set up the following:
Initial database name — mydb
DB parameter group — default
Enable automated backups — uncheck
Leave all other settings as default
Scroll to the bottom and click on Create database
Create a connection to the Amazon RDS database from the EC2 instance
sudo su
3. Download some Linux packages
sudo amazon-linux-extras install epel -y
4. Install the MySQL repository package. Enter y wherever asked.
sudo yum install https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
5. Install the MySQL community server. Enter y wherever asked.
sudo yum install mysql-community-server
6. Verify the version for MySQL.
mysql --version
If all installed well, the command should show the MySQL version installed
7. Get your rds instance Endpoint. On the database instance console, under the connectivity tab, copy the Endpoint
8. Run the following command on the terminal: mysql -h <mysql-instance-dns\> -u <username> -p
In our case, it will be:
mysql -h database-instance.cfjitlrhaxvx.us-east-1.rds.amazonaws.com -u rdsuser -p
Press enter then enter the password
Create a Database, Table and Insert data for testing
- Create a database:
CREATE DATABASE SchoolDB;
2. You can see the created database through the following command:
SHOW databases;
3. Switch to the database named SchoolDB
use SchoolDB;
4. Create a sample table consisting of Subjects.
CREATE TABLE IF NOT EXISTS subjects (subject_id INT AUTO_INCREMENT,subject_name VARCHAR(255) NOT NULL,teacher VARCHAR(255),start_date DATE,lesson TEXT,PRIMARY KEY (subject_id)) ENGINE=INNODB;
5. Insert some details into the table:
INSERT INTO subjects(subject_name, teacher) VALUES ('English', 'John Taylor');
INSERT INTO subjects(subject_name, teacher) VALUES ('Science', 'Mary Smith');
INSERT INTO subjects(subject_name, teacher) VALUES ('Maths', 'Ted Miller');
INSERT INTO subjects(subject_name, teacher) VALUES ('Arts', 'Suzan Carpenter');
6. Let’s check the items we added into the table:
select * from subjects;
Congratulations! By following the steps in this guide, you’ve successfully connected your EC2 and RDS within Amazon Web Services. This connection acts like a superhighway between your computing power and your data storage, allowing your applications to run more efficiently. Now that you’ve set up this connection, you’re all set to manage your data and apps more smoothly within Amazon’s world. This link is key for seamless data operations and application performance. Keep exploring and using this powerful connection to innovate and create within the Amazon ecosystem. It’s your gateway to building robust and scalable systems, opening doors to endless possibilities within AWS.