AWS——02 articles (AWS service storage EFS mounted on Amazon EC2 - managed file storage for EC2)

1 Introduction

2. About Amazon EFS

2.1 Full name of Amazon EFS

  • as follows:
    • Amazon Elastic File System
    • Amazon Elastic File System, a scalable and elastic cloud-native NFS file system
    • Amazon Elastic File System (Amazon EFS) provides a simple, scalable, and elastic file system for general-purpose workloads that can be used with AWS cloud services and on-premises resources.

2.2 What is Amazon EFS

  • simple explanation
    • Amazon EFS is a cloud-native data store that provides simple scalable shared file storage for Linux-based business applications that can grow to petabytes (petabytes) while providing consistent low legacy data and high levels of throughput. And it's fully managed, so there's no need to worry about ongoing maintenance of Amazon EFS.
    • Easy to set up, just use the AWS Management Console API or command interface to create a file system and make it securely available to EC2one or more of your instances Amazon VPC, then mount your file system to store and access your data , you can also use AWS direct connect or AWS VPN to mount the local server to EFS, easily migrate data to EFS to enable cloud bursting or back up local data to EFS.
    • The EFS file system is elastic and can automatically grow and shrink as you add and remove files. You can choose between two performance modes to tailor the file system performance to your application needs. The throughput of the file system will increase as the Automatically expands as capacity increases. For workloads with high throughput requirements and low capacity requirements, where throughput can be configured independently of capacity, but less frequently, you can configure EFS to store data in a cost-optimized infrequently accessed storage class.
    • Amazon EFS works with the tools and applications you already use and is designed for high availability and durability, allowing you to store your redundant data across multiple Availability Zones. You can always do this, providing the capacity you need when you need it, without having to provision storage up front.
    • Pay only for what you use, with no minimum fees or setup costs, and it eliminates storage management tasks.
  • In summary, the summary is:
    Amazon Elastic File System (Amazon EFS) provides a simple, scalable, fully managed elastic NFS file system that can be used in combination with AWS cloud services and local resources. It scales to petabytes on demand without disrupting applications, and automatically scales up or down as you add and remove files, allowing you to accommodate file system growth without provisioning and managing capacity. Amazon EFS is designed to provide massively parallel shared access to thousands of Amazon EC2 instances, enabling your applications to achieve high levels of aggregate throughput and IOPS with consistently low latency.

2.3 Advantages and functions

  • Dynamically elastic
    Amazon EFS automatically and instantly expands or shrinks your file storage capacity as you add or remove files without interrupting your applications, giving you the storage you need when you need it. You simply create a file system and start adding files, no need to provision storage in advance.
  • Scalable performance
    Amazon EFS is designed to deliver the throughput, IOPS, and low latency required by general-purpose workloads. Throughput and IOPS scale as the file system grows and can burst to higher throughput levels for short periods of time to support unpredictable file workload performance needs. For the most demanding workloads, Amazon EFS can support over 10 GB/sec of performance and up to 500,000 IOPS.
  • Fully managed
    Amazon EFS is afully managed service, which provides shared file system storage for general-purpose workloads. itProvides a simple interface, which allows you to quickly create and configure file systems and manages the file storage infrastructure for you, eliminating the complexity of deploying, patching, and maintaining file system foundations.
  • Shared file storage
    Amazon EFS provides secure access to thousands of connections. Amazon EC2 instances and on-premises servers can simultaneously access the Amazon EFS shared file system through the NFSv4 protocol using the traditional file permission model, file locking capabilities, and hierarchical directory structures.Amazon EC2 instances can access your file system across Availability Zones and AWS Regions, while on-premises servers can be accessed using AWS Direct Connect or AWS VPN.

2.4 Refer to the official website

3. Create a file system

3.1 Create an EC2 instance

3.2 Create file system

  • Created as follows:
    Insert image description here
    Insert image description here

    Insert image description here

4. Mount the Amazon EFS file system on the Linux instance

4.1 View how to mount

  • first:
    Insert image description here

  • Then:
    Insert image description here

  • then
    Insert image description here

  • Finally, open the help document
    document address:

    https://docs.aws.amazon.com/efs/latest/ug/mounting-fs-mount-helper-ec2-linux.html
    

    Insert image description here

4.2 Connect to EC2 instance

  • Connect two EC2 instances, one is Amazon Linux 2023and the other is Amazon Linux 2 AMI(see the previous article for details on how to connect), as follows:
    Insert image description here
    Insert image description here

4.3 Install amazon-efs-utils

  • Installation reference address:
    https://docs.aws.amazon.com/efs/latest/ug/installing-amazon-efs-utils.html
    
  • Installation command:
    sudo yum install -y amazon-efs-utils
    
    Insert image description here
  • Installation is as follows:
    sudo -s
    yum install -y amazon-efs-utils
    
    Insert image description here

4.4 Create efs directory

  • Use the following command to create a directory efs as the mount point of the file system, as follows:

    mkdir efs
    

    Insert image description here

4.5 Execute the mount command to mount

  • Copy the mount command as follows:
    sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport 文件挂载系统的DNS名称:/ efs
    
    Insert image description here
    Insert image description here
  • Execute the mount command. If the mount is successful, as follows:
    df -h
    
    Insert image description here
    If you have any questions about this step, please refer to the following "6. Problems encountered》 to find the corresponding solution.
  • Mount the second EC2 instance
    . Use the same method to mount the other EC2 instance. No more details.

5. Easy to use

5.1 Briefly demonstrate writing and reading

  • As shown below, you can see that the data written on one EC2 instance can be read on another EC2 instance (The premise is: EFS is mounted), deletion is no problem, they are all flexible.
    Insert image description here

6. Problems encountered

6.1 Executing the mount command times out

6.1.1 Problem description

  • The problem description is as follows:
    mount.nfs4: Connection timed out
    
    Insert image description here

6.1.2 Solve the problem - create a new security group

  • Which port is open? 2049, as follows:
    Insert image description here
    Let’s continue...
  • First, check EFS系统the security group used and find that the default security group is used, as follows:
    Insert image description here
  • Then, we check the inbound rules of this security group.
    Insert image description here
    Insert image description here
    The port range is already all, why not? I don’t know, try creating a new security group...
  • Then, create a new security group as follows:
    Insert image description here
    Insert image description here
  • The modified EFS系统security group is as follows:
    Insert image description here
  • After the modification is complete, execute the mount command again,problem solved,as follows:
    Insert image description here

6.1.3 Notes on 2049

  • The EC2 instance and the EFS system do not need to have the same security group. My EC2 instance above is still the security group created before, that is, the EC2 instance does not need to open port 2049.

Guess you like

Origin blog.csdn.net/suixinfeixiangfei/article/details/132034348