chore: change default ports to non-standard ones (9472, 9470, 9471)

This commit is contained in:
2026-05-06 23:23:29 +03:00
parent be370fb76b
commit 9b7ed1fca8
29 changed files with 166 additions and 166 deletions
+1 -1
View File
@@ -32,6 +32,6 @@ let shard = router.getShard("user_123")
import barabadb/core/replication
var rm = newReplicationManager(rmSync)
rm.addReplica(newReplica("r1", "10.0.0.1", 5432))
rm.addReplica(newReplica("r1", "10.0.0.1", 9472))
rm.connectReplica("r1")
```
+4 -4
View File
@@ -159,9 +159,9 @@ sudo mkdir -p /var/lib/baradb
```bash
docker pull barabadb/barabadb:latest
docker run -d \
-p 5432:5432 \
-p 8080:8080 \
-p 8081:8081 \
-p 9472:9472 \
-p 9470:9470 \
-p 9471:9471 \
-v baradb_data:/data \
barabadb/barabadb
```
@@ -194,7 +194,7 @@ db.close()
./build/baradadb
# Тестване на HTTP API
curl http://localhost:8080/health
curl http://localhost:9470/health
# Интерактивна конзола
./build/baradadb --shell
+3 -3
View File
@@ -8,7 +8,7 @@
./build/baradadb
```
Сървърът ще стартира на `localhost:8080` по подразбиране.
Сървърът ще стартира на `localhost:9470` по подразбиране.
## Свързване чрез CLI
@@ -102,10 +102,10 @@ SELECT * FROM vectors ORDER BY cosine_distance(embedding, [0.1, 0.2, 0.3]) LIMIT
```bash
# GET заявка
curl http://localhost:8080/api/users
curl http://localhost:9470/api/users
# POST заявка
curl -X POST http://localhost:8080/api/users \
curl -X POST http://localhost:9470/api/users \
-H "Content-Type: application/json" \
-d '{"name": "Alice", "age": 30}'
```
+8 -8
View File
@@ -5,7 +5,7 @@ JSON-based REST API for web applications.
## Base URL
```
http://localhost:8080/api
http://localhost:9470/api
```
## Endpoints
@@ -15,7 +15,7 @@ http://localhost:8080/api
List all users:
```bash
curl http://localhost:8080/api/users
curl http://localhost:9470/api/users
```
Response:
@@ -31,7 +31,7 @@ Response:
Get user by ID:
```bash
curl http://localhost:8080/api/users/1
curl http://localhost:9470/api/users/1
```
### POST /api/users
@@ -39,7 +39,7 @@ curl http://localhost:8080/api/users/1
Create user:
```bash
curl -X POST http://localhost:8080/api/users \
curl -X POST http://localhost:9470/api/users \
-H "Content-Type: application/json" \
-d '{"name": "Charlie", "age": 35}'
```
@@ -49,7 +49,7 @@ curl -X POST http://localhost:8080/api/users \
Update user:
```bash
curl -X PUT http://localhost:8080/api/users/1 \
curl -X PUT http://localhost:9470/api/users/1 \
-H "Content-Type: application/json" \
-d '{"name": "Alice", "age": 31}'
```
@@ -59,7 +59,7 @@ curl -X PUT http://localhost:8080/api/users/1 \
Delete user:
```bash
curl -X DELETE http://localhost:8080/api/users/1
curl -X DELETE http://localhost:9470/api/users/1
```
## Query Endpoint
@@ -67,7 +67,7 @@ curl -X DELETE http://localhost:8080/api/users/1
Execute BaraQL queries via HTTP:
```bash
curl -X POST http://localhost:8080/api/query \
curl -X POST http://localhost:9470/api/query \
-H "Content-Type: application/json" \
-d '{"sql": "SELECT * FROM users WHERE age > 18"}'
```
@@ -87,5 +87,5 @@ curl -X POST http://localhost:8080/api/query \
```bash
curl -H "Authorization: Bearer <token>" \
http://localhost:8080/api/users
http://localhost:9470/api/users
```
+2 -2
View File
@@ -5,13 +5,13 @@ Full-duplex streaming for real-time data feeds and push notifications.
## Connection
```
ws://localhost:8081/ws
ws://localhost:9471/ws
```
## Client Example
```javascript
const ws = new WebSocket('ws://localhost:8081/ws');
const ws = new WebSocket('ws://localhost:9471/ws');
ws.onopen = () => {
console.log('Connected');
+4 -4
View File
@@ -23,7 +23,7 @@ bm.createSnapshot("/backup/baradb_2025-01-15")
### Via HTTP API
```bash
curl -X POST http://localhost:8080/api/backup \
curl -X POST http://localhost:9470/api/backup \
-H "Content-Type: application/json" \
-d '{"destination": "/backup/snapshot.db"}'
```
@@ -101,7 +101,7 @@ BARADB_REPLICATION_MODE=async \
```bash
BARADB_REPLICATION_ENABLED=true \
BARADB_REPLICATION_PRIMARY=primary:5432 \
BARADB_REPLICATION_PRIMARY=primary:9472 \
./build/baradadb
```
@@ -130,7 +130,7 @@ cp /backup/snapshot.db ./data/
./build/baradadb --recover --wal-dir=/backup/wal
# 3. Verify
curl http://localhost:8080/health
curl http://localhost:9470/health
```
#### Scenario 3: Cluster Node Failure
@@ -155,7 +155,7 @@ Always verify backups:
--data-dir=/tmp/verify_data
# Run consistency check
curl http://localhost:8080/api/admin/check
curl http://localhost:9470/api/admin/check
```
## Storage Requirements
+14 -14
View File
@@ -17,7 +17,7 @@ yarn add baradb
```typescript
import { Client } from 'baradb';
const client = new Client('localhost', 5432);
const client = new Client('localhost', 9472);
await client.connect();
// Simple query
@@ -50,7 +50,7 @@ await client.close();
```typescript
import { WebSocketClient } from 'baradb/ws';
const ws = new WebSocketClient('ws://localhost:8081');
const ws = new WebSocketClient('ws://localhost:9471');
ws.onMessage = (data) => console.log(data);
await ws.connect();
await ws.send('SUBSCRIBE updates');
@@ -69,7 +69,7 @@ pip install baradb
```python
from baradb import Client
client = Client("localhost", 5432)
client = Client("localhost", 9472)
client.connect()
# Simple query
@@ -90,7 +90,7 @@ client.batch([
])
# Context manager (auto-close)
with Client("localhost", 5432) as c:
with Client("localhost", 9472) as c:
result = c.query("SELECT count(*) FROM users")
print(result[0]["count"])
```
@@ -102,7 +102,7 @@ import asyncio
from baradb import AsyncClient
async def main():
client = AsyncClient("localhost", 5432)
client = AsyncClient("localhost", 9472)
await client.connect()
result = await client.query("SELECT * FROM users")
print(result.rows)
@@ -157,7 +157,7 @@ let path = g.shortestPath(alice, bob)
```nim
import barabadb/client/client
var c = newBaraClient("localhost", 5432)
var c = newBaraClient("localhost", 9472)
c.connect()
let result = c.query("SELECT name FROM users")
for row in result.rows:
@@ -182,7 +182,7 @@ use baradb::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut client = Client::connect("localhost:5432").await?;
let mut client = Client::connect("localhost:9472").await?;
let result = client
.query("SELECT name, age FROM users WHERE age > 18")
@@ -203,24 +203,24 @@ All languages can use the HTTP/REST API directly:
```bash
# Query
curl -X POST http://localhost:8080/api/query \
curl -X POST http://localhost:9470/api/query \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{"query": "SELECT * FROM users WHERE age > 18"}'
# Insert
curl -X POST http://localhost:8080/api/query \
curl -X POST http://localhost:9470/api/query \
-H "Content-Type: application/json" \
-d '{"query": "INSERT users { name := \"Alice\", age := 30 }"}'
# Schema
curl http://localhost:8080/api/schema
curl http://localhost:9470/api/schema
# Health
curl http://localhost:8080/health
curl http://localhost:9470/health
# Metrics
curl http://localhost:8080/metrics
curl http://localhost:9470/metrics
```
## Connection Pooling
@@ -234,7 +234,7 @@ import { Pool } from 'baradb';
const pool = new Pool({
host: 'localhost',
port: 5432,
port: 9472,
min: 5,
max: 50,
idleTimeout: 30000,
@@ -253,7 +253,7 @@ try {
```python
from baradb import Pool
pool = Pool("localhost", 5432, min_size=5, max_size=50)
pool = Pool("localhost", 9472, min_size=5, max_size=50)
with pool.connection() as conn:
result = conn.query("SELECT 1")
```
+13 -13
View File
@@ -16,9 +16,9 @@ BaraDB can be configured via **environment variables**, a **config file**, or **
| Variable | Default | Description |
|----------|---------|-------------|
| `BARADB_ADDRESS` | `127.0.0.1` | Bind address |
| `BARADB_PORT` | `5432` | TCP binary protocol port |
| `BARADB_HTTP_PORT` | `8080` | HTTP/REST API port |
| `BARADB_WS_PORT` | `8081` | WebSocket port |
| `BARADB_PORT` | `9472` | TCP binary protocol port |
| `BARADB_HTTP_PORT` | `9470` | HTTP/REST API port |
| `BARADB_WS_PORT` | `9471` | WebSocket port |
### Storage
@@ -89,9 +89,9 @@ BaraDB can be configured via **environment variables**, a **config file**, or **
```ini
[server]
address = "0.0.0.0"
port = 5432
http_port = 8080
ws_port = 8081
port = 9472
http_port = 9470
ws_port = 9471
[storage]
data_dir = "/var/lib/baradb"
@@ -132,9 +132,9 @@ raft_peers = "node2:9001,node3:9001"
{
"server": {
"address": "0.0.0.0",
"port": 5432,
"http_port": 8080,
"ws_port": 8081
"port": 9472,
"http_port": 9470,
"ws_port": 9471
},
"storage": {
"data_dir": "/var/lib/baradb",
@@ -163,9 +163,9 @@ Usage:
Options:
-c, --config <file> Config file path
-p, --port <port> TCP binary port (default: 5432)
--http-port <port> HTTP port (default: 8080)
--ws-port <port> WebSocket port (default: 8081)
-p, --port <port> TCP binary port (default: 9472)
--http-port <port> HTTP port (default: 9470)
--ws-port <port> WebSocket port (default: 9471)
-d, --data-dir <dir> Data directory (default: ./data)
--tls-cert <file> TLS certificate file
--tls-key <file> TLS private key file
@@ -208,7 +208,7 @@ BARADB_CACHE_SIZE_MB=1024 \
```bash
# Node 1
BARADB_ADDRESS=0.0.0.0 \
BARADB_PORT=5432 \
BARADB_PORT=9472 \
BARADB_RAFT_NODE_ID=node1 \
BARADB_RAFT_PEERS=node2:9001,node3:9001 \
BARADB_SHARD_COUNT=4 \
+21 -21
View File
@@ -8,9 +8,9 @@
docker build -t baradb:latest .
docker run -d \
--name baradb \
-p 5432:5432 \
-p 8080:8080 \
-p 8081:8081 \
-p 9472:9472 \
-p 9470:9470 \
-p 9471:9471 \
-v baradb_data:/data \
-e BARADB_DATA_DIR=/data \
baradb:latest
@@ -24,16 +24,16 @@ services:
baradb:
image: baradb:latest
ports:
- "5432:5432"
- "8080:8080"
- "8081:8081"
- "9472:9472"
- "9470:9470"
- "9471:9471"
volumes:
- baradb_data:/data
- ./certs:/certs:ro
environment:
- BARADB_PORT=5432
- BARADB_HTTP_PORT=8080
- BARADB_WS_PORT=8081
- BARADB_PORT=9472
- BARADB_HTTP_PORT=9470
- BARADB_WS_PORT=9471
- BARADB_DATA_DIR=/data
- BARADB_TLS_ENABLED=true
- BARADB_CERT_FILE=/certs/server.crt
@@ -42,7 +42,7 @@ services:
- BARADB_MEMTABLE_SIZE_MB=256
- BARADB_CACHE_SIZE_MB=512
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:8080/health"]
test: ["CMD", "wget", "-q", "--spider", "http://localhost:9470/health"]
interval: 10s
timeout: 5s
retries: 3
@@ -84,8 +84,8 @@ ExecStart=/usr/local/bin/baradadb
Restart=always
RestartSec=5
Environment=BARADB_PORT=5432
Environment=BARADB_HTTP_PORT=8080
Environment=BARADB_PORT=9472
Environment=BARADB_HTTP_PORT=9470
Environment=BARADB_DATA_DIR=/var/lib/baradb/data
Environment=BARADB_LOG_LEVEL=info
@@ -137,11 +137,11 @@ spec:
- name: baradb
image: baradb:latest
ports:
- containerPort: 5432
- containerPort: 9472
name: binary
- containerPort: 8080
- containerPort: 9470
name: http
- containerPort: 8081
- containerPort: 9471
name: websocket
env:
- name: BARADB_DATA_DIR
@@ -170,11 +170,11 @@ spec:
selector:
app: baradb
ports:
- port: 5432
- port: 9472
name: binary
- port: 8080
- port: 9470
name: http
- port: 8081
- port: 9471
name: websocket
clusterIP: None
```
@@ -183,11 +183,11 @@ spec:
```nginx
upstream baradb_http {
server 127.0.0.1:8080;
server 127.0.0.1:9470;
}
upstream baradb_ws {
server 127.0.0.1:8081;
server 127.0.0.1:9471;
}
server {
@@ -277,7 +277,7 @@ systemctl enable --now baradb
```bash
gcloud run deploy baradb \
--image gcr.io/PROJECT/baradb \
--port 8080 \
--port 9470 \
--memory 4Gi \
--cpu 2 \
--max-instances 10
+1 -1
View File
@@ -50,7 +50,7 @@ let shard = router.getShard("user_123")
import barabadb/core/replication
var rm = newReplicationManager(rmSync)
rm.addReplica(newReplica("r1", "10.0.0.1", 5432))
rm.addReplica(newReplica("r1", "10.0.0.1", 9472))
rm.connectReplica("r1")
let lsn = rm.writeLsn(@[1'u8, 2, 3])
rm.ackLsn("r1", lsn)
+5 -5
View File
@@ -220,9 +220,9 @@ docker pull barabadb/barabadb:latest
# Run
docker run -d \
-p 5432:5432 \
-p 8080:8080 \
-p 8081:8081 \
-p 9472:9472 \
-p 9470:9470 \
-p 9471:9471 \
-v baradb_data:/data \
barabadb/barabadb
```
@@ -260,10 +260,10 @@ db.close()
# Expected output:
# BaraDB v0.1.0 — Multimodal Database Engine
# BaraDB TCP listening on 127.0.0.1:5432
# BaraDB TCP listening on 127.0.0.1:9472
# Test with HTTP API
curl http://localhost:8080/health
curl http://localhost:9470/health
# Interactive shell
./build/baradadb --shell
+8 -8
View File
@@ -5,7 +5,7 @@
### HTTP Health Endpoint
```bash
curl http://localhost:8080/health
curl http://localhost:9470/health
```
Response:
@@ -26,7 +26,7 @@ Response:
### Readiness Probe
```bash
curl http://localhost:8080/ready
curl http://localhost:9470/ready
```
Returns `200 OK` when the server is ready to accept traffic, `503` during startup.
@@ -36,7 +36,7 @@ Returns `200 OK` when the server is ready to accept traffic, `503` during startu
### Prometheus-Compatible Metrics
```bash
curl http://localhost:8080/metrics
curl http://localhost:9470/metrics
```
Example output:
@@ -80,7 +80,7 @@ baradb_txns_committed_total 89123
### JSON Metrics
```bash
curl http://localhost:8080/metrics?format=json
curl http://localhost:9470/metrics?format=json
```
## Logging
@@ -190,7 +190,7 @@ Key panels:
For Raft clusters, monitor:
```bash
curl http://node1:8080/metrics/cluster
curl http://node1:9470/metrics/cluster
```
```json
@@ -213,19 +213,19 @@ curl http://node1:8080/metrics/cluster
### Built-in CPU Profiler
```bash
curl -X POST http://localhost:8080/debug/pprof/cpu?seconds=30 > cpu.prof
curl -X POST http://localhost:9470/debug/pprof/cpu?seconds=30 > cpu.prof
```
### Memory Profiler
```bash
curl http://localhost:8080/debug/pprof/heap > heap.prof
curl http://localhost:9470/debug/pprof/heap > heap.prof
```
### Trace
```bash
curl -X POST http://localhost:8080/debug/pprof/trace?seconds=5 > trace.out
curl -X POST http://localhost:9470/debug/pprof/trace?seconds=5 > trace.out
```
## Log Aggregation
+8 -8
View File
@@ -120,18 +120,18 @@ Every message starts with a 8-byte header:
```bash
# Connect
nc localhost 5432
nc localhost 9472
# Send: Auth request (token "mytoken")
# Header: length=15, type=0x07, seq=1
# Payload: token length=7, token="mytoken"
printf '\x00\x00\x00\x0f\x07\x01\x00\x00\x00\x07mytoken' > /dev/tcp/localhost/5432
printf '\x00\x00\x00\x0f\x07\x01\x00\x00\x00\x07mytoken' > /dev/tcp/localhost/9472
# Receive: Auth_OK
# \x00\x00\x00\x06\x83\x01
# Send: Query "SELECT 1"
printf '\x00\x00\x00\x12\x01\x02\x00\x00\x00\x00\x08SELECT 1' > /dev/tcp/localhost/5432
printf '\x00\x00\x00\x12\x01\x02\x00\x00\x00\x00\x08SELECT 1' > /dev/tcp/localhost/9472
# Receive: Data + Complete
```
@@ -140,7 +140,7 @@ printf '\x00\x00\x00\x12\x01\x02\x00\x00\x00\x00\x08SELECT 1' > /dev/tcp/localho
## HTTP/REST API
Base URL: `http://localhost:8080/api/v1`
Base URL: `http://localhost:9470/api/v1`
### Endpoints
@@ -304,7 +304,7 @@ POST /admin/check
## WebSocket Protocol
URL: `ws://localhost:8081`
URL: `ws://localhost:9471`
### Frame Format
@@ -334,7 +334,7 @@ WebSocket text frames contain JSON messages:
### Pub/Sub Example
```javascript
const ws = new WebSocket('ws://localhost:8081');
const ws = new WebSocket('ws://localhost:9471');
ws.onopen = () => {
// Subscribe to table changes
@@ -386,7 +386,7 @@ let error = makeErrorMessage(1, 42, "Syntax error")
```nim
import barabadb/protocol/http
var router = newHttpRouter(port = 8080)
var router = newHttpRouter(port = 9470)
router.get("/api/users", proc(req: Request): Future[JsonNode] {.async.} =
return %*[
@@ -405,7 +405,7 @@ router.post("/api/users", proc(req: Request): Future[JsonNode] {.async.} =
```nim
import barabadb/core/websocket
var server = newWsServer(port = 8081)
var server = newWsServer(port = 9471)
server.onMessage = proc(ws: WebSocket, data: seq[byte]) {.gcsafe.} =
echo "Received: ", cast[string](data)
asyncCheck ws.send(cast[string](data)) # Echo
+3 -3
View File
@@ -8,7 +8,7 @@ After building BaraDB, start the server:
./build/baradadb
```
The server will start on `localhost:8080` by default.
The server will start on `localhost:9470` by default.
## Connecting via CLI
@@ -118,10 +118,10 @@ SELECT * FROM articles WHERE MATCH(title, body) AGAINST('database');
```bash
# GET request
curl http://localhost:8080/api/users
curl http://localhost:9470/api/users
# POST request
curl -X POST http://localhost:8080/api/users \
curl -X POST http://localhost:9470/api/users \
-H "Content-Type: application/json" \
-d '{"name": "Alice", "age": 30}'
```
+6 -6
View File
@@ -40,7 +40,7 @@ BARADB_KEY_FILE=/etc/letsencrypt/live/db.example.com/privkey.pem \
```python
from baradb import Client
client = Client("localhost", 5432, tls=True, tls_verify=True)
client = Client("localhost", 9472, tls=True, tls_verify=True)
client.connect()
```
@@ -84,14 +84,14 @@ let token = am.createToken(JWTClaims(
```bash
curl -H "Authorization: Bearer $TOKEN" \
http://localhost:8080/api/query \
http://localhost:9470/api/query \
-d '{"query": "SELECT * FROM users"}'
```
```python
from baradb import Client
client = Client("localhost", 5432)
client = Client("localhost", 9472)
client.connect()
client.authenticate("eyJhbGciOiJIUzI1NiIs...")
```
@@ -143,11 +143,11 @@ BARADB_ADDRESS=10.0.0.5 ./build/baradadb
```bash
# Allow only application servers
sudo ufw allow from 10.0.0.0/8 to any port 5432
sudo ufw allow from 10.0.0.0/8 to any port 8080
sudo ufw allow from 10.0.0.0/8 to any port 9472
sudo ufw allow from 10.0.0.0/8 to any port 9470
# Block external access to management ports
sudo ufw deny 8081 # WebSocket (internal use only)
sudo ufw deny 9471 # WebSocket (internal use only)
```
## Data Encryption at Rest
+9 -9
View File
@@ -60,9 +60,9 @@ BARADB_PORT=5433 ./build/baradadb
**Solution 2:** Kill existing process:
```bash
lsof -ti:5432 | xargs kill -9
lsof -ti:9472 | xargs kill -9
# or
fuser -k 5432/tcp
fuser -k 9472/tcp
```
### Permission Denied on Data Directory
@@ -108,7 +108,7 @@ Error: No space left on device
df -h
# Trigger compaction to reclaim space
curl -X POST http://localhost:8080/api/admin/compact
curl -X POST http://localhost:9470/api/admin/compact
# Or manually
./build/baradadb --compact
@@ -184,7 +184,7 @@ SELECT * FROM users WHERE id = 123;
### Connection Refused
```
Connection refused: localhost:5432
Connection refused: localhost:9472
```
**Solution:**
@@ -198,7 +198,7 @@ ps aux | grep baradadb
# Check firewall
sudo ufw status
sudo ufw allow 5432
sudo ufw allow 9472
```
### Authentication Failed
@@ -247,7 +247,7 @@ BARADB_KEY_FILE=/path/to/key.pem \
```bash
# Check query plan
curl -X POST http://localhost:8080/api/explain \
curl -X POST http://localhost:9470/api/explain \
-d '{"query": "SELECT * FROM large_table"}'
```
@@ -292,7 +292,7 @@ LIMIT 10;
**Monitor:**
```bash
curl http://localhost:8080/metrics | grep memory
curl http://localhost:9470/metrics | grep memory
```
**Solutions:**
@@ -347,7 +347,7 @@ Warning: Shard 3 has 2× data of others
```bash
# Trigger rebalancing
curl -X POST http://localhost:8080/api/admin/rebalance
curl -X POST http://localhost:9470/api/admin/rebalance
```
## Data Corruption
@@ -399,7 +399,7 @@ BARADB_LOG_FILE=/tmp/baradb_debug.log \
If the issue persists:
1. Check logs: `tail -f /var/log/baradb/baradb.log`
2. Check metrics: `curl http://localhost:8080/metrics`
2. Check metrics: `curl http://localhost:9470/metrics`
3. Run diagnostics: `./build/baradadb --diagnose`
4. Open an issue with:
- BaraDB version (`./build/baradadb --version`)