Visitor Counter

Visitor Counter

Tuesday, May 12, 2020

Build DB Server and Interact With DB Using an App





What IS DB?

The relational databases are what most of us or all used to. They've been around since the 1970s.AWS has come in six different Variations relational database services, it has two key features. We've got multi-AZ which is for disaster recovery and then we've got read replicas which are for performance.multi-AZ Disaster Recovery read replicas performance

 

These are the six different relational databases on AWS

  • Microsoft sequels server

  • Oracle

  • my SQL Server

  • PostgreSQL

  • Aurora

  • MariaDB


What are the Benefits

  • Easy to administer

  • Highly scalable

  • Available and durable

  • Fast

  • Secure

  • Inexpensive




RDS Have Two Key Features

Multi-AZ - Disaster Recovery

Read Replicas - For Pereformenceses

 

Multi-AZ



Multi-AZ - Disaster Recovery

In the above example. I've got my example D.B. (There are Two AZ's)
So we've got our Easywto instance up the top and it connects into our databases using a connection and there is the address US East1.rds.amazonaws.com, Amazon host this DNS record and they point it at a database a primary database as they've pointed at it's in its internal IP address. For some reason we lost our Primary DB Amazon would detect that and they'd automatically update the DNS to point to the secondary. So you don't need to go in and change IP addresses or anything like that All you have to do is pointing out to this DNS address an Amazon will go in and update that DNS address with the new IP address. So failover is automatic with Multi-AZ




Read Replicas



Read Replicas - For Pereformenceses

In the above example. I've got my example D.B. (There are Two AZ's) We've got our Easytwo instances and they're pointing off to our primary instance using this connection .and what happens is that every time you add Data to that database that wright is going to be replicated to another database. It's a good perfect copy of the other database but it's a replica. Now if we lose our primary database for whatever reason yet, there's no automatic failover from one to the other. What you would have to do is you'd have to go in and have to create a new URL and then you'd have to update your Easytwo instances to point to the Read Replica.



This is the Scenario






After configuring everything it should be like this





In this scenario, we are going to create a Database with the subnet groups, Backup DB that is in another AZ. Using a Web interface we are going to update the DB.



To do this you have to log in to your Amazone account

 

 


Creating the VPC Security group






To do this we have to Create a VPC Security group

In the VPC Select Create Security group

In the VPC Select the VPC that you want to add to the Security Group

 

After Creating the Security Group Add an Inbound Rule the VPC to do that select the VPC Menu from below menu select Inbound rules and select Edit Inbound Rules and add the Below details

Type -: MYSQL/AURORA

Select the Web Security Group


Here what we are doing is We are allowing (Talke) to the  Web Security group into the DB Security Group



Creating the DB Subnet Groups

Now We have to create the Database to do that from the services under data base select RDS

Then Select DB Subnet Group this

To create the Subnet Group Add the details below

Name -: DBSubnetGroup ( Do not keep space you won't be able to create it )

Description -: DB Subnet Group

Under Add subnets

Availability zones   Add the Two Availability zones  (That suite for your Region)

Subnets Add the 2 Different Subnets 

Then Select Create 

 

 

Creating the DB

After Creating the DB Subnet Group Now we have to create the DB To do That in the same window Top left conner Select Databases

In this Window, We are Going to Select the DB Platform and we have select it as MYSQL

 

In the settings add the Details below to Create the DB

We will select the Production Template - It will give us the High availability, Fast Consistency performance, and High performing disk. This will give you the Multi-AZ

DB Instance identifier -: lab-db (RDS Instances name )

Master Username -: master

Master Password -: password (you can give any password you like )

DB Instance Class -: Burstable classes (includes t Classes)

from the drop-down menu select-: db.t3.micro

In Storage

Storage Type General purpose (SSD)

Allocated Space 20 GB

Keep these setting as the default 

Enable Storage Autosacaling- This means that you can add storage as run out of space

 We can Specify the maximum storage that we are going to use 

 

Under the Connectivity

Select The VPC-: LAB VPC

Subnet Group -: dbsubnetgroup (The subnet we have created earlier )

VPC Security Group Select Chose existing Group

From the list select DB Security Group (Do not select two)

Initial Database Name -:lab - If do not configure an Initial Database name Amazon RDS does not create the Database name for us and we need to use PHPMyAdmin or some way to Provisig or using sequel queries to create the database.

Untick  Enable automatic backup (Not Recommended at all we should Keep this tick for quick deploy we will untick it now )

Untick Enable Enhanced monitoring

Here you will be able to see the cost for your DB with details 

Keep all the setting as default and select Create

DB will be created and if you Click the lab-db you will be able to see the status of the DB


It will take a few minutes and there will be 3 stages Creating Modifying and Available

When the staus change to available it will be ready to use 

Copy the Endpoint Link the Highlighted one This will help you to connect to the RDS from the Web interface 

 

 

 

Login to the DB using web Interface 

Get the Incance IP address  Open a new tab and  enter the Instance IP address

 

After You got the web interface Select RDS in the web page from top  Next to the AWS logo

then enter the details 

Endpoint the Link that you have copied from the database

Database name -: lab

Username-: master

Password -: Password

After adding all the details Click Submit

It will take 10 seconds  then You will get the above page as DB you will be able to add details for this DB

Click Add contact to add the details

After adding the Contact details 

 

 

 

Problems

I have seen one Issue with this database that is we can add Characters to the Number field as you can see for the Phone number I was able to add Characters.  In the Email also it does not Check, Users can add anything.

 




How would It help us in Real-world AWS RDS is the easy way to deploying a DB cause we do not wont to worry about the Instances cause Amazone do the Patching and updating. We have to worry about our DB only. It also supports most database Platforms.


-------Important---------

Amazone RDS is not Serverless

Aurora Serverless is Serverless services






References -: 

https://aws.amazon.com/rds/

 

https://aws.amazon.com/rds/features/multi-az/

 

https://aws.amazon.com/rds/features/read-replicas/




No comments:

Post a Comment

Click hear to Visit my Facebook