故障排除

使用 MynaDB 时的常见问题及其解决方案。

表未找到

错误:"Table not found: mydb.default.cpu"

可能原因

解决方案

# 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

性能问题

查询慢

# Trigger compaction to improve query performance
curl -X POST http://localhost:7000/compact/mydb

写入慢

磁盘空间问题

磁盘空间不足

# 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)

解决方案

# 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

获取帮助

如果无法解决您的问题:

  1. 检查服务器日志以获取详细错误信息
  2. 搜索 GitHub Issues
  3. 提交新的 Issue 并附上复现步骤