1
系统开发/部署与配置
xiaowu edited this page 2026-08-25 15:16:44 +08:00
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

部署与配置

数据库(黑群晖 Docker)

  • 容器:postgres-server,端口 5438(宿主)→ 5432(容器)
  • 超级用户:sally(不是 postgres!)
  • 数据库:quant_db,另有默认库 mydb
  • 进 psql:sudo docker exec -it postgres-server psql -U sally -d quant_db

账号

账号 用途 权限
sally 超级用户 全部
xiaoqiang 小强只读查询 quant_db 只读
xiaoqiang_w importer 写库 全部表/视图/序列 owner

⚠️ 表/视图/序列的 owner 必须转给 xiaoqiang_w,否则 importer 的 DDL(CREATE INDEX 等)会报 must be owner。转换 SQL 见 系统开发/踩坑记录。

Python 环境(小强容器 openclaw-1)

  • 系统 Python 3.11 受 PEP 668 保护,不能直接 pip install
  • 专用 venv:/opt/quant-venv(root 创建)
  • 跑脚本一律用:/opt/quant-venv/bin/python
  • 依赖:tushare / pandas / psycopg2-binary / sqlalchemy / python-dotenv

.env 配置

路径:/home/node/quanxiel/quantitative_data/.env(不入 git)

QUANT_DB_HOST=192.168.27.11
QUANT_DB_PORT=5438
QUANT_DB_NAME=quant_db
QUANT_DB_USER=xiaoqiang_w
QUANT_DB_PASSWORD=***
TUSHARE_TOKEN=***
  • 密码含特殊字符时写 .env 用 heredoc <<'EOF' 防转义
  • 改 .env 后无需重启,config.py 每次加载

目录权限

仓库目录必须 node 用户可写(importer 要写日志):

sudo docker exec -u root openclaw-1 bash -c 'chown -R node:node /home/node/quanxiel'