さくらのVPSに goofys で s3 をマウント
さくらインターネットのVPSで運用しているWEBサービスで、
ディスク容量が足らなくなった。
そうだ、S3 をマウントしよう。
しかも転送が速いと噂の goofys でマウントしようでわないか。
さくらにも S3互換のストレージあるって?
単に慣れの問題です。
ーー
今までは、社内の管理サーバーから公開用の画像をWEBサーバーに rsync で同期。
社内サーバー (rsync) → WEBサーバー
まずは WEBサーバーに S3をマウントし、画像ディレクトリを置き換える。
社内サーバー (rsync) → WEBサーバー (mount) S3
#go言語とfuseをインストール yum -y install golang yum -y install fuse #go が /root/go にインストールされるので、不可視にする mv /root/go /root/.go #パスを通す echo 'export GOPATH=$HOME/.go' >> ~/.bashrc source ~/.bashrc #goofys インストール go get github.com/kahing/goofys go install github.com/kahing/goofys ### awscli のインストール #pip をインストールするため、ez_setup を設定 wget http://peak.telecommunity.com/dist/ez_setup.py python ez_setup.py #pip のインストール easy_install pip #awscli のインストール pip install awscli #aws IAM の設定 aws configure ##マウントの設定 mkdir /mnt/s3 #自動マウント設定 vi /etc/fstab #下記を追記 /root/.go/bin/goofys#バケット名 /mnt/s3 fuse _netdev,allow_other,--dir-mode=0775,--file-mode=0666,--uid=ユーザーID,--gid=グループID 0 0 #マウント実行 mount -a
aws の IAMに、S3FullAccessのパーミッションを忘れずに…。
次は社内から aws s3 sync で直接S3にファイルを転送するように変更。
社内サーバー (aws s3 sync) → S3 (mount) WEBサーバー
ばっちぐー。