Step 1: Set Up Your AWS Account
- Sign In: Log into your AWS Management Console.
- IAM User: Ensure you have an IAM user with appropriate permissions (AmazonElasticFileSystemFullAccess).
Step 2: Create an EFS File System
Navigate to EFS:
- In the AWS Management Console, search for “EFS” and select Elastic File System.
Create File System:
- Click on Create file system.
- Select your VPC and availability zones.
- Choose the performance mode (General Purpose or Max I/O) based on your use case.
- Configure throughput mode (Bursting or Provisioned).
- (Optional) Enable encryption at rest and in transit.
- Click Create file system.
Step 3: Configure EFS Mount Targets
- Mount Targets:
- After creating the file system, click on it to view details.
- Click on Network and then Add mount targets.
- Select subnets (in different availability zones for redundancy).
- Specify security groups to control access.
- Click Add mount targets.
Step 4: Create an EC2 Instance to Access EFS
- Launch EC2 Instance:
- Navigate to EC2 in the AWS Management Console.
- Click on Launch Instance.
- Choose an Amazon Machine Image (AMI), such as Amazon Linux 2.
- Select an instance type (e.g., t2.micro for testing).
- Configure network settings to ensure the instance is in the same VPC as the EFS.
- (Optional) Create or select an existing security group allowing NFS access (port 2049).
- Click Launch.
Step 5: Install NFS Client on EC2
Connect to EC2 Instance:
- Use SSH to connect to your EC2 instance.
Install NFS Utilities:
bashsudo yum install -y nfs-utils # For Amazon Linux
Step 6: Mount the EFS File System
Create a Mount Point:
bashsudo mkdir /mnt/efs
Mount EFS:
- Use the EFS DNS name to mount:
bashsudo mount -t nfs4 <EFS-DNS-NAME>:/ /mnt/efs
- Replace
<EFS-DNS-NAME>
with the actual DNS name from your EFS console.
Verify Mount:
bashdf -h
Step 7: Test EFS
Create a Test File:
bashecho "Hello EFS" | sudo tee /mnt/efs/testfile.txt
Verify File:
bashcat /mnt/efs/testfile.txt
Step 8: Configure Automatic Mounting (Optional)
Edit fstab:
- Open the fstab file:
bashsudo nano /etc/fstab
Add EFS Entry:
- Add the following line at the end of the file:
javascript<EFS-DNS-NAME>:/ /mnt/efs nfs4 defaults,_netdev 0 0
Test fstab:
bashsudo umount /mnt/efs sudo mount -a
Step 9: Clean Up
Unmount EFS:
sudo umount /mnt/efs
Delete EC2 Instance:
- Navigate to the EC2 console and terminate the instance.
Delete EFS File System:
- Go back to the EFS console and delete the file system.
No comments:
Post a Comment