Hybrid Storage and Data Migration with AWS Storage Gateway File Gateway
Obasaju Winner
Cloud Engineer| 2X AWS Certified| Certified in Cybersecurity| 2X Certified in Precision Medicine, Stanford Dept. of Genetics| Pharmacist| Computational Drug Discovery
Here, you will attach a Network File System (NFS) mount to an on-premises data storage using the AWS Storage Gateway File Gateway service. After that, you'll copy the data to an Amazon S3 bucket. Next, you will set up more advanced Amazon S3 features like cross-region replication and Amazon S3 lifecycle policies.??
At the end, you should be able to:
Pre-requisites for this lab
Three AWS Regions are used in this lab setting. To simulate an on-premises server, a Linux EC2 instance is deployed to the us-east-1 (N.Virginia) Region. The Linux server and Storage Gateway virtual appliance are both deployed to the same region. The appliance would be installed as a physical Storage Gateway appliance or in an environment using Microsoft Hyper-V or VMware vSphere.
The primary S3 bucket is created in the US-east-2 (Ohio) Region. Data from the Linux host is copied to the primary S3 bucket. This bucket can also be called the source.?
The secondary S3 bucket is created in the US-west-2 region (Oregon). This secondary bucket is the target for the cross-region replication policy. It can also be called the destination.?
Here’s the initial architecture
Creating the primary and secondary S3 buckets
Before you configure the File Gateway, you must create the primary S3 bucket (or the source) where you will replicate the data. You will also create the secondary bucket (or the destination) that will be used for cross-Region replication.?
You must enable versioning for both the source and destination buckets for cross-Region replication.
Repeat the previous steps in this task to create a second bucket with the following configuration:?
Enabling cross-Region replication
Now that you have created your two S3 buckets and enabled versioning on them, you can create a replication policy.
For this lab, use a small file that does not contain sensitive information, such as a blank text file.?
The file that you uploaded should also now have been copied to this bucket.
Note: You may need to refresh the console for the object to appear.
Configuring the File Gateway and creating an NFS file share
In this task, you will set up the File Gateway appliance as an Amazon EC2 instance. You will next set up a cache disk, choose an S3 bucket to synchronize your on-premises files with, and select an IAM policy to utilize. Finally, you'll set up an NFS file sharing on the File Gateway.
A new tab opens to the EC2 instance launch wizard. This link automatically selects the correct Amazon Machine Image (AMI) that must be used for the File Gateway appliance.
Note: This security group is configured to allow traffic through ports 80 (HTTP), 443 (HTTPS), 53 (DNS), 123 (NTP), and 2049 (NFS). These ports enable the activation of the File Gateway appliance. They also enable connectivity from the Linux server to the NFS share that you will create on the File Gateway.
Note: This security group is configured to allow Secure Shell (SSH) connections on port 22.
Tip: You may need to choose Show all selected to see them both.
A Success message displays
Your File Gateway Appliance instance will take a few minutes to initialize.
Tip: Choose the refresh button to more quickly learn the status of the instance.
You will use this IP address when you complete the File Gateway deployment.
A Successfully activated gateway File Gateway Appliance message displays. In the Configure cache storage panel, you will see a message showing the local disks loading.
Note: You might get a warning message that the file share is accessible from anywhere. For this lab, you can safely disregard this warning. In a production environment, you should always create policies that are as restrictive as possible to prevent unwanted or malicious connections to your instances.
领英推荐
Monitor the status of the deployment and wait for Status to change to Available, which takes less than a minute.
Note: You can choose the refresh button occasionally to notice more quickly when the status has changed.
This completes your Storage gateway creation.
Mounting the file share to the Linux instance and migrating the data
Before you can migrate data to the NFS share that you created, you must first mount the share. In this task, you will mount the NFS share on a Linux server, and then copy data to the share.
For Windows users, choose the Download PPK button and save the labsuser.ppk file. Note the OnPremLinuxInstance address, if it is displayed.?
For Linux and MacOS users, choose the Download PEM button and save the labsuser.pem file. Note the OnPremLinuxInstance address, if it is displayed.?
For example, if the labsuser.pem file was saved to your Downloads directory, run this command:
cd ~/Downloads
chmod 400 labsuser.pem
ssh -i labsuser.pem ec2-user@<public-ip>
Because you are using a key pair for authentication, you are not prompted for a password.
You should now be connected to the instance.
ls /media/data
You should see 20 image files in the .png format.
sudo mkdir -p /mnt/nfs/s3
sudo mount -t nfs -o nolock,hard <File-Gateway-appliance-private-IP-address>:/<S3-bucket-name> /mnt/nfs/s3
Notice that the command starts with sudo and ends with /mnt/nfs/s3
For example:
sudo mount -t nfs -o nolock,hard 10.10.1.33:/my-source /mnt/nfs/s3
df -h
The output of the command should similar to the following example:
[ec2-user@ip-10-10-1-210 ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 483M 64K 483M 1% /dev
tmpfs 493M 0 493M 0% /dev/shm
/dev/xvda1 7.8G 1.1G 6.6G 14% /
10.10.1.33:/my-source 8.80E 0 8.0E 0% /mnt/nfs/s3
?sudo cp -v /media/data/*.png /mnt/nfs/s3
Verifying that the data is migrated
You have finished configuring the gateway and copying data into the NFS share. Now, you will verify that the configuration works as intended.
Note: You might need to choose the refresh icon in the S3 console.
Note: S3 Object replication can take up to 15 minutes to complete. Keep refreshing until you see the replicated objects.
Congratulations, you successfully migrated data to Amazon S3 by using AWS Storage Gateway in the File Gateway mode. After your data is stored in Amazon S3, you can act on it like native Amazon S3 data. In this lab, you created a replication policy to copy the data to a secondary Region. You could also perform other operations, such as configuring a lifecycle policy. For example, you could migrate infrequently used data automatically from S3 Standard to Amazon S3 Glacier for long-term storage, which can reduce costs.?
Navigating cloud migration is like sailing uncharted waters—careful planning leads to treasure ??. Remember, as Seneca hinted, our wind cannot change but our sails can. Keep exploring! #CloudInnovation