Documentation

从 InfluxDB OSS 2.x 升级到 InfluxDB Cloud

迁移到 InfluxDB 云无服务器

要解锁InfluxDB 3存储引擎的好处,包括无限基数和SQL,将您的数据迁移到InfluxDB Cloud Serverless组织

所有通过 cloud2.influxdata.com 创建的 InfluxDB Cloud 账户组织,在2023年1月31日及之后,均在 InfluxDB Cloud Serverless 上,并由 InfluxDB 3 存储引擎提供支持。

要查看您的组织使用哪个存储引擎,请在您的 InfluxDB Cloud 组织主页 版本信息中找到 由 InfluxDB Cloud 提供支持的 链接。如果您的组织使用 TSM,您会看到 TSM 后面跟着版本号。如果是 Serverless,您会看到 InfluxDB Cloud Serverless 后面跟着版本号。

要从 InfluxDB OSS 2.x 升级到 InfluxDB Cloud

  1. 创建一个 InfluxDB Cloud 账户
  2. 创建全访问API令牌
  3. 设置 influx CLI 连接配置
  4. 使用模板迁移 InfluxDB 资源
  5. 迁移 DBRP 映射
  6. 双向写入 InfluxDB 2.x 和 InfluxDB Cloud
  7. 迁移时间序列数据
  8. 与其他用户协作

升级时需考虑

  • InfluxDB Cloud需要令牌认证,您必须创建所有新的API令牌。
  • InfluxDB Cloud 不支持:

创建一个 InfluxDB Cloud 账户

执行以下操作之一以创建一个 InfluxDB Cloud 账户:

创建一个全访问API令牌

InfluxDB API 令牌是每个组织独特的。 在您的 InfluxDB Cloud 用户界面 (UI) 中创建一个全部访问令牌以用于升级过程。

  1. 点击 数据 (加载数据) > 令牌 在左侧导航栏中。

  2. 点击 生成,然后选择 全访问令牌

  3. 输入令牌的描述,然后点击 保存

如果您在您的 InfluxDB 2.x 实例中为外部库或集成创建了其他令牌,请在您的 InfluxDB Cloud 实例中为每个创建相应的令牌。您无法将令牌从 InfluxDB 2.x 迁移到 InfluxDB Cloud。

有关管理令牌和令牌类型的更多信息,请参见 管理令牌

设置 influx CLI 连接配置

命令行接口 influx 让你创建连接配置,自动为 CLI 命令提供 主机组织API 令牌 凭据。使用与 InfluxDB 2.x 一起打包的 influx CLI 和 influx config create 命令 来设置 InfluxDB Cloud 实例和 InfluxDB 2.x 实例的连接配置。

为每个配置包含以下标志:

  • --config-name: 连接配置的唯一名称。 下面的示例分别使用 cloudoss
  • --host-url: InfluxDB Cloud 区域 URLInfluxDB 2.x URL
  • --org: InfluxDB 组织名称。 在 InfluxDB Cloud 中,默认的组织名称是与您的帐户关联的电子邮件地址。
  • --token: 用于连接到 InfluxDB 的 API 令牌。
    • InfluxDB Cloud: 提供一个 全访问 令牌。
    • InfluxDB OSS 2.x: 提供一个 操作员令牌
创建一个 InfluxDB Cloud 连接配置
# Example cloud connection configuration
influx config create \
  --config-name cloud \
  --host-url https://cloud2.influxdata.com \
  --org your.email@example.com \
  --token mY5uP3rS3cRe7Cl0uDt0K3n
创建 InfluxDB 2.x 连接配置
# Example 2.x connection configuration
influx config create \
  --config-name oss \
  --host-url http://localhost:8086 \
  --org example-org \
  --token mY5uP3rS3cRe70S5t0K3n

使用模板迁移InfluxDB资源

InfluxDB 模板 让您导出 InfluxDB 资源,例如存储桶、 仪表板、标签、任务等,并将它们导入到另一个 InfluxDB 实例中。 从您的 InfluxDB 2.x 实例导出资源并迁移到 您的 InfluxDB Cloud 实例中。

InfluxDB Cloud 免费计划资源限制

