> ## 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.

> Kafka Connect と ClickHouse で ClickHouse Connector Sink を使用する

# Confluent platform と ClickHouse の統合

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>;
};

<div class="vimeo-container">
  <Frame>
    <iframe
      src="//www.youtube.com/embed/SQAiPVbd3gg"
      frameborder="0"
      allow="autoplay;
fullscreen;
picture-in-picture"
      allowfullscreen
    />
  </Frame>
</div>

<div id="prerequisites">
  ## 前提条件
</div>

以下に精通していることを前提としています。

* [ClickHouse Connector Sink](/docs/ja/integrations/connectors/data-ingestion/kafka/kafka-clickhouse-connect-sink)
* Confluent Platform と [Custom Connectors](https://docs.confluent.io/cloud/current/connectors/bring-your-connector/overview.html)。

<div id="the-official-kafka-connector-from-clickhouse-with-confluent-platform">
  ## Confluent Platform 向け ClickHouse 公式 Kafka コネクタ
</div>

<div id="installing-on-confluent-platform">
  ### Confluent Platform へのインストール
</div>

以下は、Confluent Platform で ClickHouse Sink Connector をすぐに使い始めるための簡単なガイドです。
詳細については、[Confluent の公式ドキュメント](https://docs.confluent.io/cloud/current/connectors/bring-your-connector/custom-connector-qs.html#uploading-and-launching-the-connector)を参照してください。

<div id="create-a-topic">
  #### トピックを作成する
</div>

Confluent Platform でトピックを作成するのは比較的簡単です。詳細な手順は[こちら](https://docs.confluent.io/cloud/current/client-apps/topics/manage.html)を参照してください。

<div id="important-notes">
  #### 重要な注意事項
</div>

* Kafkaトピック名は、ClickHouseテーブル名と同じである必要があります。これを調整するには、トランスフォーマー (たとえば [`ExtractTopic`](https://docs.confluent.io/platform/current/connect/transforms/extracttopic.html)) を使用します。
* パーティション数が多ければ、必ずしもパフォーマンスが向上するわけではありません。詳しくは、今後公開予定のガイドでパフォーマンス向上のヒントとあわせて紹介します。

<div id="install-connector">
  #### コネクタをインストールする
</div>

コネクタは当社の[repository](https://github.com/ClickHouse/clickhouse-kafka-connect/releases)からダウンロードできます。コメントやissueもぜひそちらにお寄せください。

"Connector Plugins" -> "Add plugin" に移動し、以下の設定を使用します。

```text theme={null}
'Connector Class' - 'com.clickhouse.kafka.connect.ClickHouseSinkConnector'
'Connector type' - Sink
'Sensitive properties' - 'password'. This will ensure entries of the ClickHouse password are masked during configuration.
```

例:

<Image img="https://mintcdn.com/private-7c7dfe99/pIetLsS_hOGHqoPJ/images/integrations/data-ingestion/kafka/confluent/AddCustomConnectorPlugin.webp?fit=max&auto=format&n=pIetLsS_hOGHqoPJ&q=85&s=5fdb90da6ed384d7e4560bce54acf8ee" size="md" alt="カスタム ClickHouse コネクタを追加するための設定が表示された Confluent Platform UI" border width="552" height="850" data-path="images/integrations/data-ingestion/kafka/confluent/AddCustomConnectorPlugin.webp" />

<div id="gather-your-connection-details">
  #### 接続情報を確認する
</div>

HTTP(S) で ClickHouse に接続するには、次の情報が必要です。

| Parameter(s)              | Description                                               |
| ------------------------- | --------------------------------------------------------- |
| `HOST` and `PORT`         | 通常、TLS を使用する場合のポートは 8443、TLS を使用しない場合は 8123 です。           |
| `DATABASE NAME`           | デフォルトでは `default` という名前のデータベースがあります。接続先のデータベース名を使用してください。 |
| `USERNAME` and `PASSWORD` | デフォルトのユーザー名は `default` です。用途に応じたユーザー名を使用してください。           |

ClickHouse Cloud サービスの詳細は、ClickHouse Cloud コンソールで確認できます。
サービスを選択し、**Connect** をクリックします。

<div className="ch-image-md">
  <Frame>
    <img src="https://mintcdn.com/private-7c7dfe99/CFFsa2agBPbviR4r/images/_snippets/cloud-connect-button.webp?fit=max&auto=format&n=CFFsa2agBPbviR4r&q=85&s=ec0a298a33ca841e947fa5e8bae47362" alt="ClickHouse Cloud サービスの接続ボタン" width="998" height="932" data-path="images/_snippets/cloud-connect-button.webp" />
  </Frame>
</div>

**HTTPS** を選択します。接続情報は `curl` コマンドの例として表示されます。

<div className="ch-image-md">
  <Frame>
    <img src="https://mintcdn.com/private-7c7dfe99/CFFsa2agBPbviR4r/images/_snippets/connection-details-https.webp?fit=max&auto=format&n=CFFsa2agBPbviR4r&q=85&s=cb0fbd98aa2b5b7ca484c9f53395ee07" alt="ClickHouse Cloud HTTPS 接続情報" width="1320" height="1184" data-path="images/_snippets/connection-details-https.webp" />
  </Frame>
</div>

セルフマネージド ClickHouse を使用している場合、接続情報は ClickHouse 管理者によって設定されます。

<div id="configure-the-connector">
  #### コネクタを設定する
</div>

`Connectors` -> `Add Connector` に移動し、以下の設定を使用します (値はあくまで例です) :

```json theme={null}
{
  "database": "<DATABASE_NAME>",
  "errors.retry.timeout": "30",
  "exactlyOnce": "false",
  "schemas.enable": "false",
  "hostname": "<CLICKHOUSE_HOSTNAME>",
  "password": "<SAMPLE_PASSWORD>",
  "port": "8443",
  "ssl": "true",
  "topics": "<TOPIC_NAME>",
  "username": "<SAMPLE_USERNAME>",
  "key.converter": "org.apache.kafka.connect.storage.StringConverter",
  "value.converter": "org.apache.kafka.connect.json.JsonConverter",
  "value.converter.schemas.enable": "false"
}
```

<div id="specify-the-connection-endpoints">
  #### 接続先エンドポイントを指定する
</div>

コネクタがアクセスできるエンドポイントの許可リストを指定する必要があります。
ネットワークの egress エンドポイントを追加する際は、完全修飾ドメイン名 (FQDN) を使用する必要があります。
例: `u57swl97we.eu-west-1.aws.clickhouse.com:8443`

<Note>
  HTTP(S) ポートを指定する必要があります。コネクタはまだネイティブプロトコルをサポートしていません。
</Note>

[ドキュメントを参照してください。](https://docs.confluent.io/cloud/current/connectors/bring-your-connector/custom-connector-qs.html#cc-byoc-endpoints)

これで準備完了です！

<div id="known-limitations">
  #### 既知の制限事項
</div>

* Custom Connectors では、パブリックインターネット上のエンドポイントを使用する必要があります。静的 IP アドレスはサポートされていません。
* 一部の Custom Connector プロパティはオーバーライドできます。詳しくは、[公式ドキュメントの一覧](https://docs.confluent.io/cloud/current/connectors/bring-your-connector/custom-connector-manage.html#override-configuration-properties)を参照してください。
* Custom Connectors は、[AWS の一部のリージョン](https://docs.confluent.io/cloud/current/connectors/bring-your-connector/custom-connector-fands.html#supported-aws-regions)でのみ利用できます。
* 詳しくは、[公式ドキュメントにある Custom Connectors の制限事項一覧](https://docs.confluent.io/cloud/current/connectors/bring-your-connector/custom-connector-fands.html#limitations)を参照してください。
