memoryweave/deploy/M8-MIGRATION.md

2.0 KiB
Raw Blame History

M8 灰度切换指南

前置条件

  • M1-M7 全部通过验证
  • FAISS 数据已备份(~/projects/zhiyi/data/backup-$(date +%Y%m%d).tar.gz
  • 迁移脚本测试通过(python3 scripts/migrate.py --dry-run
  • Go 二进制在 7822 运行 48h 无崩溃
  • Python 生产服务仍在 7821 运行

步骤

1. 数据迁移

python3 scripts/migrate.py \
  --data-dir ~/projects/zhiyi/data \
  --output-dir /var/lib/zhiyi/data

验证: ls -la /var/lib/zhiyi/data/zhiyi_memory.lance/

2. 影子部署48h

# 7822 运行 Go 版本
PORT=7822 API_KEY=zhiyi-dev-key-2026 /usr/local/bin/zhiyid &

验证: curl http://localhost:7822/health → 200

3. 灰度切换

# 10% 流量 → Go
sudo tee /etc/nginx/conf.d/zhiyi-upstream.conf << 'EOF'
upstream zhiyi_backend {
    server 127.0.0.1:7821 weight=9;  # Python
    server 127.0.0.1:7822 weight=1;  # Go
}
server {
    listen 7820;
    location / { proxy_pass http://zhiyi_backend; }
}
EOF
sudo nginx -s reload

验证: Go 无 5xx

4. 权重递增

# 50% → Go
# 修改 weight: 7821=5, 7822=5 → nginx -s reload → 验证
# 100% → Go
# 修改 weight: 7821=0, 7822=10 → nginx -s reload → 验证

5. systemd 切换

sudo systemctl stop zhiyi
sudo cp ~/projects/memoryweave/deploy/zhiyid.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now zhiyid

验证: curl http://localhost:7821/health → Go 版本

6. Hermes 验证

# memory_search 正常
# memory_write 正常
# memory_stats 正常

7. 归档

cd ~/projects/zhiyi && git tag archive/python-v3 && git push --tags
# Python 代码保留 7 天

回滚

sudo systemctl stop zhiyid
sudo systemctl start zhiyi        # Python 版本
# 恢复 nginx weight

验收

  • Go 版本在 7821 稳定运行 72h
  • Hermes memory_search/write/stats 正常
  • OpenClaw 织忆插件正常
  • 无 5xx 错误
  • 内存 < 50MB