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

> Cloud SQL for MySQL を ClickPipes のソースとして設定する手順を説明するガイド

# Cloud SQL for MySQL ソースの設定ガイド

export const Image = ({img, alt, size}) => {
  return <Frame>
      <img src={img} alt={alt} />
    </Frame>;
};

これは、MySQL ClickPipe を使用して Cloud SQL for MySQL インスタンスのデータをレプリケートするための設定手順ガイドです。

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

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

<div id="enable-binlog-logging-gcp">
  ### PITR によるバイナリログの有効化
</div>

PITR 機能によって、Google Cloud 上の MySQL でバイナリログを有効または無効にするかが決まります。これは Cloud コンソールで Cloud SQL インスタンスを編集し、以下のセクションまでスクロールして設定できます。

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/2Zeerd64Tl5ZAQUa/images/integrations/data-ingestion/clickpipes/mysql/source/gcp/gcp-mysql-pitr.png?fit=max&auto=format&n=2Zeerd64Tl5ZAQUa&q=85&s=3ff38799aaa57ca03541bb3951675624" alt="Cloud SQL で PITR を有効化" size="lg" border width="1622" height="1800" data-path="images/integrations/data-ingestion/clickpipes/mysql/source/gcp/gcp-mysql-pitr.png" />

レプリケーションの用途に応じて、値は十分長めに設定することを推奨します。

まだ設定していない場合は、Cloud SQL を編集し、データベース フラグのセクションで以下を設定してください。

1. `binlog_expire_logs_seconds` を `86400` (1 日) 以上に設定する
2. `binlog_row_metadata` を `FULL` に設定する
3. `binlog_row_image` を `FULL` に設定する

これを行うには、インスタンスの概要ページ右上にある `Edit` ボタンをクリックします。

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/2Zeerd64Tl5ZAQUa/images/integrations/data-ingestion/clickpipes/mysql/source/gcp/gcp-mysql-edit-button.png?fit=max&auto=format&n=2Zeerd64Tl5ZAQUa&q=85&s=975410975dd8948188c3399078c194ae" alt="GCP MySQL の Edit ボタン" size="lg" border width="2174" height="570" data-path="images/integrations/data-ingestion/clickpipes/mysql/source/gcp/gcp-mysql-edit-button.png" />

次に、`Flags` セクションまでスクロールし、上記のフラグを追加します。

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/2Zeerd64Tl5ZAQUa/images/integrations/data-ingestion/clickpipes/mysql/source/gcp/gcp-mysql-flags.png?fit=max&auto=format&n=2Zeerd64Tl5ZAQUa&q=85&s=037387c0ed00250ed9e1438d5b593191" alt="GCP で binlog フラグを設定" size="lg" border width="1174" height="1810" data-path="images/integrations/data-ingestion/clickpipes/mysql/source/gcp/gcp-mysql-flags.png" />

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

root ユーザーとして Cloud SQL MySQL インスタンスに接続し、次のコマンドを実行します。

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

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

2. スキーマに対する権限を付与します。以下の例は、`clickpipes` データベースに対する権限を示しています。レプリケーションする各データベースおよびホストについて、これらのコマンドを繰り返してください。

   ```sql theme={null}
   GRANT SELECT ON `clickpipes`.* 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-gcp-mysql">
  ## ネットワークアクセスを設定する
</div>

Cloud SQL インスタンスへのトラフィックを制限する場合は、Cloud SQL MySQL インスタンスの許可リストに、[ドキュメントに記載されている固定 NAT IP](/ja/integrations/clickpipes/home#list-of-static-ips) を追加してください。
これは、インスタンスを編集するか、Cloud コンソール のサイドバーにある `Connections` タブから設定できます。

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/2Zeerd64Tl5ZAQUa/images/integrations/data-ingestion/clickpipes/mysql/source/gcp/gcp-mysql-ip.png?fit=max&auto=format&n=2Zeerd64Tl5ZAQUa&q=85&s=e1cbbd3b7989c19de040f797429d2d50" alt="GCP MySQL での IP 許可リスト設定" size="lg" border width="1110" height="1598" data-path="images/integrations/data-ingestion/clickpipes/mysql/source/gcp/gcp-mysql-ip.png" />

<div id="download-root-ca-certificate-gcp-mysql">
  ## ルートCA証明書をダウンロードして使用する
</div>

Cloud SQL インスタンスに接続するには、ルートCA証明書をダウンロードする必要があります。

1. Cloud コンソールで Cloud SQL インスタンスを開きます。
2. サイドバーで `Connections` をクリックします。
3. `Security` タブをクリックします。
4. `Manage server CA certificates` セクションで、下部の `DOWNLOAD CERTIFICATES` ボタンをクリックします。

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/2Zeerd64Tl5ZAQUa/images/integrations/data-ingestion/clickpipes/mysql/source/gcp/gcp-mysql-cert.png?fit=max&auto=format&n=2Zeerd64Tl5ZAQUa&q=85&s=2a974f67658678ccf70dcd061b211b96" alt="GCP MySQL 証明書のダウンロード" size="lg" border width="1584" height="1098" data-path="images/integrations/data-ingestion/clickpipes/mysql/source/gcp/gcp-mysql-cert.png" />

5. ClickPipes UI で、新しい MySQL ClickPipe の作成時に、ダウンロードした証明書をアップロードします。

<Image img="https://mintcdn.com/private-7c7dfe99-mintlify-fbfa8bee/2Zeerd64Tl5ZAQUa/images/integrations/data-ingestion/clickpipes/mysql/source/gcp/rootca.png?fit=max&auto=format&n=2Zeerd64Tl5ZAQUa&q=85&s=b35ec2089934eba61bec2bdde0c02ee0" alt="GCP MySQL 証明書の使用" size="lg" border width="1636" height="1170" data-path="images/integrations/data-ingestion/clickpipes/mysql/source/gcp/rootca.png" />
