从 InfluxDB 迁移
本文档将帮助你了解 GreptimeDB 和 InfluxDB 的数据模型之间的区别,并指导你完成迁移过程。
数据模型的区别
要了解 InfluxDB 和 GreptimeDB 的数据模型之间的差异,请参考写入数据文档中的数据模型。
数据库连接信息
在写入或查询数据之前,需要了解 InfluxDB 和 GreptimeDB 之间的数据库连接信息的差异。
- Token:InfluxDB API 中的 token 用于身份验证,与 GreptimeDB 身份验证相同。
当使用 InfluxDB 的客户端库或 HTTP API 与 GreptimeDB 交互时,你可以使用
<greptimedb_user:greptimedb_password>
作为 token。 - Organization:GreptimeDB 中没有组织。
- Bucket:在 InfluxDB 中,bucket 是时间序列数据的容器,与 GreptimeDB 中的数据库名称相同。
打开 GreptimeCloud 控制台 点击 Manage Your Data
下的 Connection Information
.
你可以找到 GreptimeDB URL,数据库名称,以及 token 所需的 username 和 password。
写入数据
GreptimeDB 兼容 InfluxDB 的行协议格式,包括 v1 和 v2。 这意味着你可以轻松地从 InfluxDB 迁移到 GreptimeDB。
HTTP API
你可以使用以下 HTTP API 请求将 measurement 写入 GreptimeDB:
- InfluxDB line protocol v2
- InfluxDB line protocol v1
curl -X POST 'https://<host>/v1/influxdb/api/v2/write?bucket=<db-name>' \
-H 'authorization: token <greptime_user:greptimedb_password>' \
-d 'census,location=klamath,scientist=anderson bees=23 1566086400000000000'
curl 'https://<host>/v1/influxdb/write?db=<db-name>&u=<greptime_user>&p=<greptimedb_password>' \
-d 'census,location=klamath,scientist=anderson bees=23 1566086400000000000'