さくらvpsでs3のストレージをマウント
s3fsというソフトウェアを使用する
前準備 libxml2をインストール
# yum -y install libxml2 libxml2-devel
前準備 fuseをインストール
# wget http://sourceforge.net/projects/fuse/files/fuse-2.X/2.9.3/fuse-2.9.3.tar.gz # tar xvfz fuse-2.9.3.tar.gz # cd fuse-2.9.3 # ./configure prefix=/usr # make # make install # ldconfig # modprobe fuse
AWS IAMでs3アクセスユーザを作成
IAM -> Users -> Create New Userと進みユーザ名を入力
Show User Security Credintials でAccess Key IDとSecret Access Key をメモ
作成したユーザを選択して、Attach User Policy からAmazon S3 Full Accessを選択
Apply Policyにてpermissionを追加
s3fsのインストール
# wget http://s3fs.googlecode.com/files/s3fs-1.74.tar.gz # cd s3fs-1.74 # export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/lib64/pkgconfig/ # ./configure --prefix=/usr # make # make install
メモをしたAccess keyを設定
# echo 'Access Key ID:Secret Access Key' > /etc/passwd-s3fs # chmod 640 /etc/passwd-s3fs
マウントポイントの作成
# mkdir /mnt/s3
s3マウント
# s3fs letitride /mnt/s3/ -o allow_other,default_acl=public_read fuse: warning: library too old, some operations may not not work
とエラーが出る。
古いfuseを削除
# rpm -qa | grep fuse fuse-libs-2.8.3-4.el6.x86_64 # yum remove fuse-libs
s3マウント
# s3fs letitride /mnt/s3/ -o allow_other,default_acl=public_read # df Filesystem 1K-blocks Used Available Use% Mounted on /dev/vda3 100893076 7532680 88235228 8% / tmpfs 510112 0 510112 0% /dev/shm /dev/vda1 247919 95886 139233 41% /boot s3fs 274877906944 0 274877906944 0% /mnt/s3
動作確認
# mkdir -p /s3/sample/01 # vi /s3/sample/01/first.txt # ll /mnt/s3/sanmple/01/ 合計 1 -rw-r--r-- 1 root root 0 9月 25 10:33 2014 first.txt