×
Community Blog How to Use Cloud Services to Build a NAS and Share Files Securely

How to Use Cloud Services to Build a NAS and Share Files Securely

This article describes how to configure Alibaba Cloud NAS and share files securely.

By Alain Francois

What Is Network Attached Storage (NAS)?

Network Attached Storage (NAS) is a reliable service that provides standard file access protocols and guarantees high throughput and low latency. It provides simple, scalable, and shared file storage for compute nodes, including Elastic Compute Service (ECS) instances, E-HPC nodes, and Alibaba Cloud Container Service for Kubernetes (ACK) nodes. NAS is compatible with multiple standard protocols, such as NFS and SMB. This means you do not have to modify existing applications; Windows and Linux applications can use NAS. Alibaba Cloud File Storage NAS can allow simultaneous access to a file system from multiple ECS instances. It provides mount points that connect to Alibaba Cloud Elastic Compute Service (ECS) nodes residing on virtual private clouds (VPCs).

Storage Types

File Storage NAS offers three storage types:

  • General-Purpose NAS File Systems store frequently accessed hot data.
  • IA Storage Media offers a lifecycle management feature to dump the data to an Infrequent Access (IA) storage medium to reduce costs.
  • Extreme NAS File Systems is a high-performance file sharing service based on the latest network architecture and all-flash storage.

This guide uses the General-Purpose NAS file systems for the demo. It consists of NAS Performance file systems and NAS Capacity file systems. You can look at both types and choose which one fits your requirements:

1

Configuring Your NAS Service

Log in to your Alibaba Cloud console and go to Storage → File Storage NAS:

2

The overview page explains the different types of storage. You can choose one that fits your needs:

3

Go to File System List to create the file storage:

4

Choose Create File System. In the new window, create the General-Purpose NAS file systems:

5

You will need to set up some configurations, including the region where you want to create your NAS File System.

Note: Capacity NAS and Performance NAS are not available as storage types for all regions. Some regions only propose one type of storage.

In our case, we will choose NFS since we will test on a Linux client.

You can encrypt it for more security and create a data backup. However, we will explain how to create a backup in this guide:

6

When configuring NAS, you need to set up the mount target. You can configure the mount target for a VPC or a classic network. If a NAS file system and multiple ECS instances reside in the same VPC, you can only mount the file system on a Linux ECS instance. In our case, we will configure it for the VPC of our ECS:

7

Next, you will get a summary of your configuration:

8

After completing your order, go back to File System List. You will see your File NAS storage:

9

The mount target was created automatically when configuring the network:

10

Mounting the NFS File System to Your Linux ECS Instance

Connect to your Linux ECS instance and install an NFS client:

  • On Debian-based systems:
$ sudo apt update && sudo apt install nfs-common -y
  • On RedHat-based systems:
$ sudo yum install nfs-utils -y

Increase the number of concurrent NFS requests by running the following two commands:

$ echo "options sunrpc tcp_slot_table_entries=128" | sudo tee /etc/modprobe.d/sunrpc.conf
$ echo "options sunrpc tcp_max_slot_table_entries=128" | sudo tee /etc/modprobe.d/sunrpc.conf

Mount the NFS file system. The command is listed below:

$sudo mount -t nfs -o vers=4,minorversion=0,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport file-system-id.region.nas.aliyuncs.com:/ /mnt                                

You need to have the values of file-system-id and region. Click on your file system created and go to the mount target section to create a query:

11

On the Action section, choose Query:

12

Select your instance for the query:

13

You will see a summary of the query:

14

You will see a new option that will give you some information to connect to the file system. Choose Mount a file system on ECS by running the command to get the procedure and the other information to mount the NFS system:

15

You may need to mount the file system so multiple ECS instances can edit a file at the same time. Choose the option that fits your needs and execute the command it shows:

16

Use the information we have so far and the command below to mount your NFS file system using the NFSv4 protocol:

$ sudo mount -t nfs -o vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 11d5994875d-rfh96.eu-central-1.nas.aliyuncs.com:/ /mnt

You can check if the file system has been mounted with the df command:

$ df -h

17

text1

We possess two Linux ECS instances, Ubuntu and CentOS. We have mounted the NFS file system on Ubuntu. Now, create a file and see if the other instance can see it after mounting the NFS file system.

Let's create a folder inside the mounted file system on our Ubuntu instance:

$ mkdir /mnt/shared-folder

Let's create a file inside the folder and put a content:

$ vim /mnt/shared-folder/test-file

Let's mount the NFS file system on the CentOS ECS instance:

$ sudo mount -t nfs -o vers=3,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 11d5994875d-rfh96.eu-central-1.nas.aliyuncs.com:/ /mnt/nfs1

Let's check the mounted file system:

18

text2

$ tree /mnt

19

You can see the shared file system and its content.

Conclusion

When you create a NAS file system on a VPC, all your running instances on the same VPC can access your NFS shared file system. Linux distributions, such as CoreOS, FreeBSD, and Fedora CoreOS, do not support the mount feature of the NAS console.

0 0 0
Share on

Alibaba Cloud Community

864 posts | 196 followers

You may also like

Comments