故障排除
使用 MynaDB 时的常见问题及其解决方案。
表未找到
错误:"Table not found: mydb.default.cpu"
可能原因
- 数据尚未刷写到磁盘
- 表名或数据库名错误
- 数据写入了不同的 schema
解决方案
# 1. Flush data to disk
curl -X POST http://localhost:7000/flush
# 2. List available tables
curl http://localhost:7000/tables/mydb
# 3. Check if using correct database in URL
curl 'http://localhost:7000/query/mydb' -d 'SELECT * FROM cpu'
# ^^^^^ make sure this matches
查询无数据返回
查询返回空结果
解决方案
# 1. Check if data exists
curl 'http://localhost:7000/query/mydb' -d 'SELECT COUNT(*) FROM cpu'
# 2. Check table schema
curl http://localhost:7000/schema/mydb/cpu
# 3. Verify column names in WHERE clause
curl 'http://localhost:7000/query/mydb' -d 'SELECT * FROM cpu LIMIT 1'
# 4. Check time range - timestamps are nanoseconds
curl 'http://localhost:7000/query/mydb' -d 'SELECT MIN(time), MAX(time) FROM cpu'
连接问题
错误:"Connection refused"
解决方案
# 1. Check if server is running
ps aux | grep mynadb
# 2. Check port availability
netstat -tlnp | grep 7000
# 3. Check server logs
journalctl -u mynadb -f
# 4. Test health endpoint
curl http://localhost:7000/health
性能问题
查询慢
- 使用 LIMIT - 探索性查询始终使用 LIMIT
- 尽早过滤 - 在时间戳和索引标签上使用 WHERE 条件
- 检查压缩 - 过多的小文件会降低查询速度
# Trigger compaction to improve query performance
curl -X POST http://localhost:7000/compact/mydb
写入慢
- 批量写入 - 在一个请求中发送多个数据点
- 如果允许降低持久性保证,可以增大刷写间隔
- 检查磁盘 I/O - 使用 SSD 存储
磁盘空间问题
磁盘空间不足
# 1. Check disk usage
du -sh /data/stats/*
# 2. Manually delete old partitions
curl -X POST http://localhost:7000/retention/mydb/default/cpu \
-H "Content-Type: application/json" \
-d '{"older_than_days": 7}'
# 3. Trigger compaction (reduces file count and size)
curl -X POST http://localhost:7000/compact/mydb
内存问题
内存溢出(OOM)
解决方案
- 在配置中降低
full_compaction_max_concurrent - 缩短缓存刷写间隔以减少内存占用
- 对大型查询使用 LIMIT
- 对大量结果使用 Arrow Flight 流式传输
# config.toml - reduce memory usage
[compaction]
full_compaction_max_concurrent = 1 # Lower this
[cache]
flush_interval_secs = 15 # Flush more frequently
常见错误
| 错误 | 解决方案 |
|---|---|
SELECT * FROM mydb.cpu |
使用 mydb.default.cpu 或直接使用 cpu |
| 忘记刷写数据 | 查询新数据前先调用 /flush |
| 时间戳格式错误 | 使用纳秒(19 位数字) |
| URL 中缺少数据库名 | 使用 /query/mydb 而非 /query |
获取帮助
如果无法解决您的问题:
- 检查服务器日志以获取详细错误信息
- 搜索 GitHub Issues
- 提交新的 Issue 并附上复现步骤