본문 바로가기

퍼블릭 클라우드

[AWS] Amazon Linux 2에서 goofys 설치 및 S3 마운트하기

728x90

Amazon Linux 2에서 goofys 설치 및 S3 마운트하기

Golang fuse 설치

$ yum install -y golang fuse
==========================================================================
 Package                          Arch           Version
==========================================================================
Installing:
 fuse                             x86_64         2.9.2-11.amzn2
 golang                           x86_64         1.15.12-1.amzn2.0.1
Installing for dependencies:
 apr                              x86_64         1.6.3-5.amzn2.0.2
 apr-util                         x86_64         1.6.1-5.amzn2.0.2
 apr-util-bdb                     x86_64         1.6.1-5.amzn2.0.2
 cpp                              x86_64         7.3.1-13.amzn2
 emacs-filesystem                 noarch         1:27.1-1.amzn2.0.1
 gcc                              x86_64         7.3.1-13.amzn2
 git                              x86_64         2.32.0-1.amzn2.0.1
 git-core                         x86_64         2.32.0-1.amzn2.0.1
 git-core-doc                     noarch         2.32.0-1.amzn2.0.1
 glibc-devel                      x86_64         2.26-48.amzn2
 glibc-headers                    x86_64         2.26-48.amzn2
 gnutls                           x86_64         3.3.29-9.amzn2
 golang-bin                       x86_64         1.15.12-1.amzn2.0.1
 golang-src                       noarch         1.15.12-1.amzn2.0.1
 kernel-headers                   x86_64         4.14.238-182.422.amzn2
 libatomic                        x86_64         7.3.1-13.amzn2
 libcilkrts                       x86_64         7.3.1-13.amzn2
 libitm                           x86_64         7.3.1-13.amzn2
 libmodman                        x86_64         2.0.1-8.amzn2.0.2
 libmpc                           x86_64         1.0.1-3.amzn2.0.2
 libmpx                           x86_64         7.3.1-13.amzn2
 libproxy                         x86_64         0.4.11-10.amzn2.0.3
 libquadmath                      x86_64         7.3.1-13.amzn2
 libsanitizer                     x86_64         7.3.1-13.amzn2
 mercurial                        x86_64         2.6.2-10.amzn2
 mpfr                             x86_64         3.1.1-4.amzn2.0.2
 neon                             x86_64         0.30.0-3.amzn2.0.2
 pakchois                         x86_64         0.4-10.amzn2.0.2
 perl-Error                       noarch         1:0.17020-2.amzn2
 perl-Git                         noarch         2.32.0-1.amzn2.0.1
 perl-TermReadKey                 x86_64         2.30-20.amzn2.0.2
 subversion                       x86_64         1.7.14-16.amzn2.0.1
 subversion-libs                  x86_64         1.7.14-16.amzn2.0.1
 trousers                         x86_64         0.3.14-2.amzn2.0.2
==========================================================================
$ go version
go version go1.15.12 linux/amd64

go 환경 변수 설정

$ which go
/usr/bin/go

$ export GOBIN=/usr/bin

$ go env | egrep 'GOROOT|GOBIN|GOPATH'
GOBIN="/usr/bin"
GOPATH="/root/go"
GOROOT="/usr/lib/golang"

goofys 설치

goofys GITHUB : https://github.com/kahing/goofys

1)설치 실패 ㅠㅠ

$ go get github.com/kahing/goofys
# github.com/kahing/goofys/api/common
/root/go/src/github.com/kahing/goofys/api/common/conf_azure.go:272:34: accountsRes.Value undefined (type storage.AccountListResultPage has no field or method Value)
/root/go/src/github.com/kahing/goofys/api/common/conf_azure.go:373:35: not enough arguments in call to client.ListKeys
	have (context.Context, string, string)
	want (context.Context, string, string, storage.ListKeyExpand)

$ go install github.com/kahing/goofys
# github.com/kahing/goofys/api/common
/root/go/src/github.com/kahing/goofys/api/common/conf_azure.go:272:34: accountsRes.Value undefined (type storage.AccountListResultPage has no field or method Value)
/root/go/src/github.com/kahing/goofys/api/common/conf_azure.go:373:35: not enough arguments in call to client.ListKeys
	have (context.Context, string, string)
	want (context.Context, string, string, storage.ListKeyExpand)

2) 설치

$ wget http://bit.ly/goofys-latest -O /usr/local/bin/goofys

$ chmod +x /usr/local/bin/goofys

$ goofys --version
goofys version 0.19.0-943e017724ea820eb4185419ef3c41d6f921a324

AWS Access Key 등록

 : EC2 인스턴스에서 S3에 액세스하기 위한 액세스 키 설정

$ aws --version
aws-cli/1.18.147 Python/2.7.18 Linux/4.14.232-177.418.amzn2.x86_64 botocore/1.18.6

'aws configure' 명령어로 Access Key 등록

$ aws configure
AWS Access Key ID [None]: accesskey
AWS Secret Access Key [None]: secretkey
Default region name [None]: ap-northeast-2
Default output format [None]: json

edit로  Access Key 등록

$ vim ~/.aws/credentials
[default]
aws_access_key_id = accesskey
aws_secret_access_key = secretkey

$ vim ~/.aws/config
[default]
output = json
region = ap-northeast-2

Access Key 리스트 확인

$ aws configure list
      Name                    Value             Type    Location
      ----                    -----             ----    --------
   profile                <not set>             None    None
access_key     ****************KKK7 shared-credentials-file
secret_key     ****************LyeU shared-credentials-file
    region           ap-northeast-2      config-file    ~/.aws/config

AWS S3 마운트(Goofys 마운트)

goofys <S3버킷> <마운트할 경로>
goofys <S3버킷:접두사> <마운트할 경로>

$ mkdir /awsS3

$ goofys test-goofys1 /awsS3

$ df -h | grep -v tmpfs
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p1  8.0G  4.8G  3.3G  60% /
test-goofys1    1.0P     0  1.0P   0% /awsS3

fstab 마운트(/etc/fstab)
goofys#<S3버킷> <마운트할 경로> fuse [마운트 옵션]

$ umount /awsS3


$ vim /etc/fstab
goofys#test-goofys1	/awsS3	fuse	_netdev,allow_other	0 0

$ mount -av
/                        : ignored
/awsS3                   : successfully mounted

$ df -h | grep -v tmpfs
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p1  8.0G  4.8G  3.3G  60% /
test-goofys1    1.0P     0  1.0P   0% /awsS3

uid, gid 추가(dir-mode, file-mode)

$ cat /etc/fstab 
#
UUID=f82063bb-28ab-42bc-baa2-b9180b861te7 / xfs defaults,noatime 1 1
#aws s3 buckets
goofys#s3bucket-01 /app/awss3/image fuse _netdev,allow_other,--uid=5000,--gid=5000 0 0
goofys#s3bucket-02 /app/awss3/websource fuse _netdev,allow_other,--uid=5000,--gid=5000 0 0
#goofys#s3bucket-01 /app/awss3/image fuse _netdev,allow_other,--dir-mode=0777,--file-mode=0666,--uid=5000,--gid=5000 0 0
728x90