跳到主要内容
Markdown DB Engine

运维指南

Writer Lock

一个 Runtime Database 同时只能由一个 Writer Host 管理。Local Server 运行时,Web UI、CLI 和应用应该连接它的 endpoint:

md-db-engine check \
  --endpoint http://127.0.0.1:3000 \
  --credentials 'owner:replace-with-your-secret' \
  --json

不要手工删除 .mddb/lock.json。正常停止原进程;只有记录的本机 PID 已经不存在时,Runtime 才会安全回收遗留 Lock。

备份

Server 运行时通过 Remote API 创建一致 Snapshot:

md-db-engine backup \
  --endpoint http://127.0.0.1:3000 \
  --credentials 'owner:replace-with-your-secret' \
  --json

Server 停止时也可以使用 md-db-engine backup --database ./content.mddb --json。不要直接复制正在提交的 Runtime 目录来代替 Snapshot。

Restore

Restore 始终写入一个不存在的新目录:

md-db-engine restore \
  --database ./content.mddb \
  --snapshot <snapshot-id> \
  --target ./recovered.mddb \
  --yes \
  --json

检查恢复目录以后,再停止应用并切换配置。Restore 不覆盖当前 Database。

完整性和升级

md-db-engine check --database ./content.mddb --json
md-db-engine upgrade --database ./content.mddb --yes --json
md-db-engine index rebuild --database ./content.mddb --yes --json

0.3.0 继续使用 Runtime Format Version 2,从 0.2.1 升级不需要格式迁移。运行维护命令前先创建 Snapshot。

Credential

首次 Owner Credential 只显示一次。为应用创建权限更小的 Editor 或 Reader;Password、Token 和 Session 明文不能进入 Git、Workspace、日志或浏览器 Bundle。最后一个有效 Owner 受到保护。

网络安全

默认监听 127.0.0.1 适合本机使用。绑定非 Loopback 地址时,Server 强制要求 TLS、Authentication、Allowed Origins 和 Access Log。不要为了方便关闭这些门禁;远程访问优先通过受控网络或反向代理,并且使用可撤销 Credential。