Friday, January 22, 2016

Mount S3 bucket di Lokal server

OS yang di gunakan AMI Linux, dependency files untuk s3fs adalah;
– gcc
– libstdc++-devel
– gcc-c++
– fuse
– fuse-devel
– curl-devel
– libxml2-devel
– mailcap
– automake
– openssl-devel

$ yum install -y gcc libstdc++-devel gcc-c++ fuse fuse-devel curl-devel libxml2-devel mailcap automake openssl-devel
download source package menggunakan git ;
$ git clone https://github.com/s3fs-fuse/s3fs-fuse
$ cd s3fs-fuse/

Config source package sebelum di kompile dan install
$ ./autogen.sh
$ ./configure –prefix=/usr –with-openssl

Kompile dan install aplikasi
$ make
$ sudo make install

Verifikasi aplikasi s3fs telah terinstall ;
$ s3fs –version
output ;
Amazon Simple Storage Service File System 1.61
Copyright (C) 2010 Randy Rizun
License GPL2: GNU GPL version 2
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.


Buat file credential untuk akses s3 bucket ;
$ echo NamaBucket:Access_Key_ID:Secret_Key_ID > ~/.passwd-s3fs
$ chmod 0600 ~/.passwd-s3fs

Lalu mount s3 bucket ke lokal server ;
$ s3fs -o allow_other -o use_cache=/tmp NamaBucket /folder/lokal

Parameter Option, bisa baca di bawah;
* The -o allow_other option allows all other users on the server read / write access to the mounted directory. Obviously, this can be a huge security hole.
* The -o use_cache=/tmp option specifies the location where to store locally cached folders and files. This enables local file caching which minimizes downloads.
Note: make certain you have plenty of space dedicated to the cache directory before considering this option. Depending on the size of the files being copied, this directory can fill up very quickly!
* The -o default_acl=public-read-write option will set anything you write to the bucket as publicly viewable and writable (by default, it’s set to private).
* The -o default_acl=public-read option will set anything you write to the bucket as publicly viewable (by default, it’s set to private).

Verifikasi mounting-an sudah berhasil ;
$ grep s3fs /etc/mtab
s3fs /folder/lokal fuse.s3fs rw,nosuid,nodev,allow_other 0 0

atau dengan cara;
$df -Th /folder/lokal
Filesystem Type Size Used Avail Use% Mounted on
s3fs fuse.s3fs 256T 0 256T 0% /folder/lokal

Untuk startup mounting tambahkan mounting ke file /etc/fstab;
s3fs#NamaBucket /folder/lokal fuse allow_other,use_cache=/tmp 0 0

Untuk umount, gunakan perintah;
$ umount /folder/lokal

Sekian & terima kasih.

No comments: