简体   繁体   English

使用相同的 AWS EFS 共享多个目录

[英]Using same AWS EFS to share multiple directories

I have create a file system EFS and mount on a EC2 instance on /var/www/html/media.我创建了一个文件系统 EFS 并挂载在 /var/www/html/media 上的 EC2 实例上。 I would like to use the same EFS Filesystem to mount another directory /var/www/html/var.我想使用相同的 EFS 文件系统挂载另一个目录 /var/www/html/var。

Is that possible?那可能吗?

I would to do:我会这样做:

fs-296e0282.efs.us-west-2.amazonaws.com:/media   /var/www/html/media   nfs4    defaults

fs-296e0282.efs.us-west-2.amazonaws.com:/var   /var/www/html/var   nfs4    defaults

But it seems no possible.但似乎没有可能。

It is possible to mount two different directories under file mount system.可以在文件挂载系统下挂载两个不同的目录。 Initially in order to access your efs just mount a EFS root under your instance using the command最初为了访问您的 efs,只需使用以下命令在您的实例下挂载一个 EFS 根

Sudo mount -t efs fs-id:/ /home/efs

Then create subdirectories under the /home/efs folder for example let's have two subdirectories under /home/efs namely media and var然后在 /home/efs 文件夹下创建子目录,例如让我们在 /home/efs 下有两个子目录,即 media 和 var

Now you can mount two directories in /var/www/html/media and /var/www/html/var by adding the below in fstab file which will be under /etc/现在,您可以通过在 /etc/ 下的 fstab 文件中添加以下内容,在 /var/www/html/media 和 /var/www/html/var 中挂载两个目录

fs-id:/media /var/www/html/media efs defaults,_netdev 0 0

fs-id:/var /var/www/html/var efs defaults,_netdev 0 0

And reboot your instance.并重新启动您的实例。 Whatever changes in /var/www/html/media will gets reflected in fs-id:/media folder also the same applies for var folder also hope this helps. /var/www/html/media 中的任何更改都会反映在 fs-id:/media 文件夹中,同样适用于 var 文件夹也希望这有帮助。

Your EFS id: fs-357f69c8您的 EFS ID: fs-357f69c8

You want to mount in a EC2 Machine of following folders您想挂载在以下文件夹的 EC2 机器中

  • /efs
  • /var/www/html/data
  • /var/www/html/api/upload
  • /var/www/html/uploadetfiles

So, first, create the folders所以,首先,创建文件夹

  • sudo mkdir /efs
  • sudo mkdir /var/www/html/data
  • sudo mkdir /var/www/html/api/upload
  • sudo mkdir /var/www/html/uploadetfiles

For mount in EC2 command will be在 EC2 命令中挂载将是

  • sudo mount -t efs -o tls fs-357f69c8:/ /efs
  • sudo mount -t efs -o tls fs-357f69c8:/ /var/www/html/data
  • sudo mount -t efs -o tls fs-357f69c8:/ /var/www/html/api/upload
  • sudo mount -t efs -o tls fs-357f69c8:/ /var/www/html/uploadetfiles

NB: Your machine should have efs-utils installed注意:您的机器应该安装了efs-utils

To build and install an RPM:要构建和安装 RPM:

  • sudo yum -y install git rpm-build make
  • sudo git clone https://github.com/aws/efs-utils
  • cd efs-utils
  • sudo make rpm
  • sudo yum -y install build/amazon-efs-utils*rpm

To build and install a Debian package:要构建和安装 Debian 软件包:

  • sudo apt-get update
  • sudo apt-get -y install git binutils
  • sudo git clone https://github.com/aws/efs-utils
  • cd efs-utils
  • sudo ./build-deb.sh
  • sudo apt-get -y install ./build/amazon-efs-utils*deb

Hope this will works希望这会奏效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM