Class 9th S3 Ec2 service Apr22nd
EC2 Elastic Compute cloud: Simple called it has 2 C, EC2
What is Ec2?
- AWS EC2 is a core service within Amazon Web service (AWS) that provides resizable compute capacity in the cloud.
- It run from the Ec2 host servers(also called physical servers) residing in the AWS datacenter
- These hosts servers are large hardware units that are divide into smaller chunks ,each chunk functions as a virtual server(instance)
- We can use these host server as shared server or dedicated servers
- Users can launch these servers with required OS setup in Pay-as-You-Go model
1.Scalabilty (We can change the Ec2 server whenever required)
2.Flexibility(We can able upgrade downgrade whenever required)
3.Customizable (Load balance we can install whatever required)
4.Pay-as-you-go pricing (How much you can use pay that much only)
5.Global reach (We access any where Globally )
6.Integration with other Aws services (Given permission we will communicate other aws services)
Ec2 Architecture
Ec2 is region specific ,each region has there availability zone (data center)
Instance has (Ip address,security group,key value pair)
Ec2 Free limit per month 750 hrs(12 free)
On-Demand instances :Whenevery you required it will give you new ip
Dedicate Instances: reserved instance for dedicated ip
Amazon Linux:AWS build the own Linux using Linux kernel,All Linux system in AWS Command Window access no GUI Access
Amazon Machine Image(AMI):
- Used to create/launch the Ec2 instances.
- AMI are available with various o/s for different requirements
- AMI's regional,each AMI Contains a unique ID Which is different form region to region
- Users can design own AMI and sell in the AWS market place.
- AMIs are immutable :once you create an AMI,it remains unchanged, Any changes made to the instance after the AMI Creation won't affect the image.
Amazon Machine Image: AWS Provided, Community, Market place
VM Creation Steps:
Step1: Choose Amazon Linux ,Generate Keypair you see below RSA, ED25519 more Strong Secure compared to RSA ,RSA will support window/Linux both ED22519
will support Linux only,Give key pair name "VM-LINUX_FIRST"
.ppk is putty based to connect ,third party service you can use
Step2:In the network section need vpc which we created,Auto -assigned public always be enable to connect public ,else Elastic Ip is chargeable
Advance option User data, Placement group not covered
just click launch instance
Step3:Connect AWS ,you can use SSH key which you have download VM-LINUX_FIRST.Pem key place directory and connect in local cmd prompt
Step3:Connect AWS ,you can use SSH key which you have download VM-LINUX_FIRST.Pem key place directory and connect in local cmd prompt
root - has supermium permission admin for ec2 instance
Simple Website Creation
Simple Website Creation
Two types of website 1.Static Website (Unchangable), 2.Dynamic Website (dynamical change and store info in Database level Change in periodically automictically) Now we are static website hosting using Linux instance.
Step1: After launch the instance amazon Linux for host website need install some software in Linux ,Apache and https package using sudo user
[ec2-user@ip-10-0-0-31 ~]$ sudo yum install httpd
Installed:
apr-1.7.5-1.amzn2023.0.4.x86_64 apr-util-1.6.3-1.amzn2023.0.1.x86_64
apr-util-openssl-1.6.3-1.amzn2023.0.1.x86_64 generic-logos-httpd-18.0.0-12.amzn2023.0.3.noarch
httpd-2.4.62-1.amzn2023.x86_64 httpd-core-2.4.62-1.amzn2023.x86_64
httpd-filesystem-2.4.62-1.amzn2023.noarch httpd-tools-2.4.62-1.amzn2023.x86_64
libbrotli-1.0.9-4.amzn2023.0.2.x86_64 mailcap-2.1.49-3.amzn2023.0.3.noarch
mod_http2-2.0.27-1.amzn2023.0.3.x86_64 mod_lua-2.4.62-1.amzn2023.x86_64
Complete!
Step2:After install ,We can the httpd status using command sudo systemctl status httpd
Step3: using command for start sudo systemctl start httpd checking the status again active and running
Step4: After installation Apache path default path is /var/www/html
If you want launch simple website,the default page is index.html
After installation httpd, just check public ip is working or not ,it connect direct direct default page (index.html)
See below Default page open successfully
Step5:
[ec2-user@ip-10-0-0-31 html]$ sudo vi index.html
[ec2-user@ip-10-0-0-31 html]$ cat index.html
<h1> Welcome to Blog </h1>
Step6:
Step7: Once you stop instance ,automatically public ip will change and apache httpd will inactive
you make manually start, Instead of manually start every time after instance restart
use below command enabled it will automatically start .
[ec2-user@ip-10-0-0-31 html]$ sudo systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
Instance Image Copy and Launch instance with image
if you want copy the same Instance image Below StepsStep1: Select insance >Image and templated and create image
Image now available(next time while you want create new instance ,take above image launch the instance the image Apache default), This is help you not required to install same softwares again
Step7: while connect using sshkey copy here see root default need change ec2-user and connectStep3:Amazon machine image take some time
Step4:Launch new instance this time using our image
Note: we can able change Linux version here, you can able to Change network setting and Security key pair and then Click launch the instance
Step5:See below successfully created new second instance using image it the instance automatically
has default software apache, just check once default page opened or not using public ip url
Step6:
ssh -i "VM-LINIX-SECOND.pem" root@34.240.205.112
PS C:\Users\Administrator> ssh -i "VM-LINIX-SECOND.pem" root@34.240.205.112
The authenticity of host '34.240.205.112 (34.240.205.112)' can't be established.
ED25519 key fingerprint is SHA256:c6LhEFgi2mMaPT1L3kE2/9dL+a12diUWugaxgzJHcNs.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '34.240.205.112' (ED25519) to the list of known hosts.
Please login as the user "ec2-user" rather than the user "root".
Connection to 34.240.205.112 closed.
PS C:\Users\Administrator> ssh -i "VM-LINIX-SECOND.pem" ec2-user@34.240.205.112
Last login: Sat Apr 26 09:50:32 2025 from 5.204.1.73
[ec2-user@ip-10-0-0-101 ~]$
Immutability means after image take any change one instance that change not carry to new instance that is called immutable
Instance Launch with Condition User data option
install Apache using commands
Step1:Create Instance give name VM-LINIX-THIRD, additonal setting going to User data setting
After give below lines in the User data section and click launch Instance
#!/bin/bash -xe
# STEP1 -Updates
yum -y update
# STEP2 -Begin Configuration
yum -y install httpd
systemctl enable httpd
systemctl start httpd
# STEP3 -Customer Web Page
echo "<h1> Welcome to Blog VM Third Instance</h1>" >> /var/www/html/index.html
Step3:After completed work need Deregister AMI image which we have created
Click AMIs, due cost related clear that
No comments:
Post a Comment