LoginSignup
0
0

More than 1 year has passed since last update.

goofys S3をマウントする

Last updated at Posted at 2021-06-13

初めに

goofys を使うと、S3 をファイルシステムとしてマウントすることができる。FSx for Lustre ではレプリケートされたオブジェクトを取り込むことができなかったが、goofys であれば取り込むことができた。

インストール~マウント

インストール

sudo curl -L https://github.com/kahing/goofys/releases/latest/download/goofys -o /usr/local/bin/goofys
sudo chmod a+x /usr/local/bin/goofys
sudo yum install golang fuse git -y

認証情報の設定

$ aws configure
AWS Access Key ID [None]: XXXXXXXXXXXXXXX
AWS Secret Access Key [None]: YYYYYYYYYYYYYYYYYYY
Default region name [None]: ap-northeast-1
Default output format [None]: json

マウント

mkdir ~/dir
goofys account-a-bucket-0525 ~/dir

ファイルシステムを確認

$ df -h | grep 'dir'
account-a-bucket-0525  1.0P     0  1.0P   0% /home/ec2-user/dir

レプリケーションオブジェクトにアクセス

レプリケーションオブジェクトであることを確認

$ aws s3api head-object --bucket account-a-bucket-0525 --key test_upload_4.txt --version-id JQnupBy2kZdOxhFHZ5v9VU9cvknOKOeA
{
    "AcceptRanges": "bytes",
    "ContentType": "text/plain",
    "LastModified": "Thu, 10 Jun 2021 14:27:50 GMT",
    "ContentLength": 13,
    "ReplicationStatus": "REPLICA",
    "VersionId": "JQnupBy2kZdOxhFHZ5v9VU9cvknOKOeA",
    "ETag": "\"2e0d1f90dbe874f1217a0bbf644219e9\"",
    "ServerSideEncryption": "aws:kms",
    "SSEKMSKeyId": "arn:aws:kms:ap-northeast-1:0123456789012:key/xxxxxxxxxx",
    "Metadata": {}
}

レプリケーションオブジェクトにアクセス

$ cat dir/test_upload_4.txt
test upload

プライベートサブネットからマウントできない

プライベートサブネット

プライベートサブネットからではマウントできない。

$ goofys account-a-bucket-0525 ~/dir
2021/06/13 00:43:11.956051 main.FATAL Unable to mount file system, see syslog for details

パブリックサブネット

マウントしてからインタネットゲートウェイをルートから外してみる。マウントできていることを確認。

$ df -h | grep 'dir'
account-a-bucket-0525  1.0P     0  1.0P   0% /home/ec2-user/dir

パブリックサブネット

マウントポイントにアクセスできる。

$ ls dir
sample.txt       test_upload_2.txt  test_upload_4.txt  test_upload_6.txt
test_goofys.txt  test_upload_3.txt  test_upload_5.txt  test_upload.txt

プライベートサブネット

マウントポイントにアクセスできない。

$ ls dir
ls: reading directory dir: Input/output error

ゲートウェイ型S3エンドポイント

プライベートサブネットからはゲートウェイ型・インターフェース型のS3エンドポイントを使ってもマウントできない。

ゲートウェイ型S3エンドポイント付きプライベートサブネット

マウント後であればゲートウェイ型のS3エンドポイントを使用すればマウントポイントにアクセスできる。

$ ls dir
sample.txt       test_upload_2.txt  test_upload_4.txt  test_upload_6.txt
test_goofys.txt  test_upload_3.txt  test_upload_5.txt  test_upload.txt

インターフェース型S3エンドポイント付きプライベートサブネット

インターフェース型のS3エンドポイントではマウントポイントにアクセスできない。

$ ls dir
ls: reading directory dir: Input/output error

まとめ

(1) goofys はレプリケーションオブジェクトにアクセスできる。

(2) プライベートサブネットから goofys を使うには、

  1. パブリックサブネットでマウントする
  2. ゲートウェイ型S3エンドポイント付きのプライベートサブネットに切り替えてマウントポイントにアクセスする

という流れ。

サブネット マウント マウントポイントアクセス
パブリックサブネット
プライベートサブネット(ゲートウェイ型S3エンドポイント) ×
プライベートサブネット(インターフェース型S3エンドポイント) × ×
プライベートサブネット(エンドポイントなし) × ×

参考記事

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0