AWS服务器EC2挂载S3

DevOps AWS评论4,160字数 5320阅读17分44秒阅读模式

安装s3

[root@us-prod-sre-jumpserver-1 ~]#yum install epel-release
[root@us-prod-sre-jumpserver-1 ~]#yum install s3fs-fuse
[root@us-prod-sre-jumpserver-1 ~]# echo AKIA3TT6M7A7QSTdUTOKZ:O8Fagj5NAAYN405Q7YOX3OAi+Q0XExdd4j/uBw7haV > /root/.passwd-s3fs
[root@us-prod-sre-jumpserver-1 ~]# chmod 600 /root/.passwd-s3fs

S3fs挂载存储桶使用的命令是s3fs

  • s3fs的命令格式是:
  • s3fs BUCKET MOUNTPOINT [OPTION]…
  • s3fs [S3存储桶名] [本地目录名] [OPTION]
  • OPTION是可选项,格式是 –o <option_name>=<option_value>,常用的options有:
     名称 含义 缺省值
    passwd_file 指定挂载的密钥文件
    connect_timeout 设置超时连接等待的时间,单位秒 300
    url 设置访问s3的url http://s3.amazonaws.com
    endpoint 设置s3存储桶的endpoint us-east-1
    allow_other 设置allow_other允许所有用户访问挂载点目录,设置这个选项需要在 /etc/fuse.conf 文件添加user_allow_other选项

手动挂载AWS海外区域S3存储桶

  • 命令格式:s3fs [S3存储桶名] [本地目录名] -o passwd_file=[密钥文件名] -o endpoint=[区域名]
[root@us-prod-sre-jumpserver-1 centos]# s3fs classroom-test /data2 -o passwd_file=/root/.passwd-s3fs -o endpoint=us-west-1

检查挂载结果

  • 挂载操作执行结束后,可以使用Linux “df”命令查看挂载是否成功。出现类似下面256T的s3fs文件系统即表示挂载成功。用户就可以进入本地挂载目录去访问存储在S3存储桶中的对象。
[root@us-prod-sre-jumpserver-1 centos]# df -h
Filesystem                          Size  Used Avail Use% Mounted on
devtmpfs                            7.6G     0  7.6G   0% /dev
tmpfs                               7.6G     0  7.6G   0% /dev/shm
tmpfs                               7.6G   17M  7.6G   1% /run
tmpfs                               7.6G     0  7.6G   0% /sys/fs/cgroup
/dev/nvme0n1p1                      100G   37G   64G  37% /
/dev/mapper/vg_name--1-lvm_name--1  500G  639M  500G   1% /data
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/4ef8bd40f36f602d11616b61ebbdf8e3c76b19c6209863d5f2cc325d630ced37/merged
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/4604d182a7d4b82103be4023da66430f62ec40f6d2b8d1eb6893ab3687307164/merged
shm                                  64M     0   64M   0% /var/lib/docker/containers/5c2fcef06083c63e0d10ff342d715ff1032fc470771a8675016b8d0a3ef318da/mounts/shm
shm                                  64M     0   64M   0% /var/lib/docker/containers/07e88a6dcf9f18a2aaf705efd8fbf40267eaf8d22430049e5236344ba3d096cf/mounts/shm
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/a18b42eec3da2254a106aa1654c033f7f275dc52fd98890dd34fb226ca92a899/merged
shm                                  64M     0   64M   0% /var/lib/docker/containers/b348e536054d1b931678c4a20704a9e96e4280068b9404b3eb3687ac27a8cc3c/mounts/shm
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/dfd6cd8bd8ce52eb766da25cd9c17b5789547a69bc4327883820051499595f2f/merged
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/71128b609f98c64badce4f1b689f60659684c327a6039342455d2b10cef45651/merged
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/e1e49334d42a2cf4961bdbcb91df0dfe472696b96ffded1fa04236d070e7846e/merged
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/f3ce399584d3d9d32eae3e2d38b06a8d062b6cb78770c327631e484481d34eda/merged
shm                                  64M     0   64M   0% /var/lib/docker/containers/3177c81491b83070a7c4a127a42d2205eda9878a062141d6386a3a28ed3a37f3/mounts/shm
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/3b13e92631af0a53eab2a56ff1b27bc3172e0f2ea2bae7ff6c1aad339b7279b7/merged
shm                                  64M     0   64M   0% /var/lib/docker/containers/126a11cf624a6c02f990d9e28dda1d823451f8e4a47eaffde0f1d7a0833e6a1c/mounts/shm
shm                                  64M     0   64M   0% /var/lib/docker/containers/3e5b35b19823d7df064b3357945c46e63380aa79462cc486679d5b701f1ce78b/mounts/shm
shm                                  64M  124K   64M   1% /var/lib/docker/containers/466e0f2552cad5ab3e94980919b113606b0ee990d67310c40086a4211a6c5344/mounts/shm
shm                                  64M     0   64M   0% /var/lib/docker/containers/10c3ae6c4b063e7bfffdc0c327794dba9e442a573ef78b88adac3f28be0816e3/mounts/shm
tmpfs                               1.6G     0  1.6G   0% /run/user/1000
s3fs                                 16E     0   16E   0% /data2

