goofysでs3をmountする。

goofysでEC2からs3をmountする。
作業は全てrootでやってます。

まずはaws configureでアカウント連携

# aws configure
AWS Access Key ID [None]: hogehogehogehogehoge
AWS Secret Access Key [None]: hagehagehagehagehagehgaehage
Default region name [None]: ap-northeast-1
Default output format [None]: json

s3のバケットが見えるか確認

# aws s3 ls
2018-07-31 02:44:55 hogehoge
2018-08-31 01:57:46 xxxxx-test
2018-08-22 07:23:27 hagehagehage

今回mountするのバケットはhogehoge

go関連のパッケージをインストール

# yum install golang fuse git
# go get github.com/kahing/goofys
# go install github.com/kahing/goofys

goのpathを通します。

# export GOPATH=$HOME/go

起動時にpathが通るように.bashrcにも記述

# vim /root/.bashrc
#最終行に適当に記載
export GOPATH=$HOME/go

確認

# go version
go version go1.9.4 linux/amd64
# echo $GOPATH
/root/go

mountするディレクトリを作ります。

# mkdir /mnt/s3

mountします。

# ./go/bin/goofys –region ap-northeast-1 –profile s3 hogehoge /mnt/s3

確認

# df -h | grep hogehoge
hogehoge 1.0P 0 1.0P 0% /mnt/s3

mountできました。
次は起動時に自動mount設定です。
fstabにこんな感じで書けばいいです。

# cat /etc/fstab | grep hogehoge
/root/go/bin/goofys#hogehoge /mnt/s3 fuse _netdev,allow_other,–file-mode=0666,–uid=500,–gid=500 0 0

rebootしてmountされているか確認して終了。

タグ . ブックマークする パーマリンク.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です