In this project, three web servers were created and distributed across separate availability zones. The web servers need to share the same unstructured data.
The data can consists of PHP files, config files, plugins, and images etc.
EFS Is used as a shared file system, with EFS you can share file data without provisioning or managing servers.
Amazon EFS automatically grows and shrinks as you add or remove files. This removes the need for capacity management
After creating the EFS file system, you can create mount tragets on each subnet.The mount target enables communication from Amazon EC2 instances on the subnet. It uses the Network File system (NFSV4) protocol
Amazon EFS security Group once created, you can prepare to create the file system
In general, Create the EC2 instance then the EFS, and within the network session of the EFS you create security group for each EC2 instance,
Then click attach to attach the EFS and EC2 instance copy out the EFS mount helper provided code
Connect to the instance
Login as root user: sudo -i Install the amazon EFS Util tool
sudo yum install -y amazon-efs-utils
Amazon EFS client Is available in the Amazon Linux package repositories, to build install and package on linux repositories
- In the terminal, run:
sudo -i
- In the terminal, run:
sudo yum install -y amazon-efs-utils
- Go to the next step.
- In the terminal, run:
mkdir data
- If you receive a Permission Denied message, run:
cd ~/
- In the terminal, run:
ls
- In the terminal, paste the sudo mount command that you copied from the Amazon EFS console in an earlier step. At the end of the command, replace the "efs" folder name with "data" (without quotes) and press Enter. sudo mount -t efs -o tls fs-08ed9db97402b6ab1:/ efs
- The command should look similar to what is displayed in the screenshot example.
- In the terminal, run:
cd data
- To create a log file, run:
sudo bash -c "cat >> efs-1-setup.log"
- No output will appear. Instead, the cursor will move to a new line and wait for your next input.
- In the terminal, run:
efs-1 mounted in site A
- To end the cat session, on your keyboard, press Ctrl+C.
- To view the log file contents, run:
cat efs-1-setup.log
You should see all the File system mounted to the different instances.