> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-detect-table-modification.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Amazon RDS MariaDB を ClickPipes のソースとして設定するための手順ガイド

# RDS MariaDB ソースの設定ガイド

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 経由でデータをレプリケーションするために、RDS MariaDB インスタンスを設定する手順をまとめたガイドです。

<br />

<Info>
  [こちら](/ja/integrations/clickpipes/mysql/faq)の MySQL に関するよくある質問にも、あわせて目を通すことをお勧めします。よくある質問ページは随時更新されています。
</Info>

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

バイナリログは、MySQLサーバーのインスタンスで行われたデータ変更に関する情報を含む一連のログファイルです。バイナリログファイルはレプリケーションに必要です。以下の両方の手順を実行する必要があります。

<div id="enable-binlog-logging-rds">
  ### 1. 自動バックアップによるバイナリログの有効化
</div>

自動バックアップ機能によって、MySQL でバイナリログを有効にするかどうかが決まります。これは AWS コンソールで設定できます。

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

レプリケーションの用途に応じて、バックアップ保持期間は十分に長めに設定することを推奨します。

<div id="binlog-retention-hours-rds">
  ### 2. binlog の保持時間
</div>

Amazon RDS for MariaDB では、binlog の保持期間 (変更内容を含む binlog ファイルを保持しておく時間) の設定方法が異なります。binlog ファイルが削除される前に一部の変更が読み取られないと、レプリケーションを継続できなくなります。binlog retention hours のデフォルト値は NULL で、これはバイナリログが保持されないことを意味します。

DB インスタンスでバイナリログを保持する時間数を指定するには、レプリケーションに十分な長さの binlog の保持期間を指定して、mysql.rds\_set\_configuration 関数を使用します。推奨される最小値は `24 hours` です。

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

<div id="binlog-parameter-group-rds">
  ## パラメータグループで binlog 設定を構成する
</div>

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

<Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/Qdrmbc1T54ihl0_n/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/rds_config.webp?fit=max&auto=format&n=Qdrmbc1T54ihl0_n&q=85&s=161752b6bce88b03775804018ae96347" alt="RDS でパラメータグループを確認する場所" size="lg" border width="708" height="853" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/rds_config.webp" />

パラメータグループのリンクをクリックすると、パラメータグループのページに移動します。右上に `Edit` ボタンがあります。

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

`binlog_format`、`binlog_row_metadata`、`binlog_row_image` は次のように設定する必要があります。

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

<Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/Qdrmbc1T54ihl0_n/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_format.webp?fit=max&auto=format&n=Qdrmbc1T54ihl0_n&q=85&s=538ac4d105d9090e01c8c0d820f93cde" alt="Binlog format を 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-detect-table-modification/Qdrmbc1T54ihl0_n/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_metadata.webp?fit=max&auto=format&n=Qdrmbc1T54ihl0_n&q=85&s=2a8bb8ec83b7dcb3700ae4109201bf24" alt="Binlog row metadata を FULL に設定" 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-detect-table-modification/Qdrmbc1T54ihl0_n/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_image.webp?fit=max&auto=format&n=Qdrmbc1T54ihl0_n&q=85&s=584f5f33af3a683339880f79aca732aa" alt="Binlog row image を FULL に設定" size="lg" border width="934" height="234" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_image.webp" />

次に、右上の `Save Changes` をクリックします。変更を反映するには、インスタンスの再起動が必要になる場合があります。RDS インスタンスの `Configurations` タブで、パラメータグループのリンクの横に `Pending reboot` と表示されている場合は、インスタンスの再起動が必要である可能性が高いことを示しています。

<br />

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

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

Global Transaction Identifiers (GTID) は、MySQL/MariaDB でコミットされた各トランザクションに割り当てられる一意の ID です。これにより、binlog レプリケーションが簡素化され、トラブルシューティングも容易になります。MariaDB ではデフォルトで GTID モードが有効になっているため、利用するためにユーザー側で追加の操作を行う必要はありません。

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

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

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

   ```sql theme={null}
   CREATE USER 'clickpipes_user'@'host' 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="configure-network-access">
  ## ネットワークアクセスを設定する
</div>

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

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

<Image img="https://mintcdn.com/private-7c7dfe99-detect-table-modification/Qdrmbc1T54ihl0_n/images/integrations/data-ingestion/clickpipes/mysql/source/rds/security-group-in-rds-mysql.webp?fit=max&auto=format&n=Qdrmbc1T54ihl0_n&q=85&s=71300997912778c80deba5b411225fd6" alt="RDS でセキュリティグループはどこにありますか？" 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-detect-table-modification/nH26ELfEvmC8yX3w/images/integrations/data-ingestion/clickpipes/postgres/source/rds/edit_inbound_rules.webp?fit=max&auto=format&n=nH26ELfEvmC8yX3w&q=85&s=fd70b9d17dea4a777163ef8237fd6e5f" 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>

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