> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.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}) => {
  return <Frame>
      <img src={img} alt={alt} />
    </Frame>;
};

これは、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-fix-nav-issues/8xU-7NRzcVe16bmG/images/integrations/data-ingestion/clickpipes/mysql/source/rds/rds-backups.png?fit=max&auto=format&n=8xU-7NRzcVe16bmG&q=85&s=90254433b20a2c148eff941e000a09c7" alt="RDS で自動バックアップを有効にする" size="lg" border width="3230" height="530" data-path="images/integrations/data-ingestion/clickpipes/mysql/source/rds/rds-backups.png" />

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

<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-fix-nav-issues/lGskH5qUgz9Vtlav/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/rds_config.png?fit=max&auto=format&n=lGskH5qUgz9Vtlav&q=85&s=43680fa1238b0257129bd71baeabe863" alt="RDS でパラメータグループを確認する場所" size="lg" border width="708" height="853" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/rds_config.png" />

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

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

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

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

<Image img="https://mintcdn.com/private-7c7dfe99-fix-nav-issues/lGskH5qUgz9Vtlav/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_format.png?fit=max&auto=format&n=lGskH5qUgz9Vtlav&q=85&s=577d8354fff2ec7786d7bf858841b375" alt="Binlog format を ROW に設定" size="lg" border width="960" height="232" data-path="images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_format.png" />

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

<Image img="https://mintcdn.com/private-7c7dfe99-fix-nav-issues/lGskH5qUgz9Vtlav/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_metadata.png?fit=max&auto=format&n=lGskH5qUgz9Vtlav&q=85&s=ea2ca2f04e8241d31bface4647a36199" 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.png" />

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

<Image img="https://mintcdn.com/private-7c7dfe99-fix-nav-issues/lGskH5qUgz9Vtlav/images/integrations/data-ingestion/clickpipes/mysql/parameter_group/binlog_row_image.png?fit=max&auto=format&n=lGskH5qUgz9Vtlav&q=85&s=0d6367589076ab5fb1875645fd69a87c" 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.png" />

次に、右上の `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-fix-nav-issues/8xU-7NRzcVe16bmG/images/integrations/data-ingestion/clickpipes/mysql/source/rds/security-group-in-rds-mysql.png?fit=max&auto=format&n=8xU-7NRzcVe16bmG&q=85&s=a3aa579333d3437ccec8476951ec5cc8" alt="RDS でセキュリティグループはどこにありますか？" size="lg" border width="2850" height="994" data-path="images/integrations/data-ingestion/clickpipes/mysql/source/rds/security-group-in-rds-mysql.png" />

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

<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)を参照してください。
