LoginSignup
4
5

More than 5 years have passed since last update.

s3fsで複数バケットをマウントする方法

Last updated at Posted at 2016-02-08

はまった割に同じ事例を見つけられなかったので。

まず結論から先に書く。
s3fsで複数バケットにマウントしたい場合、
まず/etc/passwd-s3fsにバケット数分のパスワード情報を記述した上で、
マウント時のオプションにpasswd_file=/etc/passwd-s3fsを追記してやる必要がある。
以下詳細。

詳細手順

/etc/passwd-s3fsの記述

(まずそもそも、パスワードファイルの格納先は別に/etc/passwd-s3fs固定ではないけれども、簡単のため、/etc/passwd-s3fsにファイルを置くという前提で話を進める)
このファイルに複数のバケットのパスワード情報を記述したい場合、

bucketName:accessKeyId:secretAccessKey

のようにバケット名を含むパスワード情報を記述する。これを、下記のようにバケット数分記述する。

bucketName1:accessKeyId1:secretAccessKey1
bucketName2:accessKeyId2:secretAccessKey2

書き終わったら、/etc/passwd-s3fsの権限を変更する。/etc/passwd-s3fsの場合は640でいいらしい。

sudo chmod 640 /etc/passwd-s3fs

ファイルの設定は以上。ここまではマニュアルに明示されているので問題ないはず。

マウントの方法について

ここではまった。はまり方としては、bucketName1をs3fsでマウント(これは成功)し、次いでbucketName2をマウントしようとすると、下記のようなエラーが発生した。

s3fs: could not establish security credentials, check documentation

manやwikiを読んで試行錯誤した結果、パスワードファイルを明示してやらなければいけなかったらしい。

(NG)s3fs bucketName2 /mnt/s3 -o allow_other,use_cache=/tmp,uid=497,gid=497
(OK)s3fs bucketName2 /mnt/s3 -o allow_other,use_cache=/tmp,uid=497,gid=497,passwd_file=/etc/passwd-s3fs

以上。

4
5
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
4
5