卸载挂载的S3存储桶

[root@us-prod-sre-jumpserver-1 centos]# umount /data2
[root@us-prod-sre-jumpserver-1 centos]# df -h
Filesystem                          Size  Used Avail Use% Mounted on
devtmpfs                            7.6G     0  7.6G   0% /dev
tmpfs                               7.6G     0  7.6G   0% /dev/shm
tmpfs                               7.6G   17M  7.6G   1% /run
tmpfs                               7.6G     0  7.6G   0% /sys/fs/cgroup
/dev/nvme0n1p1                      100G   37G   64G  37% /
/dev/mapper/vg_name--1-lvm_name--1  500G  639M  500G   1% /data
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/4ef8bd40f36f602d11616b61ebbdf8e3c76b19c6209863d5f2cc325d630ced37/merged
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/4604d182a7d4b82103be4023da66430f62ec40f6d2b8d1eb6893ab3687307164/merged
shm                                  64M     0   64M   0% /var/lib/docker/containers/5c2fcef06083c63e0d10ff342d715ff1032fc470771a8675016b8d0a3ef318da/mounts/shm
shm                                  64M     0   64M   0% /var/lib/docker/containers/07e88a6dcf9f18a2aaf705efd8fbf40267eaf8d22430049e5236344ba3d096cf/mounts/shm
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/a18b42eec3da2254a106aa1654c033f7f275dc52fd98890dd34fb226ca92a899/merged
shm                                  64M     0   64M   0% /var/lib/docker/containers/b348e536054d1b931678c4a20704a9e96e4280068b9404b3eb3687ac27a8cc3c/mounts/shm
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/dfd6cd8bd8ce52eb766da25cd9c17b5789547a69bc4327883820051499595f2f/merged
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/71128b609f98c64badce4f1b689f60659684c327a6039342455d2b10cef45651/merged
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/e1e49334d42a2cf4961bdbcb91df0dfe472696b96ffded1fa04236d070e7846e/merged
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/f3ce399584d3d9d32eae3e2d38b06a8d062b6cb78770c327631e484481d34eda/merged
shm                                  64M     0   64M   0% /var/lib/docker/containers/3177c81491b83070a7c4a127a42d2205eda9878a062141d6386a3a28ed3a37f3/mounts/shm
overlay                             100G   37G   64G  37% /var/lib/docker/overlay2/3b13e92631af0a53eab2a56ff1b27bc3172e0f2ea2bae7ff6c1aad339b7279b7/merged
shm                                  64M     0   64M   0% /var/lib/docker/containers/126a11cf624a6c02f990d9e28dda1d823451f8e4a47eaffde0f1d7a0833e6a1c/mounts/shm
shm                                  64M     0   64M   0% /var/lib/docker/containers/3e5b35b19823d7df064b3357945c46e63380aa79462cc486679d5b701f1ce78b/mounts/shm
shm                                  64M  124K   64M   1% /var/lib/docker/containers/466e0f2552cad5ab3e94980919b113606b0ee990d67310c40086a4211a6c5344/mounts/shm
shm                                  64M     0   64M   0% /var/lib/docker/containers/10c3ae6c4b063e7bfffdc0c327794dba9e442a573ef78b88adac3f28be0816e3/mounts/shm
tmpfs                               1.6G     0  1.6G   0% /run/user/1000

继续阅读
DevOps
  • 本文由 发表于 2022年7月11日 14:11:57
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
S3迁移到另一个S3 AWS

S3迁移到另一个S3

部署AWS CLI客户端 curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unz...
S3迁移到另一个S3 AWS

S3迁移到另一个S3

部署AWS CLI客户端 curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unz...
评论  0  访客  0

发表评论