0% found this document useful (0 votes)
20 views19 pages

EC2 running notes and pratical implementation

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)
20 views19 pages

EC2 running notes and pratical implementation

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/ 19

============

EC2 Service

============

=> Elastic Compute Cloud

=> It is Most demanded service in AWS

=> It is Used to create Virtual Machines in AWS cloud

=> EC2 VM is called as EC2 instance

EC2 Instance = Computer / Server / VM / Virtual Machine / V Box

=> EC2 instance is re-sizable (we can change configuration based on demand)

=> EC2 is a paid service (hourly billing)

=> EC2 VM Minimum billing period is 1 hour

9:00 AM - 9:15 AM : 15 mins usage => 1 hour

9:30 AM - 9:40 AM : 10 mins usage => 1 hour

Note: To encourage beginners, AWS provided t2.micro/t3.micro for 1 year free

(Monthly 750 hours )

=> EC2 VM will have storage with EBS service


EC2 Windows VM : 30 GB (default)

EC2 Linux VM : 8 GB (default)

EBS Max Capacity: 16 TB

=> For EC2 VM, network will be provided by VPC service

=> For EC2 vm creation we will use AMI (Amazon Machine Image)

Note: AMI represents configuration required for machine

- Windows AMI

- Amazon Linux AMI

- Ubuntu AMI

- RedHAT AMI

=> To secure EC2 VM we will use Key-Pair (pem)

=> To allow incoming and outgoing traffic for EC2 we will use Security Group

Note-1 : One Key Pair we can use for multiple EC2 instances

Note-2 : One Security Group (SG) we can use for multiple EC2 instances.
===========================

Lab Practicals on EC2 VM

===========================

1) Create Key Pair (.pem file)

- public key (aws will keep it)

- private key (we will get it)

2) Create Security Group and update Inbound Rules to allow traffic

Windows RDP : 3389

Linux SSH : 22

HTTP : 80

HTTPS : 443

MySQL : 3306

3) Create EC2 Instance

- Select AMI

- Select Instance Type

- Select Key Pair

- Select Security Group

- Select EBS Storage

- Create it

===============================

Types of IP's in AWS Cloud


==============================

=> We have 3 types of IP's in AWS cloud

1) private ip

2) public ip

3) elastic ip

=> Private IP is a fixed IP in AWS. It is used for internal communication (With in VPC)

=> public ip is a dynamic IP in aws. It is used to connect with EC2 VM from outside.

=> When we restart our VM then public ip gets changed.

=> If we want fixed public ip then we need to use Elastic IP.

=> Elastic IPs are commercial (bill will be generated).

==============================

Lab Practicals on Elastic IP

=============================

Step-1 : Allocate Elastic IP (Getting from AWS)

Step-2 : Associate Elastic IP with EC2 VM

Step-3 : Restart VM and check public ip (it will not change)

Step-4 : De-Associate Elastic IP


Step-5 : Release Elastic IP to AWS (to avoid billing)

==============

What is EBS

==============

=> EBS stands for Elastic Block Store

=> It is block level storage device (Hard Disc / SSD)

=> EBS will be attached with EC2 instance.

=> EBS provides both primary and secondary storages for EC2 instances

=> In EBS we have 2 types volumes (Storages)

- Root Volume

- Additional Volume

Ntoe: When we launch EC2 instance by default we will get one Root volume.

=> Root volume is mandatory to launch EC2 instance.

=> If we remove root volume from EC2 then we can't start/use that instance.

=> Additional EBS volumes are optional devices (we can add/remove)
=> For windows VM, we will get 30 GB as default volume size.

=> For Linux VM, we will get 8 GB as default volume size.

Note: EBS volume can have upto 16 TB.

=> One EC2 VM can have multiple EBS volumes.

=> One EBS volume can be attached to one EC2 VM at a time..

=> EBS volumes are Availability Zone Specific...

Mumbai (ap-south-1)

=> ap-south-1a

=> ap-south-1b

=> ap-south-1c

=> If EC2 VM is created in ap-south-1a then our EBS volume also should be there in ap-
south-1a then only we can attach it.

====================

EBS Volume Types

===================

=> We have 5 types of EBS volumes


1) General Purpose (Min: 1 GiB, Max: 16384 GiB)

2) Provisioned IOPS (Min: 4 GiB, Max: 16384 GiB)

3) COLD HDD (Min: 125 GiB, Max: 16384 GiB)

4) Throughput Optimized (Min: 125 GiB, Max: 16384 GiB)

5) Magnetic (Min: 1 GiB, Max: 1024 GiB)

=========================

Lab Task on EBS Volumes

=========================

1) Create EC2 VM (VM-1) (amazon linux ami) - we will get EBS root vol 8 GB

2) Create Additonal EBS Vol with 10 GB (check AZ)

3) Attach Additional Volume to EC2 VM-1

Note: Now EC2 Vm-1 will have 2 EBS volumes (root vol + additional vol)

4) Connect with VM-1 and check volumes attached

$ lsblk
4) Store data (files) into EBS Additional Volume using below commands

$ sudo mkfs -t ext4 /dev/xvdb

$ mkdir dir1

$ sudo mount /dev/xvdb dir1

$ cd dir1

$ sudo touch f1.txt f2.txt

5) Detach Additional Volume from EC2 VM-1

6) Create New EC2 VM (VM-2) and attach EBS Additional Volume to EC2 VM-2

7) Check files are available in Additional volume or not

$ lsblk

$ mkdir demo

$ sudo mount /dev/xvdb demo

$ ls -l demo

Note: Once practice is completed, detach additional volume and delete it to avoid
billing.

==========

Snapshots

=========

=> Snapshots are used for volumes backup


=> Snapshots are regional specific (volumes are zone specific)

