

Amazon Timestream for LiveAnalytics に類似した機能をご希望の場合は Amazon Timestream for InfluxDB をご検討ください。リアルタイム分析に適した、シンプルなデータインジェストと 1 桁ミリ秒のクエリ応答時間を特徴としています。詳細については、[こちら](https://docs.aws.amazon.com//timestream/latest/developerguide/timestream-for-influxdb.html)を参照してください。

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# 移行の概要
<a name="timestream-for-influx-getting-started-migrating-data-overview"></a>

前提条件を満たした後、以下を行います。

1. 移行スクリプトを実行する: お使いのターミナルアプリで Python スクリプトを実行し、送信元 InfluxDB インスタンスから送信先 InfluxDB インスタンスにデータを転送します。

1. 認証情報を入力する: ホストアドレスとポートを CLI オプションとして入力します。

1. データを検証する: 次の方法でデータが正しく転送されていることを確認します。

   1. InfluxDB UI を使用しバケットを調べる。

   1. `influx bucket list -t <destination token> --host <destination host address> --skip-verify` を使用してバケットを一覧表示する。

   1. `influx v1 shell -t <destination token> --host <destination host address> --skip-verify` を使用して `SELECT * FROM <migrated bucket>.<retention period>.<measurement name> LIMIT 100 to view contents of a bucket or SELECT COUNT(*) FROM <migrated bucket>.<retention period>.<measurment name>` を実行し、正しい数のレコードが移行されたことを確認する。

**Example 実行の例**  

1. お使いのターミナルアプリを開き、必要な前提条件が正しく設定されていることを確認します。  
![スクリプトの前提条件。](http://docs.aws.amazon.com/ja_jp/timestream/latest/developerguide/images/script-pre-reqs.png)

1. 移行スクリプトに移動します。  
![スクリプトの場所](http://docs.aws.amazon.com/ja_jp/timestream/latest/developerguide/images/script-navigate.png)

1. 以下の情報を準備します。

   1. 移行するソースバケットの名前。

   1. (オプション) 送信先サーバーにある移行済みバケットの新しいバケット名を選択します。

   1. 送信元および送信先の Influx インスタンスのルートトークン。

   1. 送信元および送信先の Influx インスタンスのホストアドレス。

   1. (オプション) S3 バケット名と認証情報。 AWS Command Line Interface 認証情報は OS 環境変数で設定する必要があります。

      ```
      # AWS credentials (for timestream testing)
          export AWS_ACCESS_KEY_ID="xxx"
          export AWS_SECRET_ACCESS_KEY="xxx"
      ```

   1. コマンドを次のように作成します。

      ```
      python3 influx_migration.py --src-bucket [amzn-s3-demo-source-bucket]  --dest-bucket [amzn-s3-demo-destination-bucket] --src-host [source host] --dest-host [dest host] --s3-bucket [amzn-s3-demo-bucket2](optional) --log-level debug
      ```

   1. スクリプトを実行します。  
![スクリプトの実行](http://docs.aws.amazon.com/ja_jp/timestream/latest/developerguide/images/script-execution.png)

   1. スクリプトの実行が終了するまで待ちます。

   1. 新たに移行したバケットのデータの完全性、`performance.txt` を確認します。このファイルは、スクリプトを実行したディレクトリと同じディレクトリにあり、各ステップに要する時間に関する基本情報が含まれています。

## 移行シナリオ
<a name="timestream-for-influx-migration-scenarios"></a>

**Example 例 1: ローカルストレージを使用した簡単な移行**  
単一のバケット amzn-s3-demo-primary-bucket を、送信元サーバー `(http://localhost:8086)` から送信先サーバー `(http://dest-server-address:8086)` に移行します。  
ポート 8086 に、InfluxDB インスタンスをホストする両方のマシンへの TCP アクセス (HTTP アクセス用) があり、送信元トークンと送信先トークンの両方があり、それぞれ環境変数 `INFLUX_SRC_TOKEN` および `INFLUX_DEST_TOKEN` として保存されていることを確認したら、以下によりセキュリティを強化します。  

```
python3 influx_migration.py --src-bucket amzn-s3-demo-primary-bucket --src-host http://localhost:8086 --dest-host http://dest-server-address:8086
```
出力は次の例に類似したものになります:  

```
INFO: influx_migration.py: Backing up bucket data and metadata using the InfluxDB CLI
2023/10/26 10:47:15 INFO: Downloading metadata snapshot
2023/10/26 10:47:15 INFO: Backing up TSM for shard 1
2023/10/26 10:47:15 INFO: Backing up TSM for shard 8245
2023/10/26 10:47:15 INFO: Backing up TSM for shard 8263
[More shard backups . . .]
2023/10/26 10:47:20 INFO: Backing up TSM for shard 8240
2023/10/26 10:47:20 INFO: Backing up TSM for shard 8268
2023/10/26 10:47:20 INFO: Backing up TSM for shard 2
INFO: influx_migration.py: Restoring bucket data and metadata using the InfluxDB CLI
2023/10/26 10:47:20 INFO: Restoring bucket "96c11c8876b3c016" as "amzn-s3-demo-primary-bucket"
2023/10/26 10:47:21 INFO: Restoring TSM snapshot for shard 12772
2023/10/26 10:47:22 INFO: Restoring TSM snapshot for shard 12773
[More shard restores . . .]
2023/10/26 10:47:28 INFO: Restoring TSM snapshot for shard 12825
2023/10/26 10:47:28 INFO: Restoring TSM snapshot for shard 12826
INFO: influx_migration.py: Migration complete
```
ディレクトリ `influxdb-backup-<timestamp>` が作成され、スクリプトが実行されたディレクトリに保存され、そこにバックアップファイルが追加されます。



**Example 例 2: ローカルストレージとデバッグログを使用した完全な移行**  
上記と同じですが、すべてのバケット、トークン、ユーザー、ダッシュボードを移行し、送信先サーバーのバケットを削除し、`--confirm-full` オプションを使用してユーザーが完全なデータベース移行を確認することなく先に進みます。また、デバッグログを有効にするために、パフォーマンスのメジャーメントを確認する必要もあります。  

```
python3 influx_migration.py --full --confirm-full --src-host http://localhost:8086 --dest-host http://dest-server-address:8086 --log-level debug
```
出力は次の例に類似したものになります:  

```
INFO: influx_migration.py: Backing up bucket data and metadata using the InfluxDB CLI
2023/10/26 10:55:27 INFO: Downloading metadata snapshot
2023/10/26 10:55:27 INFO: Backing up TSM for shard 6952
2023/10/26 10:55:27 INFO: Backing up TSM for shard 6953
[More shard backups . . .]
2023/10/26 10:55:36 INFO: Backing up TSM for shard 8268
2023/10/26 10:55:36 INFO: Backing up TSM for shard 2
DEBUG: influx_migration.py: backup started at 2023-10-26 10:55:27 and took 9.41 seconds to run.
INFO: influx_migration.py: Restoring bucket data and metadata using the InfluxDB CLI
2023/10/26 10:55:36 INFO: Restoring KV snapshot
2023/10/26 10:55:38 WARN: Restoring KV snapshot overwrote the operator token, ensure following commands use the correct token
2023/10/26 10:55:38 INFO: Restoring SQL snapshot
2023/10/26 10:55:39 INFO: Restoring TSM snapshot for shard 6952
2023/10/26 10:55:39 INFO: Restoring TSM snapshot for shard 6953
[More shard restores . . .]
2023/10/26 10:55:49 INFO: Restoring TSM snapshot for shard 8268
2023/10/26 10:55:49 INFO: Restoring TSM snapshot for shard 2
DEBUG: influx_migration.py: restore started at 2023-10-26 10:55:36 and took 13.51 seconds to run.
INFO: influx_migration.py: Migration complete
```



**Example 例 3: CSV、送信先組織、S3 バケットを使用した完全な移行**  
前述の例と同じですが、Linux または Mac を使用してファイルを S3 バケット `amzn-s3-demo-bucket` に保存します。これで、バックアップファイルがローカルストレージの容量に過負荷をかけることを回避できます。  

```
python3 influx_migration.py --full --src-host http://localhost:8086 --dest-host http://dest-server-address:8086 --csv --dest-org MyOrg --s3-bucket amzn-s3-demo-bucket
```
出力は次の例に類似したものになります:  

```
INFO: influx_migration.py: Creating directory influxdb-backups
INFO: influx_migration.py: Mounting amzn-s3-demo-influxdb-migration-bucket
INFO: influx_migration.py: Creating directory influxdb-backups/amzn-s3-demo-bucket/influxdb-backup-1698352128323
INFO: influx_migration.py: Backing up bucket data and metadata using the InfluxDB v2 API
INFO: influx_migration.py: Restoring bucket data and metadata from csv
INFO: influx_migration.py: Restoring bucket amzn-s3-demo-some-bucket
INFO: influx_migration.py: Restoring bucket amzn-s3-demo-another-bucket
INFO: influx_migration.py: Restoring bucket amzn-s3-demo-primary-bucket
INFO: influx_migration.py: Migration complete
INFO: influx_migration.py: Unmounting influxdb-backups
INFO: influx_migration.py: Removing temporary mount directory
```