数据库和保留策略映射
InfluxDB 1.x 数据模型包含 databases 和 retention policies。InfluxDB Cloud 用 buckets 替代数据库和保留策略。为了在 InfluxDB Cloud 中支持 InfluxDB 1.x 查询和写入模式,数据库和保留策略通过 数据库和保留策略 (DBRP) 映射服务 映射到桶。
DBRP映射服务使用在1.x兼容API请求中指定的数据库和保留策略来路由操作到一个桶。
要查询使用 api/v2/write API 写入的 InfluxQL 数据,您必须 手动创建 DBRP 映射 将一个存储桶映射到一个数据库和保留策略。有关更多信息,请参见 创建 DBRP 映射。
默认保留策略
一个数据库可以有多个保留策略,其中一个被设置为默认。如果在查询或写入请求中未指定保留策略,InfluxDB会使用指定数据库的默认保留策略。使用influx CLI或InfluxDB API将保留策略设置为数据库的默认保留策略。
写入数据时
在使用/write 兼容性端点写入数据时,DBRP映射服务会检查与数据库和保留策略映射的桶:
如果找到映射的桶,则数据将写入该桶。
如果一个未映射的桶的名称匹配:
database/retention policyexists, a DBRP mapping is added to the bucket, and data is written to the bucket.databaseexists (without a specified retention policy), the default database retention policy is used, a DBRP mapping is added to the bucket, and data is written to the bucket.
查询数据时
当从 InfluxDB Cloud 查询数据时,使用 /query 兼容性端点,DBRP 映射服务会检查指定的数据库和保留策略(如果未指定保留策略,则使用数据库的默认保留策略):
- 如果存在映射的桶,数据将从映射的桶中查询。
- 如果没有映射的存储桶,InfluxDB 将返回一个错误。 请查看如何 Create DBRP mappings。
有关DBRP映射API的更多信息,请参阅/api/v2/dbrps端点文档.
一个 DBRP 组合只能映射到一个单一的桶
每个唯一的DBRP组合只能映射到一个单一的bucket。如果您映射一个已经映射到另一个bucket的DBRP组合,它将覆盖现有的DBRP映射。