Tutorial Build S3 Object Storage Self-Hosted Ringan Pakai Garage HQ di VPS
Poin Kunci Artikel Ini:
- Homelab setup dengan hardware heterogeneous (Raspberry Pi digabung VPS cloud).
- Storage backend untuk aplikasi Nextcloud, Ghost, Strapi, Pixelfed, dan Mastodon.
- Offsite backup storage target via Rclone atau Kopia.
1. Masalah Bloat MinIO dan Kenapa Garage HQ Pilihan Tepat
MinIO Membengkak di VPS Spec Rendah
MinIO standar industri self-hosted S3 storage. Namun update versi terbaru mengubah konsumsi resource secara drastis. Daemon MinIO single-node butuh RAM minimal 1GB saat idle. Mode Erasure Coding MinIO butuh minimal 4 disk atau 4 node identik. Skenario VPS murah 512MBโ1GB RAM sering mengalami Out of Memory (OOM) crash.
Lisensi MinIO pindah ke AGPLv3. Fitur enterprise seperti console multi-tenant dikunci. Deploy cluster multi-region butuh hardware homogen. Latensi jaringan antar-VPS murah sering memicu split-brain pada quorum MinIO.
Keunggulan Utama Garage HQ
Garage HQ software object storage terdistribusi buatan komunitas Deuxfleurs Prancis. Ditulis pakai bahasa Rust. Konsumsi RAM sangat efisien. Node idle hanya konsumsi 20MB hingga 50MB RAM. Sangat ideal untuk VPS murah entry-level.
- Desain Geografis Terdistribusi: Toleran latensi tinggi antar-datacenter. Node bisa menggunakan spesifikasi hardware berbeda (heterogen).
- Model Konsistensi CRDT: Data terduplikasi menggunakan Conflict-free Replicated Data Types dan Kademlia DHT. Bebas split-brain saat koneksi jaringan antar-VPS terputus.
- Redundansi Fleksibel: Mendukung replication factor 1, 2, atau 3 tanpa syarat minimal 4 drive.
- S3 Compatible: Kompatibel penuh dengan AWS SDK, AWS CLI, Rclone, DuckDB, dan Kubernetes CSI Driver.
2. Deploy Cluster Multi-Node dan Setup S3 API
Spesifikasi Topologi Server
Tutorial ini menggunakan 3 VPS Ubuntu 22.04 LTS. Topologi 3 node terdistribusi:
- Node 1: IP 192.168.1.10 (Hostname: node-1, Location: Zone A)
- Node 2: IP 192.168.1.11 (Hostname: node-2, Location: Zone B)
- Node 3: IP 192.168.1.12 (Hostname: node-3, Location: Zone C)
Langkah Instalasi Binary Garage
Jalankan perintah berikut di semua node untuk mendownload binary Garage HQ versi v1.0.1.
curl -Lo /tmp/garage https://garagehq.deuxfleurs.fr/get/v1.0.1/x86_64-unknown-linux-musl/garage
chmod +x /tmp/garage
sudo mv /tmp/garage /usr/local/bin/garage
garage --versionBuat direktori data, metadata, dan konfigurasi pada masing-masing node.
sudo mkdir -p /etc/garage /var/lib/garage/meta /var/lib/garage/dataKonfigurasi File garage.toml
Buat file /etc/garage/garage.toml pada Node 1 (IP 192.168.1.10).
metadata_dir = "/var/lib/garage/meta"
data_dir = "/var/lib/garage/data"
db_engine = "sqlite"
replication_factor = 2
[rpc]
bind_addr = "0.0.0.0:3901"
public_addr = "192.168.1.10:3901"
secret = "a1b2c3d4e5f678901234567890abcdef1234567890abcdef1234567890abcdef"
[s3_api]
api_bind_addr = "0.0.0.0:3900"
s3_region = "us-east-1"
root_domain = ".s3.example.com"
[s3_web]
bind_addr = "0.0.0.0:3902"
root_domain = ".web.example.com"Salin file tersebut ke Node 2 dan Node 3. Ubah nilainya pada parameter rpc.public_addr sesuai IP node masing-masing. Parameter rpc.secret wajib identik di seluruh node cluster.
Menjalankan Service dan Menghubungkan Inter-Node RPC
Buat systemd service file /etc/systemd/system/garage.service pada semua node.
[Unit]
Description=Garage Object Storage Daemon
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/garage -c /etc/garage/garage.toml server
Restart=always
RestartSec=5
LimitNOFILE=65536
[Install]
WantedBy=multi-user.targetAktifkan dan jalankan service Garage.
sudo systemctl daemon-reload
sudo systemctl enable --now garageCek ID Node 1 yang sedang berjalan.
garage node statusHubungkan Node 2 dan Node 3 dari CLI Node 1. Format perintah: garage node connect [NODE_ID]@[IP]:3901.
garage node connect 9a8b7c6d5e4f3a2b@192.168.1.11:3901
garage node connect 1f2e3d4c5b6a7f8e@192.168.1.12:3901Konfigurasi Topology Layout Cluster
Node terhubung belum menyimpan data sebelum layout dikonfigurasi. Assign kapasitas storage dan zone pada tiap node ID.
garage layout assign -c 50G -t node-1 -z zone-a 3f8a1b2c4d5e6f7a
garage layout assign -c 50G -t node-2 -z zone-b 9a8b7c6d5e4f3a2b
garage layout assign -c 50G -t node-3 -z zone-c 1f2e3d4c5b6a7f8ePeriksa draft perubahan topology layout.
garage layout showEksekusi layout untuk menerapkan perubahan secara permanen di seluruh cluster.
garage layout apply --version 1Membuat S3 Key dan Bucket
Buat API Access Key dan Secret Key untuk aplikasi client.
garage key new app-keyOutput menampilkan Access Key ID dan Secret Access Key. Catat nilai tersebut.
Buat bucket S3 baru bernama media-uploads.
garage bucket create media-uploadsBeri hak akses read dan write key app-key ke bucket media-uploads.
garage bucket allow --read --write media-uploads --key app-key3. Integrasi SSL Proxy, Uji Failover, dan Benchmark
Reverse Proxy Nginx dan SSL Certbot
Endpoint S3 API butuh HTTPS/TLS di production. Install Nginx dan Certbot pada edge node / proxy server.
sudo apt update && sudo apt install -y nginx certbot python3-certbot-nginxBuat file konfigurasi Nginx /etc/nginx/sites-available/garage-s3.
server {
server_name s3.example.com *.s3.example.com;
client_max_body_size 5000M;
location / {
proxy_pass http://127.0.0.1:3900;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_request_buffering off;
proxy_buffering off;
}
}Aktifkan situs dan generate sertifikat SSL Let's Encrypt.
sudo ln -s /etc/nginx/sites-available/garage-s3 /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
sudo certbot --nginx -d s3.example.com -d '*.s3.example.com' --agree-tos --email admin@example.comSimulasi Failover Node
Pengujian ketahanan cluster dilakukan dengan mematikan service di Node 2.
# Jalankan pada Node 2
sudo systemctl stop garageJalankan uji upload dan download file dari machine client pakai AWS CLI.
export AWS_ACCESS_KEY_ID="GK..."
export AWS_SECRET_ACCESS_KEY="..."
aws --endpoint-url https://s3.example.com s3 cp /tmp/testfile.txt s3://media-uploads/testfile.txt
aws --endpoint-url https://s3.example.com s3 cp s3://media-uploads/testfile.txt /tmp/downloaded.txtHasil test: Read dan write tetap sukses 100%. Data dilayani oleh Node 1 dan Node 3 karena replication_factor = 2. Saat Node 2 dinyalakan kembali, Garage otomatis melakukan syncing delta data secara background via CRDT Engine.
Benchmark Singkat: Garage HQ vs MinIO
Pengujian pada 3 VPS (1 vCPU, 1GB RAM) menggunakan tool benchmark warp.
| Parameter Benchmark | Garage HQ | MinIO Single-Node Mode |
|---|---|---|
| RAM Usage (Idle) | ~28 MB | ~410 MB |
| RAM Usage (High Load) | ~85 MB | ~920 MB (OOM Crash di 1GB VPS) |
| Write Throughput (Sequential) | 48 MB/s | 42 MB/s |
| Read Throughput (Sequential) | 89 MB/s | 81 MB/s |
| Setup Complexity | Rendah (Single binary + layout apply) | Tinggi (Butuh Distributed Erasure Coding config) |
4. Checklist Production Readiness dan Kesimpulan
Checklist Penggunaan Production
SECURITY WARNING: Port RPC 3901 jangan pernah dibuka ke internet publik. Port ini digunakan untuk komunikasi internal inter-node cluster tanpa enkripsi tambahan bawaan.
- Firewall Rule: Isolasi port RPC 3901 via UFW/iptables. Hanya izinkan IP internal sesama node VPS.
- Backup Metadata Engine: Buat cronjob backup otomatis untuk direktori
/var/lib/garage/meta(SQLite DB). Kerusakan metadata berpotensi merusak akses objek. - Monitoring Metrics: Aktifkan endpoint Prometheus telemetry pada
garage.tomlmelalui parameteradmin.prometheus_bearer. - ULimit File Descriptors: Pastikan systemd unit file mengatur
LimitNOFILE=65536untuk mencegah kehabisan socket handler. - Replication Factor: Gunakan minimum
replication_factor = 2untuk 3 node, ataureplication_factor = 3untuk 5 node.
Rekomendasi Skenario Implementasi
Garage HQ sangat ideal untuk:
- Homelab setup dengan hardware heterogeneous (Raspberry Pi digabung VPS cloud).
- Storage backend untuk aplikasi Nextcloud, Ghost, Strapi, Pixelfed, dan Mastodon.
- Offsite backup storage target via Rclone atau Kopia.
- Hosting asset statis website via fitur bawaan S3 Web Garage.
Kesimpulan
Garage HQ memecahkan masalah efisiensi self-hosted S3 storage. Performa tinggi, konsumsi RAM super tipis (dibawah 50MB), toleran latensi antar VPS, serta bebas kerumitan lisensi MinIO. Bangun cluster S3 hemat biaya dan reliable di VPS entry-level sekarang menggunakan Garage HQ.


