> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> Amazon Aurora MySQL を ClickPipes のソースとして設定するためのステップバイステップガイド

# Aurora MySQL ソース設定ガイド

export const Image = ({img, alt, size = "lg"}) => {
  const normalizedSize = ["sm", "md", "lg"].includes(size) ? size : "lg";
  return <div className={`ch-image-${normalizedSize}`}>
      <Frame>
        <img src={img} alt={alt} />
      </Frame>
    </div>;
};

このステップバイステップガイドでは、[MySQL ClickPipe](/docs/ja/integrations/clickpipes/mysql/index) を使用して、Amazon Aurora MySQL から ClickHouse Cloud にデータをレプリケートするよう設定する方法を説明します。MySQL CDC (変更データキャプチャ) に関するよくある質問については、[MySQL よくある質問ページ](/docs/ja/integrations/clickpipes/mysql/faq) を参照してください。

<div id="enable-binlog-retention-aurora">
  ## バイナリログ保持を有効にする
</div>

バイナリログは、MySQL サーバーインスタンスで行われたデータ変更に関する情報を含む一連のログファイルであり、レプリケーションにはバイナリログファイルが必要です。Aurora MySQL でバイナリログ保持を設定するには、[バイナリログを有効にし](#enable-binlog-logging)、[binlog の保持期間を延長する](#binlog-retention-interval)必要があります。

<Steps>
  <Step title="自動バックアップでバイナリログを有効にする" id="enable-binlog-logging">
    自動バックアップ機能によって、MySQL でバイナリログを有効にするかどうかが決まります。自動バックアップは、RDS Console で **Modify** > **Additional configuration** > **Backup** に移動し、**Enable automated backups** チェックボックスを選択することで (まだ選択されていない場合) インスタンスに設定できます。

    <Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/mysql/source/rds/rds-backups.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=21ca5d0f6d6dfda1a398b336782fb229" alt="Aurora で自動バックアップを有効にする" size="lg" border width="3230" height="530" data-path="images/integrations/data-ingestion/clickpipes/mysql/source/rds/rds-backups.webp" />

    レプリケーションのユースケースに応じて、**Backup retention period** は十分に長い値に設定することを推奨します。
  </Step>

  <Step title="binlog の保持期間を延長する" id="binlog-retention-interval">
    <Warning>
      ClickPipes がレプリケーションの再開を試みた際、設定された binlog の保持期間が原因で必要な binlog ファイルがすでに削除されていると、ClickPipe はエラー状態になり、再同期が必要になります。
    </Warning>

    デフォルトでは、Aurora MySQL はバイナリログをできるだけ早く削除します (つまり、*遅延パージ*) 。障害発生時でもレプリケーションに必要な バイナリログ ファイルを利用できるようにするため、binlog の保持期間は少なくとも **72 時間** に延長することを推奨します。バイナリログ の保持期間 ([`binlog retention hours`](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/mysql-stored-proc-configuring.html#mysql_rds_set_configuration-usage-notes.binlog-retention-hours)) を設定するには、[`mysql.rds_set_configuration`](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/mysql-stored-proc-configuring.html#mysql_rds_set_configuration) プロシージャを使用します。

    [//]: # "注: 多くの CDC（変更データキャプチャ）プロバイダーは、Aurora RDS の最大保持期間（7 日間 / 168 時間）を推奨しています。これはディスク使用量に影響するため、ここでは控えめに最小 3 日間 / 72 時間を推奨しています。"

    ```text theme={null}
    mysql=> call mysql.rds_set_configuration('binlog retention hours', 72);
    ```

    この設定がされていない、または間隔が短すぎると、バイナリログに欠落が生じ、ClickPipes がレプリケーションを再開できなくなるおそれがあります。
  </Step>
</Steps>

<div id="binlog-settings">
  ## binlog 設定を構成する
</div>

パラメータグループは、RDS Console で MySQL インスタンスをクリックし、**Configuration** タブに移動すると確認できます。

<Tip>
  MySQL クラスターを使用している場合、以下のパラメータは DB インスタンスグループではなく、[DB cluster](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_WorkingWithParamGroups.CreatingCluster.html) のパラメータグループにあります。
</Tip>

<Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/aurora_config.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=ec0ef20aec0663ad14d674699ce54c1b" alt="Aurora でパラメータグループを確認する場所" size="lg" border width="1524" height="901" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/aurora_config.webp" />

<br />

パラメータグループのリンクをクリックすると、その詳細ページに移動します。右上に **Edit** ボタンが表示されるはずです。

<Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/edit_button.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=3b73e47820d72b09c2238a8fce0df716" alt="パラメータグループの編集" size="lg" border width="1662" height="292" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/edit_button.webp" />

<br />

以下のパラメータを次のように設定する必要があります。

1. `binlog_format` を `ROW` に設定します。

<Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_format.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=98ccb656415f8e43ebfe03c26f4bf908" alt="Binlog フォーマットを ROW に設定" size="lg" border width="960" height="232" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_format.webp" />

2. `binlog_row_metadata` を `FULL` に設定します。

<Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_metadata.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=75008a3321f0b26b2111d8f14d80e3fe" alt="Binlog 行メタデータ" size="lg" border width="934" height="234" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_metadata.webp" />

3. `binlog_row_image` を `FULL` に設定します。

<Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_image.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=a5660a6f88829e05eefca1eb7dcea83a" alt="Binlog 行イメージ" size="lg" border width="934" height="234" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_image.webp" />

<br />

その後、右上の **Save Changes** をクリックします。変更を反映するには、インスタンスの再起動が必要な場合があります。Aurora インスタンスの **Configuration** タブで、パラメータグループのリンクの横に `Pending reboot` と表示されていれば、それが目印です。

<div id="gtid-mode">
  ## GTID モードを有効にする (推奨)
</div>

<Tip>
  MySQL ClickPipe は、GTID モードを使用しないレプリケーションにも対応しています。ただし、パフォーマンス向上とトラブルシューティングのしやすさのため、GTID モードを有効にすることを推奨します。
</Tip>

[Global Transaction Identifiers (GTIDs)](https://dev.mysql.com/doc/refman/8.0/en/replication-gtids.html) は、MySQL でコミットされた各トランザクションに割り当てられる一意の ID です。これにより、binlog レプリケーションが簡素化され、トラブルシューティングもしやすくなります。MySQL ClickPipe が GTID ベースのレプリケーションを使用できるようにするため、GTID モードを有効にすることを**推奨**します。

GTID ベースのレプリケーションは、Amazon Aurora MySQL v2 (MySQL 5.7) および v3 (MySQL 8.0) 、ならびに Aurora Serverless v2 でサポートされています。Aurora MySQL インスタンスで GTID モードを有効にするには、次の手順に従ってください。

1. RDS Console で、MySQL インスタンスをクリックします。
2. **Configuration** タブをクリックします。
3. パラメータグループのリンクをクリックします。
4. 右上の **Edit** ボタンをクリックします。
5. `enforce_gtid_consistency` を `ON` に設定します。
6. `gtid-mode` を `ON` に設定します。
7. 右上の **Save Changes** をクリックします。
8. 変更を反映するため、インスタンスを再起動します。

<Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/mysql/enable_gtid.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=e27af3084b41fb2f1c326542f14c01d1" alt="GTID が有効" size="lg" border width="1650" height="469" data-path="images/integrations/data-ingestion/clickpipes/mysql/enable_gtid.webp" />

<div id="configure-database-user">
  ## データベースユーザーを設定する
</div>

管理者ユーザーとして Aurora MySQL インスタンスに接続し、次のコマンドを実行します。

1. ClickPipes 専用のユーザーを作成します。

   ```sql theme={null}
   CREATE USER 'clickpipes_user'@'%' IDENTIFIED BY 'some-password';
   ```

2. スキーマに対する権限を付与します。次の例は、`mysql` データベースに対する権限を示しています。レプリケーション対象の各データベースとホストについて、これらのコマンドを繰り返します。

   ```sql theme={null}
   GRANT SELECT ON `mysql`.* TO 'clickpipes_user'@'host';
   ```

3. ユーザーにレプリケーション権限を付与します。

   ```sql theme={null}
   GRANT REPLICATION CLIENT ON *.* TO 'clickpipes_user'@'%';
   GRANT REPLICATION SLAVE ON *.* TO 'clickpipes_user'@'%';
   ```

<div id="iam-authentication">
  ### IAM認証を使用する (任意)
</div>

パスワードの代わりに、AWS IAM のロールベースアクセスを使用して ClickPipes ユーザーを認証できます。次のようにユーザーを作成し、その後、上記と同じスキーマおよびレプリケーションの権限を付与してください。

```sql theme={null}
CREATE USER 'clickpipes_iam_user' IDENTIFIED WITH AWSAuthenticationPlugin AS 'RDS';
```

ClickPipes がこの方法で認証を行うために必要な IAM ロールとポリシーの設定手順の詳細については、[AWS IAM DB認証 (RDS/Aurora)](/docs/ja/integrations/clickpipes/postgres/auth)を参照してください。

<div id="configure-network-access">
  ## ネットワークアクセスを設定する
</div>

<div id="ip-based-access-control">
  ### IP ベースのアクセス制御
</div>

Aurora MySQL インスタンスへのトラフィックを制限するには、[ドキュメントに記載されている固定 NAT IP](/docs/ja/integrations/clickpipes/home#list-of-static-ips) を、Aurora のセキュリティグループの **Inbound rules** に追加します。

<Image img="https://mintcdn.com/private-7c7dfe99/Rm4A9_kDxZf0ApeE/images/integrations/data-ingestion/clickpipes/mysql/source/rds/security-group-in-rds-mysql.webp?fit=max&auto=format&n=Rm4A9_kDxZf0ApeE&q=85&s=af38397cd478a3e845217f3cc0165a7f" alt="Aurora MySQL でセキュリティグループはどこで確認できますか？" size="lg" border width="2850" height="994" data-path="images/integrations/data-ingestion/clickpipes/mysql/source/rds/security-group-in-rds-mysql.webp" />

<Image img="https://mintcdn.com/private-7c7dfe99/dZZG_-B0EzCG8L4V/images/integrations/data-ingestion/clickpipes/postgres/source/rds/edit_inbound_rules.webp?fit=max&auto=format&n=dZZG_-B0EzCG8L4V&q=85&s=1176aa14815b965b841d70d28b5f0d7c" alt="上記のセキュリティグループのインバウンドルールを編集" size="lg" border width="1800" height="935" data-path="images/integrations/data-ingestion/clickpipes/postgres/source/rds/edit_inbound_rules.webp" />

<div id="private-access-via-aws-privatelink">
  ### AWS PrivateLink 経由のプライベートアクセス
</div>

Aurora MySQL インスタンスにプライベートネットワーク経由で接続するには、AWS PrivateLink を使用できます。接続の設定については、[ClickPipes 向け AWS PrivateLink セットアップガイド](/docs/ja/resources/support-center/knowledge-base/cloud-services/aws-privatelink-setup-for-clickpipes)を参照してください。

<div id="whats-next">
  ## 次のステップ
</div>

Amazon Aurora MySQL インスタンスで binlogレプリケーションが設定され、ClickHouse Cloud への安全な接続が確立されたら、[最初の MySQL ClickPipe を作成できます](/docs/ja/integrations/clickpipes/mysql/index#create-your-clickpipe)。MySQL CDC (変更データキャプチャ) に関する一般的な質問については、[MySQL よくある質問ページ](/docs/ja/integrations/clickpipes/mysql/faq)を参照してください。
