0% found this document useful (0 votes)
35 views4 pages

DB Create

The document outlines the steps to set up an Amazon EC2 instance with Amazon Linux, configure security groups, and create an RDS database using MariaDB. It details the installation of Apache Tomcat 9, uploading necessary files, and linking the RDS database with the Tomcat application. Additionally, it includes instructions for creating a database and table within the RDS instance and accessing the application via a web browser.

Uploaded by

banda.aws09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views4 pages

DB Create

The document outlines the steps to set up an Amazon EC2 instance with Amazon Linux, configure security groups, and create an RDS database using MariaDB. It details the installation of Apache Tomcat 9, uploading necessary files, and linking the RDS database with the Tomcat application. Additionally, it includes instructions for creating a database and table within the RDS instance and accessing the application via a web browser.

Uploaded by

banda.aws09
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1) Create an instance with basic settings with amazon linux as its ami

2) Edit security group: inbound rule: “Custom TCP” “port 8080” “all ip’s” and “mysql/aurora(for
mysql)” “port 3306” “all ip’s”

3) Create a RDS Database


with settings: standard create
database engine:mariadb
template:free tier
settings:instance name: any name, username:anyname, password:anystrongpassword
instance configuration:default
storage:
availability and durability:
connectivity: don’t connect to ec2 resource
vpc:default, SG:default
public access:no
create database.
4) Install apache tomcat 9
search on google apache tomcat 9 and login to our instance from mobaxterm
go to that result and copy its link path of .tar extension
login into our instance.
TYPE THE FOLLOWING COMMANDS

sudo -i = for root user access


curl -O https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.91/bin/apache-tomcat-9.0.91.tar.gz
tar -xvf apache-tomcat-9.0.91.tar.gz

ls
mv apache-tomcat-9.0.91 /opt/
cd /opt

5) THEN UPLOAD THE mysql-connector.jar AND student.war FILE ON MOBAXTRIME THEN CHECK THE
CD HOME/EC2-USER DIRECTORY AND THEN MOVE INTO THE mysql-connector.jar(lib) AND
student.war(webapps)
cd /home/ec2-user/
mv mysql-connector.jar /opt/apache-tomcat-9.0.91/lib/
cd lib
mv student.war /opt/apache-tomcat-9.0.91/webapps/
cd webapps

6) Now we need to run the apache tomcat(in browser) but for that we need to install java amazon
corretto 11 (jdk11)
cd /opt/apache-tomcat-9.0.91/
ls
cd bin/
ls
yum search java
yum install java-11-amazon-corretto.x86_64 –y
bash catalina.sh start
(if it shows tomcat started then start browser and paste ip:8080/student of our instance and check)

7) Link our created RDS database with our instance in apache tomcat(database with student.war)
CREATE THE context.xml FILE if not present in /opt/apache-tomcat-9.0.91/conf/ AND
INSERT THE DATA ON THAT XML FILE (after 21st line)
cd /opt/apache-tomcat-9.0.91/conf/
vim context.xml (after line 20 or 21 ish after <context> to be exact)
<Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
maxTotal="100" maxIdle="30" maxWaitMillis="10000"
username="admin" password="Admin123" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://database-1.c3yqqwyeoe4f.ap-south-
1.rds.amazonaws.com:3306/studentapp"/>
And START THE TOMACAT USING COMMAND
cd /opt/apache-tomcat-9.0.91/bin/
bash catalina.sh start

8) Now that RDS database is linked to the tomcat, we need to create a database in the instance which
will be linked to the RDS database. For that we need to install mariabdb version 105

yum search maria


yum install mariadb105.x86_64 -y

9) To create a database inside RDS database from ec2 instance, we need to login into that database
through command and then perform some operation to insert/create a database and table.

mysql -h my-database-1.c9y4i026ihzh.ap-south-1.rds.amazonaws.com -u admin -pAdmin1234

MariaDB [(none)]> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| innodb |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.001 sec)

MariaDB [(none)]> create database studentapp;


Query OK, 1 row affected (0.005 sec)

MariaDB [(none)]> use studentapp;


Database changed
MariaDB [studentapp]> CREATE TABLE if not exists students(student_id INT NOT NULL
AUTO_INCREMENT,
-> student_age VARCHAR(3) NOT NULL,
student_name VARCHAR(100) NOT NULL,
-> student_addr VARCHAR(100) NOT NULL,
-> student_age VARCHAR(3) NOT NULL,
-> student_qual VARCHAR(20) NOT NULL,
-> student_percent VARCHAR(10) NOT NULL,
-> student_year_passed VARCHAR(10) NOT NULL,
-> PRIMARY KEY (student_id)
-> );
Query OK, 0 rows affected (0.007 sec)

MariaDB [studentapp]> show databases;


+--------------------+
| Database |
+--------------------+
| information_schema |
| innodb |
| mysql |
| performance_schema |
| studentapp |
| sys |
+--------------------+
6 rows in set (0.001 sec)

16. Run tomcat and then GO TO YOUR AWS instance and restart that instance, AND COPY PUBLIC IP AND
GO TO CHROME BROWSER fire FOLLOWING COMMAND
In mobaxterm:
cd /opt/apache-tomcat-9.0.91/bin/
bash catalina.sh start

In the browser:
http://13.201.85.99:8080/student/

You might also like