๐ป ์์คํ ์ค์น ๋ฐ ์คํ ์๊ตฌ์ฌ์ (System Requirements)
์ต์ FerretDB v2 (ghcr.io/ferretdb/ferretdb:2) ๋ฐ PostgreSQL 17 + DocumentDB ํ์ฅ (ghcr.io/ferretdb/postgres-documentdb:17) ๊ธฐ์ค ์๊ตฌ์ฌ์์
๋๋ค.
| ๊ตฌ๋ถ | ์ต์ ์ฌ์ (Minimum) | ๊ถ์ฅ ์ฌ์ (Recommended) |
|---|---|---|
| ์ด์์ฒด์ (OS) | Linux, macOS, Windows (Docker Desktop / WSL2) | Ubuntu 24.04 LTS / Debian 12 / Rocky Linux 9 (x86_64, ARM64) |
| CPU | 2 vCPU | 4 ~ 8+ vCPU (์ง๊ณ ์ฟผ๋ฆฌ ๋ฐ ๋์ ์ปค๋ฅ์ ์ฒ๋ฆฌ์ฉ) |
| ๋ฉ๋ชจ๋ฆฌ (RAM) | 2 GB (ํ๊ฐ์ฉ ์ฌ์ธ์ ์ปจํ ์ด๋ ๊ธฐ์ค) | 8 GB ~ 32 GB+ (shared_buffers ๋ฐ ์ธ๋ฑ์ค ์บ์ฑ ํ๋ณด) |
| ๋์คํฌ (Storage) | 5 GB ์ฌ์ ๊ณต๊ฐ | NVMe SSD (PostgreSQL WAL + BSON ๋ฐ์ดํฐ ๋ณผ๋ฅจ ๋ถ๋ฆฌ ๊ถ์ฅ) |
| ๋ฐํ์ / ํด๋ผ์ด์ธํธ | Docker 24+, mongosh 2.x ๋๋ ๊ณต์ MongoDB ๋๋ผ์ด๋ฒ | Docker Compose v2 / Kubernetes + PostgreSQL 17 + pg_documentdb |
์ต์ ๋ฒ์ ๋น ๋ฅธ ์คํ (ํ๊ฐ์ฉ ์ฌ์ธ์ vs ๋ถ๋ฆฌํ)
# ๋ฐฉ๋ฒ A: ํ
์คํธ/ํ์ต์ฉ ์ฌ์ธ์ ์ด๋ฏธ์ง (PostgreSQL + DocumentDB + FerretDB ํตํฉ)
docker run -d --name ferretdb-eval \
-p 27017:27017 \
-e POSTGRES_USER=ferret \
-e POSTGRES_PASSWORD=secretpass \
-v ferretdb_eval_data:/var/lib/postgresql/data \
ghcr.io/ferretdb/ferretdb-eval:2
# mongosh๋ก ์ฆ์ ์ ์ ํ์ธ (๊ธฐ์กด MongoDB ํด๋ผ์ด์ธํธ ๊ทธ๋๋ก ์ฌ์ฉ)
mongosh "mongodb://ferret:secretpass@127.0.0.1:27017/appdb?authMechanism=PLAIN"
๐ง FerretDB v2 ๋ฉํ ๋ชจ๋ธ (MongoDB Wire Protocol + PostgreSQL DocumentDB)
FerretDB v1์ MongoDB ์ฟผ๋ฆฌ๋ฅผ ์ผ๋ฐ SQL ํ
์ด๋ธ๋ก ๋ณํํ์ผ๋, FerretDB v2๋ **PostgreSQL์ฉ ์คํ์์ค DocumentDB ํ์ฅ(pg_documentdb)**์ ๋ฐฑ์๋ ์์ง์ผ๋ก ์ฌ์ฉํ์ฌ ๋ค์ดํฐ๋ธ BSON ์ ์ฅ, ๋ณตํฉ ์ธ๋ฑ์ค, ์ง๊ณ ํ์ดํ๋ผ์ธ ๋ฐ ๋ฒกํฐ ๊ฒ์์ PostgreSQL ๋ด๋ถ์์ ์ง์ ์ฒ๋ฆฌํฉ๋๋ค.
โโโโโโโโโโโโโโโโโโโโโโโโโโโ MongoDB Wire Protocol (:27017)
โ mongosh / PyMongo / โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Node MongoDB Driver / โ โผ
โ Spring Data MongoDB โ โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ โ FerretDB v2 Proxy โ
โ (ํ๋กํ ์ฝ ๋ณํ/์ธ์ฆ) โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โ PostgreSQL Protocol (:5432)
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PostgreSQL 17 + โ
โ pg_documentdb ํ์ฅ โ
โ (๋ค์ดํฐ๋ธ BSON/์ธ๋ฑ์ค) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
- ๋ฒค๋ ๋ฝ์ธ ํด๋ฐฉ: MongoDB SSPL ๋ผ์ด์ ์ค ์ ์ฝ ์์ด 100% ์คํ์์ค(Apache 2.0 / MIT) ์คํ์ผ๋ก ๊ธฐ์กด MongoDB ์ฑ์ ๊ทธ๋๋ก ๊ตฌ๋ํ ์ ์์ต๋๋ค.
- PostgreSQL ์ํ๊ณ ๊ณต์ : PostgreSQL์ ๋ฐฑ์
(
pg_dump/WAL), ๋ณต์ , ๋ชจ๋ํฐ๋ง, ํด๋ผ์ฐ๋ ๊ด๋ฆฌํ DB ์ธํ๋ผ๋ฅผ ๊ทธ๋๋ก ํ์ฉํฉ๋๋ค.
๐ ๋จ๊ณ๋ณ ์ ์ง์ ์ค์ต (Step-by-Step Walkthrough)
[์ด๋ณด์ 1๋จ๊ณ] mongosh๋ก ์ฒซ ๋ํ๋จผํธ CRUD ์ค์ต
ferretdb-eval:2 ์ปจํ
์ด๋์ mongosh๋ก ์ ์ํ ๋ค, ์ผ๋ฐ MongoDB์ ๋์ผํ๊ฒ DBยท์ปฌ๋ ์
์์ฑ ๋ฐ CRUD๋ฅผ ์ํํฉ๋๋ค.
// 1. ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ ํ (์๋ ์์ฑ)
use shop_db
// 2. ๋จ์ผ ๋ฐ ๋ค์ค ๋ํ๋จผํธ ์ฝ์
db.products.insertOne({
sku: "KB-MECH-01",
name: "๋ฌด์ ๊ธฐ๊ณ์ ํค๋ณด๋",
price: 129000,
stock: 25,
tags: ["keyboard", "wireless", "peripherals"],
createdAt: new Date()
})
db.products.insertMany([
{ sku: "MS-ERG-02", name: "๋ฒํฐ์ปฌ ๋ฌด์ ๋ง์ฐ์ค", price: 69000, stock: 40, tags: ["mouse", "wireless"] },
{ sku: "MN-4K-03", name: "27์ธ์น 4K ๋ชจ๋ํฐ", price: 450000, stock: 8, tags: ["monitor", "4k"] }
])
// 3. ์กฐ๊ฑด ์กฐํ ๋ฐ ํ๋ก์ ์
db.products.find(
{ price: { $gte: 70000 }, tags: "wireless" },
{ _id: 0, sku: 1, name: 1, price: 1 }
)
// ์์ ์ถ๋ ฅ: [ { sku: 'KB-MECH-01', name: '๋ฌด์ ๊ธฐ๊ณ์ ํค๋ณด๋', price: 129000 } ]
// 4. ์ฌ๊ณ ์ฐจ๊ฐ ($inc) ๋ฐ ์ญ์
db.products.updateOne({ sku: "KB-MECH-01" }, { $inc: { stock: -2 } })
db.products.deleteOne({ sku: "MN-4K-03" })
[2๋จ๊ณ] Docker Compose ๋ถ๋ฆฌํ ๊ตฌ์ฑ & ์ ํ๋ฆฌ์ผ์ด์ SDK ์ฐ๋
๊ฐ๋ฐ/์ด์ ํ๊ฒฝ์์๋ PostgreSQL(DocumentDB)๊ณผ FerretDB ์ปจํ ์ด๋๋ฅผ ๋ถ๋ฆฌํ์ฌ ๊ตฌ์ฑํ๋ ๊ฒ์ด ๊ณต์ ํ์ค์ ๋๋ค.
# compose.yml (FerretDB v2 ๊ณต์ ๊ถ์ฅ ๋ถ๋ฆฌ ๊ตฌ์ฑ)
services:
postgres:
image: ghcr.io/ferretdb/postgres-documentdb:17
restart: unless-stopped
environment:
POSTGRES_USER: ferret_admin
POSTGRES_PASSWORD: strong_password_2026
POSTGRES_DB: postgres
volumes:
- pg_documentdb_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ferret_admin -d postgres"]
interval: 5s
timeout: 5s
retries: 5
ferretdb:
image: ghcr.io/ferretdb/ferretdb:2
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
ports:
- "27017:27017"
environment:
FERRETDB_POSTGRESQL_URL: postgres://ferret_admin:strong_password_2026@postgres:5432/postgres
volumes:
pg_documentdb_data:
# ๋ฐฑ๊ทธ๋ผ์ด๋ ์คํ ๋ฐ ์ํ ํ์ธ
docker compose up -d
docker compose ps
Node.js (mongodb ๊ณต์ ๋๋ผ์ด๋ฒ) ์ฐ๋ ์์
// app.mjs (npm install mongodb)
import { MongoClient } from 'mongodb';
const uri = 'mongodb://ferret_admin:strong_password_2026@127.0.0.1:27017/appdb?authMechanism=PLAIN';
const client = new MongoClient(uri);
async function main() {
await client.connect();
const db = client.db('appdb');
const orders = db.collection('orders');
await orders.insertOne({
orderNo: 'ORD-2026-001',
userId: 'user_101',
amount: 129000,
status: 'PAID',
orderedAt: new Date(),
});
const paidOrders = await orders.find({ status: 'PAID' }).toArray();
console.log('๊ฒฐ์ ์๋ฃ ์ฃผ๋ฌธ:', paidOrders.length, paidOrders[0].orderNo);
}
main()
.catch(console.error)
.finally(() => client.close());
Python (pymongo) ์ฐ๋ ์์
# app.py (pip install pymongo)
from pymongo import MongoClient
uri = "mongodb://ferret_admin:strong_password_2026@127.0.0.1:27017/appdb?authMechanism=PLAIN"
with MongoClient(uri) as client:
db = client["appdb"]
col = db["events"]
col.insert_one({"type": "LOGIN", "user": "lucky", "ip": "10.0.0.12"})
doc = col.find_one({"user": "lucky"}, {"_id": 0})
print("์กฐํ ๊ฒฐ๊ณผ:", doc)
# ์์ ์ถ๋ ฅ: ์กฐํ ๊ฒฐ๊ณผ: {'type': 'LOGIN', 'user': 'lucky', 'ip': '10.0.0.12'}
[3๋จ๊ณ] ์ธ๋ฑ์ค, Aggregation Pipeline & ๊ธฐ์กด PostgreSQL ํ์ฅ ํตํฉ
1) ์ธ๋ฑ์ค & ์ง๊ณ ํ์ดํ๋ผ์ธ (Aggregation)
// ์ ๋ํฌ ์ธ๋ฑ์ค & ๋ณตํฉ ์ ๋ ฌ ์ธ๋ฑ์ค ์์ฑ
db.products.createIndex({ sku: 1 }, { unique: true })
db.orders.createIndex({ userId: 1, orderedAt: -1 })
// ํ๊ทธ๋ณ ์ํ ์ ๋ฐ ํ๊ท ๊ฐ๊ฒฉ ์ง๊ณ
db.products.aggregate([
{ $unwind: "$tags" },
{
$group: {
_id: "$tags",
count: { $sum: 1 },
avgPrice: { $avg: "$price" }
}
},
{ $sort: { count: -1 } }
])
2) ๊ธฐ์กด PostgreSQL ์๋ฒ์ DocumentDB ํ์ฅ ์ง์ ํ์ฑํํ๊ธฐ
์ง์ ์ด์ํ๋ PostgreSQL 17(Linux DEB/RPM ํจํค์ง ์ค์น ํ๊ฒฝ)์ DocumentDB ํ์ฅ์ ๋ก๋ํ๋ ค๋ฉด postgresql.conf์ SQL ํ์ฅ ๋ฑ๋ก์ด ํ์ํฉ๋๋ค.
# /etc/postgresql/17/main/postgresql.conf
shared_preload_libraries = 'pg_cron,pg_documentdb_core,pg_documentdb'
cron.database_name = 'postgres'
-- PostgreSQL ์ฌ์์ ํ ํ์ฅ ํ์ฑํ
CREATE EXTENSION IF NOT EXISTS documentdb CASCADE;
-- DocumentDB ํ์ฅ ์ค์น ํ์ธ
SELECT extname, extversion FROM pg_extension WHERE extname LIKE 'documentdb%';
๐ ๏ธ ์ฃผ์ ํ๊ฒฝ ๋ณ์ & ์ด์ ๋ช ๋ น์ด ๋ ํผ๋ฐ์ค
| ํ๊ฒฝ ๋ณ์ / ํ๋๊ทธ | ๊ธฐ๋ณธ๊ฐ | ์ค๋ช |
|---|---|---|
FERRETDB_POSTGRESQL_URL | - | ๋ฐฑ์๋ PostgreSQL ์ฐ๊ฒฐ URI (postgres://user:pass@host:5432/db) |
FERRETDB_LISTEN_ADDR | :27017 | MongoDB ์์ด์ด ํ๋กํ ์ฝ ๋ฆฌ์จ ์ฃผ์ ๋ฐ ํฌํธ |
FERRETDB_LISTEN_TLS | - | TLS ๋ฆฌ์จ ์ฃผ์ (์: :27018, ์ธ์ฆ์ ๊ฒฝ๋ก ํจ๊ป ์ง์ ) |
FERRETDB_LISTEN_TLS_CERT_FILE | - | ์๋ฒ TLS ์ธ์ฆ์(.pem/.crt) ๊ฒฝ๋ก |
FERRETDB_LISTEN_TLS_KEY_FILE | - | ์๋ฒ TLS ๊ฐ์ธํค(.key) ๊ฒฝ๋ก |
FERRETDB_LOG_LEVEL | info | ๋ก๊ทธ ๋ ๋ฒจ (debug, info, warn, error) |
FERRETDB_METRICS_ADDR | :8088 | Prometheus ๋ฉํธ๋ฆญ ๋ฐ ํฌ์ค์ฒดํฌ ๋
ธ์ถ ์ฃผ์ (/metrics) |
โ ๏ธ ์ค๋ฌด ์ฃผ์์ฌํญ & ํ๋ก๋์ ์ฒดํฌ๋ฆฌ์คํธ
- FerretDB v1 โ v2 ์
๊ทธ๋ ์ด๋ ์ฃผ์: v1์ SQL ๊ธฐ๋ฐ ์คํค๋ง์ v2์
pg_documentdbBSON ์ ์ฅ ๊ตฌ์กฐ๋ ๋ด๋ถ ํ ์ด๋ธ ํฌ๋งท์ด ๋ค๋ฆ ๋๋ค. v1์์ v2๋ก ์ ํํ ๋๋mongodump/mongorestore๋ก ๋ ผ๋ฆฌ์ ๋ฐฑ์ ํ ๋ณต์ํด์ผ ํฉ๋๋ค. - ์ด๋ฏธ์ง ๋ฒ์ ํ์ด๋ง ์ ์ง:
ghcr.io/ferretdb/ferretdb:2์ghcr.io/ferretdb/postgres-documentdb:17์ ๋ฆด๋ฆฌ์ค ์ฃผ๊ธฐ๊ฐ ์ฐ๋๋๋ฏ๋ก ํ๋ก๋์ ์์๋:2๋์ ๊ตฌ์ฒด์ ํ๊ทธ(์::2.8.0๋ฐ ๋์ DocumentDB ํ๊ทธ)๋ก ๊ณ ์ ํด ๋กค๋ง ์ ๋ฐ์ดํธํ์ธ์. - ์ธ์ฆ ๋ฉ์ปค๋์ฆ ํ์ธ: PostgreSQL ์ฌ์ฉ์ ์ธ์ฆ์ ์ฐ๋ํ ๋ ๋๋ผ์ด๋ฒ ์ฐ๊ฒฐ ๋ฌธ์์ด์
?authMechanism=PLAIN๋๋ TLS ํ๊ฒฝ์์์SCRAM-SHA-256์ค์ ์ด ์ ํํ ์ผ์นํ๋์ง ํ์ธํ์ธ์. - TLS ๋ฐ ๋คํธ์ํฌ ๊ฒฉ๋ฆฌ:
:27017ํฌํธ๋ ์ธ๋ถ์ ์ง์ ๋ ธ์ถํ์ง ๋ง๊ณ ๋ด๋ถ VPC/Docker ๋คํธ์ํฌ์ ๋ฐฐ์นํ๋ฉฐ, ์ธ๋ถ ํด๋ผ์ด์ธํธ ์ ์์ด ํ์ํ๋ฉดFERRETDB_LISTEN_TLS๋ฅผ ๋ฐ๋์ ํ์ฑํํ์ธ์. - ๋ชจ๋ํฐ๋ง ์ฐ๋:
:8088/metricsPrometheus ์๋ํฌ์ธํธ๋ฅผ ์์งํด ์์ด์ด ํ๋กํ ์ฝ ๋ช ๋ น ์ง์ฐ์๊ฐ๊ณผ PostgreSQL ์ปค๋ฅ์ ํ ํฌํ๋๋ฅผ ํจ๊ป ์ถ์ ํ์ธ์.
์๊ฒฌ ๋ฐ ์ง๋ฌธ
0์์ง ๋ฑ๋ก๋ ์๊ฒฌ์ด ์์ต๋๋ค. ์ฒซ ๋ฒ์งธ ๋๊ธ์ ๋จ๊ฒจ๋ณด์ธ์!
๋๊ธ ์์
๋๊ธ ์ญ์