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

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

# Amazon DocumentDB ソースの設定ガイド

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

<div id="supported-documentdb-versions">
  ## サポートされる DocumentDB のバージョン
</div>

ClickPipes は DocumentDB バージョン 5.0 をサポートしています。

<div id="configure-change-stream-log-retention">
  ## 変更ストリームのログ保持期間を設定する
</div>

デフォルトでは、Amazon DocumentDB の変更ストリームのログ保持期間は 3 時間ですが、DocumentDB 内の既存データ量によっては初期ロードにそれよりも大幅に長い時間がかかる場合があります。初期スナップショットが完了する前にログが切り捨てられないよう、変更ストリームのログ保持期間は 72 時間以上に設定することを推奨します。

<div id="update-change-stream-log-retention-via-aws-console">
  ### AWS Console で変更ストリームのログ保持期間を更新する
</div>

1. 左側のパネルで `Parameter groups` をクリックし、DocumentDB クラスターで使用しているパラメータグループを見つけます (デフォルトのパラメータグループを使用している場合は、変更するために、まず新しいパラメータグループを作成する必要があります) 。

<Image img="https://mintcdn.com/private-7c7dfe99-fix-nav-issues/lGskH5qUgz9Vtlav/images/integrations/data-ingestion/clickpipes/mongodb/docdb-select-parameter-group.png?fit=max&auto=format&n=lGskH5qUgz9Vtlav&q=85&s=114c5b4713faaf6c9b8ec5c92ea14ffb" alt="パラメータグループを選択" size="lg" border width="2534" height="1266" data-path="images/integrations/data-ingestion/clickpipes/mongodb/docdb-select-parameter-group.png" />

2. `change_stream_log_retention_duration` を検索し、選択して `259200` (72時間) に編集します。

<Image img="https://mintcdn.com/private-7c7dfe99-fix-nav-issues/lGskH5qUgz9Vtlav/images/integrations/data-ingestion/clickpipes/mongodb/docdb-modify-parameter-group.png?fit=max&auto=format&n=lGskH5qUgz9Vtlav&q=85&s=53fc5f5e9108d1bddbc1eefdd9d58408" alt="パラメータグループを変更" size="lg" border width="2524" height="1332" data-path="images/integrations/data-ingestion/clickpipes/mongodb/docdb-modify-parameter-group.png" />

3. `Apply Changes` をクリックして、変更したパラメータグループをすぐに DocumentDB クラスターへ適用します。パラメータグループのステータスは `applying` に変わり、変更が適用されると `in-sync` になります。

<Image img="https://mintcdn.com/private-7c7dfe99-fix-nav-issues/lGskH5qUgz9Vtlav/images/integrations/data-ingestion/clickpipes/mongodb/docdb-apply-parameter-group.png?fit=max&auto=format&n=lGskH5qUgz9Vtlav&q=85&s=c6998c69e545b99280f21a72af1d8dcd" alt="パラメータグループを適用" size="lg" border width="2520" height="1596" data-path="images/integrations/data-ingestion/clickpipes/mongodb/docdb-apply-parameter-group.png" />

<Image img="https://mintcdn.com/private-7c7dfe99-fix-nav-issues/lGskH5qUgz9Vtlav/images/integrations/data-ingestion/clickpipes/mongodb/docdb-parameter-group-status.png?fit=max&auto=format&n=lGskH5qUgz9Vtlav&q=85&s=150f1d10c5441391446ffe5bbc9e499b" alt="パラメータグループのステータス" size="lg" border width="2538" height="694" data-path="images/integrations/data-ingestion/clickpipes/mongodb/docdb-parameter-group-status.png" />

<div id="update-change-stream-log-retention-via-aws-cli">
  ### AWS CLI で変更ストリームのログ保持期間を更新する
</div>

また、AWS CLI を使って設定することもできます。

現在の変更ストリームのログ保持期間を確認するには、次を実行します。

```shell theme={null}
aws docdb describe-db-cluster-parameters --db-cluster-parameter-group-name <PARAMETER_GROUP_NAME> --query "Parameters[?ParameterName=='change_stream_log_retention_duration'].{Name:ParameterName,Value:ParameterValue}"
```

変更ストリームのログの保持期間を72時間に設定するには:

```shell theme={null}
aws docdb modify-db-cluster-parameter-group --db-cluster-parameter-group-name <PARAMETER_GROUP_NAME> --parameters "ParameterName=change_stream_log_retention_duration,ParameterValue=259200,ApplyMethod=immediate"
```

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

管理者ユーザーとして DocumentDB クラスターに接続し、次のコマンドを実行して MongoDB CDC (変更データキャプチャ)  ClickPipes 用のデータベースユーザーを作成します。

```javascript theme={null}
db.getSiblingDB("admin").createUser({
    user: "clickpipes_user",
    pwd: "some_secure_password",
    roles: ["readAnyDatabase", "clusterMonitor"],
})
```

<Note>
  `clickpipes_user` と `some_secure_password` は、使用するユーザー名とパスワードに必ず置き換えてください。
</Note>

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

これで、[ClickPipe を作成](/ja/integrations/clickpipes/mongodb)して、DocumentDB インスタンスから ClickHouse Cloud へのデータ取り込みを開始できます。
ClickPipe の作成時に必要になるため、DocumentDB クラスターの設定時に使用した接続情報は必ず控えておいてください。
