본문 바로가기

IT knowledge?/Amazon Web Service

[AWS]S3FS를 이용한 s3 마운트 정리

내부적인 용도로 사용할 서비스에 AWS S3(Simple Storage Service)를 서버에 

mount하여 사용해야하는 이슈가 생겼다.


개인적으로 테스트 한 것을 정리하고자하는 목적으로 글을 작성하였다.



1. 환경정보

      OS: CentOS 6

      S3: S3FS-TEST-BUCKET

      Mount location: /S3FS-TEST-DIR

2. 설치순서

     (1) AWS 포털 IAM 계정 생성.

         권한부여, 보안상 특정 S3에만 사용가능한 Permission policy 생성.

        

 {

"Version": "2012-10-17",

"Statement": [

{

"Effect": "Allow",

"Action": "s3:ListAllMyBuckets",

"Resource": "arn:aws:s3:::*"

},

{

"Effect": "Allow",

"Action": [

"s3:ListBucket",

"s3:GetBucketLocation"

],

"Resource": "arn:aws:s3:::S3 버킷명"

},

{

"Effect": "Allow",

"Action": [

"s3:PutObject",

"s3:GetObject",

"s3:DeleteObject"

],

"Resource": "arn:aws:s3:::S3 버킷명/*"

}

]

}


         (2) 서버 로그인 후 설치 순서

             1) 기존 fuse 삭제

                  yum remove fuse

               ----> S3FS의 경우, fuse 2.9.4 버전이 requirement. yum으로 다운 받을 수                     있는 RPM 버전은 2.9.2가 최신임. 따라서, 컴파일 버전으로 설치할 필요가 있음. 

          아마존 Linux의 경우, 최신버전 기본제공.


              2) Dependency RPM Package 설치

                   yum install automake fuse-devel gcc-c++ git libcurl-devel libxml2-                    devel make openssl-devel 


              3) fuse install

                 wget http://pkgs.fedoraproject.org/repo/pkgs/fuse/fuse-                                    2.9.4.tar.gz/ecb712b5ffc6dffd54f4a405c9b372d8/fuse-2.9.4.tar.gz


                tar xzf fuse-2.9.4.tar.gz 

 

               cd fuse-2.9.4

                ./configure --prefix=/usr/local

                make && make install

                export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig

               ldconfig

              modprobe fuse


              4) Download s3fs

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

            

             5) Change to the extracted directory

                  cd /down/s3fs-fuse

             

             6) Run Auto Generate Shell Script

                 ./autogen.sh

             

             7) Configure package

                 ./configure

             

             8)  Compile and Install Package

                 make && make install

             

             9) Symbolic link s3fs to /usr/bin/

          ln -s /usr/local/bin/s3fs /usr/bin/s3fs

             

               

3. S3 Mount

 (1) Mount Command

  s3fs S3FS-TEST-BUCKET -o use_cache=/tmp -o allow_other /S3FS-TEST-DIR

            (2) fstab 등록

s3fs#S3FS-TEST-BUCKET /S3FS-TEST-DIR fuse allow_other,use_cache=/tmp/cache,uid=userid,gid=groupid 0 0

            (3) umount Command

fusermount -u /S3FS-TEST-DIR


* References

http://wp.yoonc.co.kr/2012/07/ec2%EC%97%90-s3%EB%A5%BC-mount-%ED%95%98%EB%8A%94%EB%B2%95on-ubuntu/

https://www.bonusbits.com/wiki/HowTo:Mount_AWS_S3_Bucket_on_CentOS_EC2_Instance

http://d.hatena.ne.jp/letitride/20140925/1411610072

http://fuse.996288.n3.nabble.com/fuse-warning-td8937.html

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

https://www.noodles.net.nz/2013/02/27/s3fsfuse-on-centosrhel/

'IT knowledge? > Amazon Web Service' 카테고리의 다른 글

별개 S3 접근제어를 위한 IAM Role  (0) 2016.08.11