如果升级到 InfluxDB Cloud 免费计划,您只能创建 有限数量的资源。如果您的导出模板超出这些限制,资源迁移将会失败。

  • 所有资源 从 InfluxDB 2.x 组织迁移到 InfluxDB Cloud 组织:
    使用 influx export all 命令 并将输出通过管道传递到 influx apply 命令。使用 --active-config 标志与每个命令一起指定要使用的连接配置:

    influx export all --active-config oss | influx apply --active-config cloud
    
  • 从 InfluxDB 2.x 组织迁移 特定资源 到 InfluxDB Cloud 组织:
    使用 influx export 命令 带有要导出的特定资源列表或 influx export all 命令 与过滤器。将输出通过管道传递给 influx apply 命令。 使用 --active-config 标志与每个命令一起指定要使用的连接配置:

    influx export \
      --active-config oss \
      --buckets 0Xx0oox00XXoxxoo1,0Xx0oox00XXoxxoo2 \
      --labels o0x0oox0Xxoxx001,o0x0oox0Xxoxx002 \
      --dashboards 0XxXooXoo0xooXo0X1,0XxXooXoo0xooXo0X2 | \
    influx apply --active-config cloud
    
    influx export all \
      --active-config oss \
      --filter=resourceKind=Bucket \
      --filter=resourceKind=Dashboard \
      --filter=labelName=Foo | \
    influx apply --active-config cloud
    

    有关更多导出命令示例,请参见 influx exportinflux export all 文档。

    更新硬编码的 InfluxDB URLs

    如果您的任何迁移资源包含硬编码的 InfluxDB URL (http://localhost:8086),请执行以下操作之一将这些 URL 更新为您的 InfluxDB Cloud 区域 URL

    • Migrate your resources to InfluxDB Cloud, and then update URLs in the InfluxDB Cloud UI.
    • Save your template to a file, update URLs in the file, and then apply the template to your InfluxDB Cloud instance.

迁移 DBRP 映射

InfluxDB 数据库和保留策略 (DBRP) 映射允许您使用 InfluxQL 查询 InfluxDB Cloud 桶,遵循 InfluxDB 1.x DBRP 约定。如果您的 InfluxDB 2.x 实例中有 DBRP 映射,请将它们迁移到您的 InfluxDB Cloud 实例。

迁移DBRP映射到InfluxDB Cloud

双写到 InfluxDB 2.x 和 InfluxDB Cloud

更新外部客户端以写入您的 InfluxDB Cloud 实例。 我们建议在您完成 迁移现有时间序列数据 之前,同时将数据写入 InfluxDB 2.x 和 InfluxDB Cloud。有关逐步说明,请参见 双重写入

迁移时间序列数据

要将您的时间序列数据从 InfluxDB 2.x 实例迁移到 InfluxDB Cloud 实例,请执行以下操作:

  1. 使用influx bucket list命令查看您的InfluxDB 2.x存储桶及其ID的列表。

    influx bucket list --active-config oss
    
  2. 使用influxd inspect export-lp命令从您的InfluxDB 2.x实例中的一个桶导出数据为线协议。包括以下标志:

    • --bucket-id: 要导出的存储桶ID
    • --engine-path: InfluxDB 引擎路径
    • --output-path: 输出文件路径
    • --compress: (可选) 压缩导出的行协议为Gzip
    • --start: (可选) 导出的最早时间戳
    • --end: (可选) 最新的导出时间戳
    influxd inspect export-lp \
      --bucket-id 12ab34cd56ef \
      --engine-path ~/.influxdbv2/engine \
      --compress \
      --output-path path/to/bucket-export.lp
    
  3. 使用influx write命令将导出的行协议写入您的InfluxDB Cloud实例。提供以下内容。

    • --bucket: 目标桶名称

      --bucket-id: 目标桶ID
    • --compression: (可选) gzip 如果导出的行协议被压缩
    • --file: 导入文件路径
    influx write \
      --active-config cloud \
      --bucket example-bucket \
      --compression gzip \
      --file path/to/bucket-export.lp
    
  4. 对每个存储桶重复步骤 2-3。

InfluxDB Cloud 写入速率限制

写请求受到与您的 InfluxDB Cloud 定价计划相关的速率限制。 如果您导出的行协议大小可能超过您的速率限制,请考虑执行以下操作之一:

  • influx write 中包含 --rate-limit 标志来限制写入数据的速率。

    influx write \
      --active-config cloud \
      --bucket example-bucket \
      --file path/to/bucket-export.lp \
      --rate-limit "5MB/5min"
    
  • influxd inspect export-lp中包含--start--end标志,以按时间限制导出的数据,然后顺序写入连续的时间范围。

    influxd inspect export-lp \
      --bucket-id 12ab34cd56ef \
      --engine-path ~/.influxdbv2/engine \
      --start 2021-01-01T00:00:00Z \
      --end 2021-02-01T00:00:00Z \
      --compress \
      --output-path path/to/example-bucket-jan-2021.lp
    

为了最小化网络带宽使用,我们推荐使用gzip来压缩导出的行协议。
然而,当写入InfluxDB Cloud时,数据输入摄取批量大小速率限制跟踪未压缩行协议的有效载荷大小。

迁移系统存储桶

InfluxDB system buckets 包含与 InfluxDB 监控和警报系统相关的数据。尽管 InfluxDB Cloud 和 InfluxDB 2.x 中系统桶的保留期限仅为七天,但如果您想迁移这些数据,请使用上述描述的方法 to migrate time series data

在一个命令中导出并写入数据

如果您的数据和速率限制允许,您可以在单个命令中导出并写入数据,而无需将行协议导出文件写入磁盘。influxd inspect export-lp 命令可以输出到 stdout,而 influx write 命令接受来自 stdin 的行协议。

导出和写入数据

与其他用户协作

要与您在 InfluxDB Cloud 组织中的其他用户协作,邀请用户加入您的组织



Flux的未来

Flux 正在进入维护模式。您可以像现在一样继续使用它,而无需对您的代码进行任何更改。

阅读更多

InfluxDB 3 开源版本现已公开Alpha测试

InfluxDB 3 Open Source is now available for alpha testing, licensed under MIT or Apache 2 licensing.

我们将发布两个产品作为测试版的一部分。

InfluxDB 3 核心,是我们新的开源产品。 它是一个用于时间序列和事件数据的实时数据引擎。 InfluxDB 3 企业版是建立在核心基础之上的商业版本,增加了历史查询能力、读取副本、高可用性、可扩展性和细粒度安全性。

有关如何开始的更多信息,请查看:

由TSM驱动的InfluxDB Cloud