Ngulik CloudNgulik Linux

Cara Install dan Konfigurasi s3cmd Object Storage

S3CMD

s3cmd adalah utilitas baris perintah yang digunakan untuk membuat bucket s3, mengunggah, mengambil dan mengelola data ke penyimpanan Amazon s3. Artikel ini akan membantu Anda menggunakan cara menginstal s3cmd pada sistem CentOS, RHEL, OpenSUSE, Ubuntu, Debian & LinuxMint dan mengelola bucket s3 melalui baris perintah dalam langkah mudah.

Instal s3cmd di Linux

s3cmd tersedia di repositori rpm default untuk CentOS, RHEL dan sistem Ubuntu, Anda dapat menginstalnya dengan hanya mengeksekusi perintah berikut pada sistem Anda.

  • CentOS / RHEL:
# yum instal s3cmd
  • Ubuntu / Debian:
# sudo apt-get install s3cmd
  • SUSE Linux Enterprise
# zypper addrepo http://s3tools.org/repo/SLE_11/s3tools.repo zypper install s3cmd

Instal S3cmd menggunakan Sumber terbaru

Jika Anda tidak mendapatkan versi terbaru dari s3cmd menggunakan manajer paket, Anda dapat menginstal versi s3cmd terbaru di sistem Anda menggunakan source code. Kunjungi url https://sourceforge.net/projects/s3tools/files/s3cmd/ atau gunakan perintah di bawah untuk mengunduh versi terbaru s3cmd.

# wget https://sourceforge.net/projects/s3tools/files/s3cmd/2.0.1/s3cmd-2.0.1.tar.gz
# tar xzf s3cmd-2.0.1.tar.gz
# cd s3cmd-2.0.1
# sudo python setup.py install

Konfigurasi s3cmd Environment

Untuk mengkonfigurasi s3cmd anda membutuhkan access key dan secret key NEO Object storage Anda. Dapatkan access key dan secret key tersebut pada halaman https://portal.neo.id/.

Setelah mendapatkan access key dan secret key, gunakan perintah di bawah ini untuk mengkonfigurasi s3cmd.

root@donkus:~# s3cmd –configure Enter new values or accept defaults in brackets with Enter. Refer to user manual for detailed description of all options.   Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables.  
Access Key: xxxxxxxxxxxxxxxxxxxxxxx
Secret Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  
Default Region [US]: ID

Use “s3.amazonaws.com” for S3 Endpoint and not modify it to the target Amazon S3. S3 Endpoint [s3.amazonaws.com]: nos.wjv-1.neo.id   Use “%(bucket)s.s3.amazonaws.com” to the target Amazon S3. “%(bucket)s” and “%(location)s” vars can be used if the target S3 system supports dns based buckets. DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]: 443
Encryption password is used to protect your files from reading by unauthorized persons while in transfer to S3 Encryption password: donkus99 Path to GPG program [/usr/bin/gpg]:  

When using secure HTTPS protocol all communication with Amazon S3 servers is protected from 3rd party eavesdropping. This method is slower than plain HTTP, and can only be proxied with Python 2.7 or newer   Use

HTTPS protocol [Yes]: yes  

On some networks all internet access must go through a HTTP proxy. Try setting it here if you can’t connect to S3 directly   HTTP Proxy server name:
New settings:   Access Key: xxxxxxxxxxxxxxxxxxxx  
Secret Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  
Default Region: ID  
S3 Endpoint: nos.wjv-1.neo.id  
DNS-style bucket+hostname:port template for accessing a bucket: 443   Encryption password: donkus99  
Path to GPG program: /usr/bin/gpg  
Use HTTPS protocol: True  
HTTP Proxy server name:  
HTTP Proxy server port: 0  

Test access with supplied credentials? [Y/n] y

Please wait, attempting to list all buckets… Success. Your access key and secret key worked fine 🙂   Now verifying that encryption works… Success. Encryption and decryption worked fine 🙂  

Save settings? [y/N] Y

Configuration saved to ‘/root/.s3cfg’

Daftar Semua Bucket S3

Gunakan perintah berikut untuk mencantumkan semua Bucket s3 di akun Anda.

root@donkus:~# s3cmd ls
2018-09-27 08:58  s3://donkus 2018-10-10 15:45  s3://laraveldon

Mengunggah file dalam Bucket

Perintah di bawah ini akan mengunggah file file.txt ke s3 bucket menggunakan perintah s3cmd.

root@donkus:~# s3cmd put example.txt s3://donkus/

upload: ‘example.txt’ -> ‘s3://donkus/example.txt’  [1 of 1] 0 of 0     0% in    0s     0.00 B/s  done

Mengunggah Direktori dalam Bucket

Jika kita perlu mengunggah seluruh penggunaan direktori -r untuk mengunggahnya secara rekursif seperti di bawah ini.

root@donkus:~# s3cmd put -r testdir s3://donkus/

upload: ‘testdir/test1.txt’ -> ‘s3://donkus/testdir/test1.txt’  [1 of 3] 0 of 0     0% in    0s     0.00 B/s  done

upload: ‘testdir/test2.txt’ -> ‘s3://donkus/testdir/test2.txt’  [2 of 3] 0 of 0     0% in    0s     0.00 B/s  done

upload: ‘testdir/test3.txt’ -> ‘s3://donkus/testdir/test3.txt’  [3 of 3] 0 of 0     0% in    0s     0.00 B/s  done

Daftar Data Bucket S3

Buat daftar objek dari bucket s3 menggunakan switch ls dengan s3cmd.

root@donkus:~# s3cmd ls s3://donkus/           

DIR   s3://donkus/testdir/
2018-11-03 12:28         0   s3://donkus/1.txt
2018-11-03 15:12         0   s3://donkus/example.txt
2018-09-27 11:04      2827   s3://donkus/giobackup-25-september-2018-all.csv

Unduh File dari Bucket

Jjika perlu mengunduh file dari Bucket s3, Gunakan perintah berikut untuk mengunduhnya.

root@donkus:~# s3cmd get s3://donkus/example.txt
download: ‘s3://donkus/example.txt’ -> ‘./example.txt’  [1 of 1] 0 of 0     0% in    0s     0.00 B/s  done

Menghapus Data Bucket S3

Untuk menghapus file dalan Bucket dari s3 bucket gunakan perintah berikut.

root@donkus:~# s3cmd del s3://donkus/1.txt
delete: ‘s3://donkus/1.txt’

Hapus Bucket S3

Jika kita tidak lagi membutuhkan s3 bucket, kita dapat dengan mudah menghapusnya menggunakan perintah berikut. Sebelum menghapus buxket, pastikan isinya kosong.

root@donkus:~# s3cmd rb s3://laraveldon
Bucket ‘s3://laraveldon/’ removed

 

Leave a Response