=> From volume we can create snapshot & from snapshot we can create volume

Volume ===> Snapshot ===> Volume

Note: Snapshot can't be attached to EC2 instance directley (volumes can be attached
to EC2 instance).

=========================================================

Q) How to copy the data from 1a zone VM to 1b zone VM ?

=========================================================

Step-1 : Create snapshot for 1a vm volume

Step-2 : From Snapshot create volume in 1b zone

Step-3 : Attach created 1b volume to 1b vm.

=========

Website

=========

- Collection of web pages (html pages)


- Websites are divided into 2 types

- static websites

- dynamic websites

- static website will give same response for every user

- dynamic website will give response based on user

Ex: gmail

- To host websites we need webservers

- Webserver is a s/w which is used to run website

Ex : httpd, apache2... (for static websites)

tomcat, IIS (for dynamic websites)

====================================

Hosting static website using httpd

====================================

$ sudo yum update -y

$ sudo yum install httpd


$ sudo systemctl start httpd

Note: Enable HTTP : 80 in Security Group Inbound rules

=> Access our website using EC2 vm public ip

=> We can change content of our website using below commands

$ cd /var/www/html

$ sudo vi index.html

<h1> Welcome to Ashok IT <h1>

<h2> Contact Us : + 91 - 9985296677 </h2>

=> Access our website using EC2 vm public ip

=================================

What is user-data in EC2 VM ?

=================================

- It is used to execute script while launching machine.

- User data will execute only once

- Create EC2 VM (amazon linux) with below user data


#! /bin/bash

sudo su

yum install httpd -y

cd /var/www/html

echo "<html><h1>Life Insurance Server - 1</h1></html>" > index.html

service httpd start

- After machine launch access public ip in browser

=========================

What is Load Balancer ?

=========================

=> When we run our application in single server then we have to face below challenges

1) One server should handle all reqs

2) Burden will increase on server

3) Response will be delayed for clients

4) Server can crash

5) Single Point Of Failure

6) Business Loss

=> To avoid above problems, we will run our application using Load Balancer.

=> Load Balancer is used to distribute load to multiple servers in round robbin fashion.

=> We have below advantages with Load Balancer


1) App will run in multiple severs

2) Load will be distributed

3) Burden will be reduces on servers

4) Fast Performance

5) High Availability

=> In AWS we have 4 types of Load Balancers

1) Application Load Balancer (http & https)

2) Network Load Balancer

3) Gateway Load Balancer

4) Classic Load Balancer

=======================

Load Balancer Lab Task

=======================

Step-1) Create EC2 VM-1 with below user data


#! /bin/bash

sudo su

yum install httpd -y

cd /var/www/html

echo "<html><h1>Life Insurance Server - 1</h1></html>" > index.html

service httpd start

Step-2) Create EC2 VM-2 with below user data

#! /bin/bash

sudo su

yum install httpd -y

cd /var/www/html

echo "<html><h1>Life Insurance Server - 2</h1></html>" > index.html

service httpd start

Step-3) Add these 2 instances to one "Target Group"

Step-4) Create Load Balancer with Target Group (ALB)

Schme : Internet Facing

Note: ALB runs on HTTP protocol with 80 port number

Step-5) Access Load Balancer DNS in browser

(it will route the requests to our servers in round robbin fashion)
===============================

Monolithic Vs Microservices

===============================

Monolithic => Developing all functionalities in one single application

Note: For monolithic application we need single target group

Microservices => Dividing functionalities into multiple apis

Note: For microservices application we need multiple target groups

##### Microservices Load Balancing : https://www.youtube.com/watch?v=QvEJ8--zneU


####

==============

OSI Model

==============

=> Open Systems Interconnection

=> OSI model represents how request will transfer from client to server

=> OSI model contains 7 layers


Layer-7 : Application Layer

Layer-6 : Presentation Layer

Layer-5 : Session Layer

Layer-4 : Transport Layer

Layer-3 : Network Layer

Layer-2 : Data Link Layer

Layer-1 : Physical Layer

=> ALB works at layer-7 (application layer)

Ex: For http, https & microservices

Advanced routings

header based routing

path based routing

=> NLB works at Layer-4 (Transport layer)

Ex: TCP, UDP

For gaming servers

For video streaming


=> GWLB works at layer-3 (Network layer)

Ex: Third party virtual appliances

Firewalls

VPNs

High Security

=====================

Auto Scaling Groups

=====================

=> It is used adjust the capacity required to handle the load

Ex: For big billon day sale we can't guess traffic

=> If requests are increasing then servers should be increased and if requests are
decreasing then less servers should be handling the request

1) Fault Tolerance

2) Cost Management

3) High Availability

=> To create Auto Scaling group we will use Launch Template.

=> Launch Template is used to specify configuration required to launch new VM.
===============================================================

How application will be deployed into new vm created by ASG ?

===============================================================

Option-1 : Using Custom AMI

Option-2 : User Data Script

Option-3 : Code Deploy (Native Service)

Option-4 : Kubernetes Cluster (EKS)

=========================================================

IQ) How to connect with EC2 VM when we lost .pem file ?

=========================================================

====================

Ec2 Instance Types

====================

1) General Purpose

2) Compute Optimized

3) Memory Optimized

4) Storage Optimized

5) Accelerated Computing
============

EC2 Summary

============

1) What is Ec2

2) AMI

3) Instance Type (t2.micro)

4) Keypair (public & private)

5) VPC (default vpc)

6) Security Groups (inbound & outbound)

7) EBS (Volumes & Snapshots)

8) Types of IPs

9) Launching Windows VM

10) Launching Linux VM

11) Static website hosting using httpd

12) Load Balancer

13) Types of LBRs

14) Auto Scaling

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy