Exploring AWS !!
Day 31:
Case Study — EC2, EBS, EFS
Problem Statement:
You work for XYZ Corporation. Your corporation is working on an application and they require secured web servers on Linux to launch the application.
You have been asked to:
- Create an Instance in us-east-1 (N. Virginia) region with Linux OS and manage the requirement of web servers of your company using AMI
- Replicate the instance in us-west-2 (Oregon) region
- Build two EBS volumes and attach them to the instance in us-east-1 (N. Virginia) region
- Delete one volume after detaching it and extend the size of other volume
- Take backup of this EBS volume
Solution:
1.Create an instance in N.Virginia with Linux OS
- Creating an image i.e. AMI for the instance launched in N.Virginia, go to Action → Image and Template → Create Image
- Create Image, by entering the required details such as Image name and description and click create
- The AMI is created for the instance in N.Virginia, now we need to create a copy of the same
- Right click and Copy AMI
- Select the US West Oregon and click Copy AMI
- The AMI copy operation is initiated, and we can check the progress in us-west-2(Oregon) as well.
- The progress can be checked this way in the Oregon region as well.
- The AMI is created and we can click on ‘Launch Instance from image’
- Using the AMI we were able to successfully replicate the Instance in Oregon Region
- Now to create EBS volumes, we need to go to Volumes and click on Create Volume → Select the exact AZ which is for the instance as well, i.e. is your instance is launched in us-east-1c then make sure that the EBS created should also be in us-east-1c, we need to create 2 such volumes.
- Click on Actions and choose ‘Attach’ to attach the volumes to the respective instance
- Select the instance and AZ accordingly
- The Device name appears and it can range from sdf to sdp, click on Attach Volume
- Now to mount the EBS volumes, Copy the IPv4 address of the instance launched
- We can connect to the instance even by putty
- We can also connect to the instance directly via Instance Connect
- As the instance launched is Linux, we are connected to ec2-user@ip-172–31–86–236
- For Linux OS, we need to run following command to get updates → sudo yum update
- Give following commands to mount the EBS volume on the EC2 instance
lsblk
file –s /dev/devicename
mkfs –t ext4/dev/devicename
mkdir ebsvolume
mount /dev/devicename path to ebsvolume
- To unmount the EBS volume, give following commands:
df –h
unmount /dev/devicename
- As the EBS is unmounted we can detach the volume and delete it
- We can modify the size by clicking Actions → Modify Volume
- Give the desired size and click Modify
- Size volume modification will be in progress
- To create a backup of this volume, we can go to Actions → Create Snapshot
- Enter the required details such as description and click Create Snapshot
- Backup of EBS is created
Top comments (0)