Notice: Trying to get property 'post_excerpt' of non-object in /home/n3svtp4r09fz/technet.vn/wp-content/themes/darknews/single.php on line 43
Lab Details:
- This lab walks you through the steps to create an Elastic File System.
- You will launch and configure two Amazon EC2 Instances.
- You will practice mounting the EFS to both instances by logging into each instance via SSH authentication.
- You will practice sharing files between two instances.
- Duration: 1 hours
- AWS Region: US East (N. Virginia)
Lab Tasks:
- Log into AWS Management Console.
- Create an Elastic File System.
- Create 2 Amazon Linux Instances from an Amazon Linux AMI
- Find your instance in the AWS Management Console.
- SSH into your instance.
- Install NFS Client and mount EFS onto the instances.
- Test sharing files between the instances.
Architecture Diagram:
Steps
Launching two EC2 Instances
- Make sure you are in the N.Virginia Region.
- Navigate to the
menu at the top and click on
in the
section.
- Select Instances from the left menu and then click on
- Search and Choose Amazon Linux 2 AMI:
- Choose an Instance Type: Select
and then click on the
-
Configure Instance Details:
- Number of Instances : Enter 2
- No need to change any other settings. Click on
- Number of Instances : Enter 2
- Add Storage: No need to change anything in this step. Click on
-
Add Tags: Click on
- Key : Enter Name
- Value : Enter MyEFS
- Click on
- Key : Enter Name
-
Configure Security Group:
- Security Group Name: Enter EFS-SG
-
To add SSH:
- Choose Type:
- Source:
(Allow specific IP address) or
(0.0.0.0/0).
- Choose Type:
-
For NFS:
- Click on
- Choose Type: NFS
- Source:
(Allow specific IP address) or
(0.0.0.0/0).
- Click on
- After that, click on
- Security Group Name: Enter EFS-SG
- Review and Launch : Review all settings and click on
- Key Pair : Create a new key pair and click on
. After that, click on
- Launch Status: Your instance is now launching. Click on the instance ID and wait until the initialization status changes to
-
Click on each instance and enter a names as MyEC2-1 and MyEC2-2.
- Take note of the IPv4 Public IP Addresses of the EC2 instances and save them for later.
Creating an Elastic FIle System
- Navigate to EFS by clicking on the
menu at the top. Click on EFS in the
section.
-
Click on Create File System.
- Configure Network Access:
-
VPC
- An Amazon EFS file system is accessed by EC2 instances running inside one of your VPCs.
- Choose the same VPC you selected while launching the EC2 instance (leave as default).
- An Amazon EFS file system is accessed by EC2 instances running inside one of your VPCs.
-
Mount Targets
- Instances connect to a file system by using a network interface called a mount target. Each mount target has an IP address, which we assign automatically or you can specify.
- We will select all the Availability Zones (AZ’s) so that the EC2 instances across your VPC can access the file system.
- Select all the Availability Zones, and in the Security Groups, select EFS-SG instead of the default value.
- Click on
- Instances connect to a file system by using a network interface called a mount target. Each mount target has an IP address, which we assign automatically or you can specify.
-
Configure File System Settings
-
Add tags:
- Key : Enter Name
- Value : Enter MyFirstEFS
- Key : Enter Name
- Enable Lifecycle Management : Choose None
- Choose Throughout mode : Choose Bursting
- Choose Performance mode: Choose General Purpose
- Enable Encryption : Leave it as default
- Click on
-
- Configure Client Access: No need to change anything. Click on
- Review and Create: Review the configuration below before proceeding to create your file system.
-
Click on
- Scroll down on the page. You can see the Mount target status is set to Creating. Wait for the status to be Available.
- Open the EC2 dashboard in a seperate tab.
What to do if your Putty session times out:
- Note: Putty doesn’t work or becomes inactive if it is left idle for sometime. If you get stuck in putty and cannot type, we can duplicate the session.
- Right click on top, click on Duplicate Session, and close the current session with yes to the warning.
Mount the File System the MyEFS-1 Instance
- Select the MyEFS-1 Instance and copy the IPv4 Public IP.
- SSH into the EC2 Instance
-
Please follow the steps in SSH into EC2 Instance.
-
Switch to root user
- sudo -s
- sudo -s
-
Run the updates using the following command:
- yum -y update
- yum -y update
-
Install the NFS client.
- yum -y install nfs-utils
- yum -y install nfs-utils
-
Create a directory by the name efs
- mkdir efs
- mkdir efs
-
Mount the file system in this directory. To do so, navigate to EFS and copy the DNS Name in the file system.
-
- mount -t nfs dns-name:/ efs/
-
Note: Enter your EFS DNS Name in the place of dns-name above.
-
To display information for all currently-mounted file systems, we’ll use the command bellow:
- df -h
- df -h
-
Create a directory in our current location:
- mkdir aws
- mkdir aws
-
Mount the File System to MyEFS-2 Instance
- Select the MyEFS-2 Instance and copy the IPv4 Public IP.
- SSH into the EC2 Instance
- Please follow the steps in SSH into EC2 Instance.
-
Switch to root user
- sudo -s
- sudo -s
-
Run the updates using the following command:
- yum -y update
- yum -y update
-
Install the NFS client.
- yum -y install nfs-utils
- yum -y install nfs-utils
-
Create a directory with the name efs
- mkdir efs
- mkdir efs
-
Mount the file system in this directory. To do so, navigate to EFS and copy the DNS Name in the file system.
- mount -t nfs dns-name:/ efs/
- Note: Enter your EFS DNS Name in the place of dns-name above.
- To display information for all currently mounted file systems, we’ll use the command
-
df -h
Testing the File System
- SSH into both instances in a side-by-side view on your machine, if possible.
-
Switch to root user
- sudo -s
- sudo -s
-
Navigate to efs directory in both the servers using command
- cd efs
- cd efs
-
Create a file in any one server.
- touch hello.txt
- touch hello.txt
-
Check the file using command
- ls -ltr
- ls -ltr
-
Now go to the other server and give command
- ls -ltr
- ls -ltr
- You can see the file created on this server as well. This proves that our EFS is working.
- You can try creating files (touch command) or directories (mkdir command) on other servers to continue to grow the EFS implementation.
Completion and Conclusion
- You have successfully created an Elastic File System.
- You have successfully created 2 Amazon Linux instances.
- You have successfully installed the NFS Client and mounted EFS to the instances.
- You have successfully tested the file-share between both Instances.