s3fsをインストールしてbucketをマウントする

f:id:komeiy:20150107164847j:plain

s3fs インストール概要

必要なライブラリをインストールする

$ sudo yum install gcc-c++ fuse-devel openssl-devel libcurl-devel libxml2-devel

s3fsのソースを準備する

以下からcloneするかArchiveから直接落としてください。

https://github.com/s3fs-fuse/s3fs-fuse

インストールの流れ

  1. ./autogen.sh
  2. configure
  3. make
  4. sudo make install

configureはprefix=/オプションを使用できます。

aclocal: command not foundが出た時の対処法

$ sudo ./autogen.sh
./autogen.sh: line 23: aclocal: コマンドが見つかりません
$ sudo yum info automake
利用可能なパッケージ
名前                : automake
アーキテクチャー    : noarch
バージョン          : 1.13.4
リリース            : 3.15.amzn1
容量                : 718 k
リポジトリー        : amzn-main/latest
要約                : A GNU tool for automatically creating Makefiles
URL                 : http://www.gnu.org/software/automake/
ライセンス          : GPLv2+ and GFDL and Public Domain and MIT
説明                : Automake is a tool for automatically generating `Makefile.in'
                    : files compliant with the GNU Coding Standards.
                    :
                    : You should install Automake if you are developing software and would
                    : like to use its ability to automatically generate GNU standard
                    : Makefiles.

マウント用のIAMユーザを作成する

  1. IAMコンソールにアクセス
  2. Create New Usersを選択
  3. 任意の名前でユーザを作成し、Access Key/Secret Access Keyを確認する
  4. 作成したユーザを選択し、Attach User Policyからポリシーを設定する

特定のbucketにのみアクセス可能なポリシーを作成する

  • arn:aws:s3:::mybucket/*

    • アクセスするbucket内のファイルに対する権限を設定
  • arn:aws:s3:::mybucket

    • bucketでlistをgetする時にアクセスする権限を設定
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:*"
            ],
            "Resource": [
                "arn:aws:s3:::<mybucket>/*",
                "arn:aws:s3:::<mybucket>"
            ]
        }
    ]
}

Credentialの設定

$ echo <Access Key>J<Secret Access Key> | sudo tee /etc/passwd-s3fs
$ sudo chmod 640 /etc/passwd-s3fs

mount

$ s3fs my bucket /opt/mybucket

other user

$ ls /opt/mybucket
ls: /opt/mybucketにアクセスできません: 許可がありません
$ fusermount -u /opt/mybucket
$ s3fs my bucket /opt/mybucket -o allow_other

unmount

$ fusermount -u /opt/mybucket

シェアして頂けると嬉しいです。
参考になったという方がいれば是非お願いしますm(_ _ )m
モチベーション維持の観点で非常に励みになります。

このエントリーをはてなブックマークに追加

Amazon Web Services クラウドデザインパターン実装ガイド

Amazon Web Services クラウドデザインパターン実装ガイド

よくわかるAmazonEC2/S3入門 ―AmazonWebServicesクラウド活用と実践 (Software Design plusシリーズ)

よくわかるAmazonEC2/S3入門 ―AmazonWebServicesクラウド活用と実践 (Software Design plusシリーズ)