Files
Baradb/docs/bg/deployment.md
T
dimgigov c55d3080cf
CI / test (push) Has been cancelled
CI / verify (push) Has been cancelled
Clients CI / build-server (push) Has been cancelled
Clients CI / test-python (push) Has been cancelled
Clients CI / test-javascript (push) Has been cancelled
Clients CI / test-nim (push) Has been cancelled
Clients CI / test-rust (push) Has been cancelled
Update documentation and clients for v1.1.0
Documentation updates:
- Fix v0.1.0 → v1.1.0 version numbers in en, ru, fa, zh docs
- Add missing Window Functions, Multi-Tenant ERP, Supported Keywords sections
  to ru, fa, zh baraql.md (~105 lines each)
- Expand Turkish and Arabic baraql.md (110 → 268 lines)
- Expand Turkish and Arabic installation.md (62 → 307 lines)
- Add new Bulgarian documentation files (18 new files)

Client updates:
- Python: Full async/await rewrite with asyncio, request queueing
- Rust: Full async/await rewrite with tokio, async examples
- Nim: Update README to v1.1.0
- All clients now support async patterns consistently
2026-05-14 23:05:47 +03:00

4.9 KiB

Ръководство за Внедряване (Deployment)

Docker

За пълно ръководство за Docker deployment вижте Docker Guide.

Бърз старт

docker build -t baradb:latest .
docker compose up -d

Docker Compose файлове

Файл Назначение
docker-compose.yml Development
docker-compose.prod.yml Production
docker-compose.override.yml Dev override (автоматично)
docker-compose.test.yml Тестова среда

Production

docker compose -f docker-compose.prod.yml up -d

Docker Swarm

docker stack deploy -c docker-compose.prod.yml baradb

systemd Услуга

Създайте /etc/systemd/system/baradb.service:

[Unit]
Description=BaraDB Multimodal Database
After=network.target

[Service]
Type=simple
User=baradb
Group=baradb
WorkingDirectory=/var/lib/baradb
ExecStart=/usr/local/bin/baradadb
Restart=always
RestartSec=5

Environment=BARADB_PORT=9472
Environment=BARADB_HTTP_PORT=9470
Environment=BARADB_DATA_DIR=/var/lib/baradb/data
Environment=BARADB_LOG_LEVEL=info

# Подсилване на сигурността
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/baradb/data
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true

[Install]
WantedBy=multi-user.target

Активиране и стартиране:

sudo useradd -r -s /bin/false baradb
sudo mkdir -p /var/lib/baradb/data
sudo chown -R baradb:baradb /var/lib/baradb
sudo cp build/baradadb /usr/local/bin/
sudo systemctl daemon-reload
sudo systemctl enable --now baradb

Kubernetes

StatefulSet

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: baradb
spec:
  serviceName: baradb
  replicas: 3
  selector:
    matchLabels:
      app: baradb
  template:
    metadata:
      labels:
        app: baradb
    spec:
      containers:
      - name: baradb
        image: baradb:latest
        ports:
        - containerPort: 9472
          name: binary
        - containerPort: 9470
          name: http
        - containerPort: 9471
          name: websocket
        env:
        - name: BARADB_DATA_DIR
          value: /data
        - name: BARADB_RAFT_NODE_ID
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        volumeMounts:
        - name: data
          mountPath: /data
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes: ["ReadWriteOnce"]
      resources:
        requests:
          storage: 100Gi
---
apiVersion: v1
kind: Service
metadata:
  name: baradb
spec:
  selector:
    app: baradb
  ports:
  - port: 9472
    name: binary
  - port: 9470
    name: http
  - port: 9471
    name: websocket
  clusterIP: None

Reverse Proxy (nginx)

upstream baradb_http {
    server 127.0.0.1:9470;
}

upstream baradb_ws {
    server 127.0.0.1:9471;
}

server {
    listen 80;
    server_name db.example.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name db.example.com;

    ssl_certificate /etc/letsencrypt/live/db.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/db.example.com/privkey.pem;

    location /api/ {
        proxy_pass http://baradb_http/;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }

    location /ws/ {
        proxy_pass http://baradb_ws/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Висока Достъпност (High Availability)

3-Възел Raft Клъстер

# Възел 1
BARADB_RAFT_NODE_ID=node1 \
BARADB_RAFT_PEERS=node2:9001,node3:9001 \
./build/baradadb

# Възел 2
BARADB_RAFT_NODE_ID=node2 \
BARADB_RAFT_PEERS=node1:9001,node3:9001 \
./build/baradadb

# Възел 3
BARADB_RAFT_NODE_ID=node3 \
BARADB_RAFT_PEERS=node1:9001,node2:9001 \
./build/baradadb

Облачно Внедряване

AWS EC2

Препоръчителна инстанция: m6i.2xlarge (8 vCPU, 32 GB RAM)

# User data скрипт
#!/bin/bash
apt-get update
apt-get install -y nim
wget https://github.com/katehonz/barabaDB/releases/latest/download/baradadb-linux-amd64
chmod +x baradadb-linux-amd64
mv baradadb-linux-amd64 /usr/local/bin/baradadb

mkdir -p /data/baradb
cat > /etc/systemd/system/baradb.service << 'EOF'
[Unit]
Description=BaraDB
After=network.target
[Service]
ExecStart=/usr/local/bin/baradadb
Environment=BARADB_DATA_DIR=/data/baradb
Restart=always
[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable --now baradb

GCP Cloud Run (само HTTP)

gcloud run deploy baradb \
  --image gcr.io/PROJECT/baradb \
  --port 9470 \
  --memory 4Gi \
  --cpu 2 \
  --max-instances 10