AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

Install or Uninstall MongoDB Search on Community in a Docker Container

MongoDB Community Edition では、検索プロセス mongot をインストールできます。検索プロセスは、 Dockerではイメージとして配置で利用できます。mongot プロセスは、独自の埋め込みまたは自動埋め込みを使用した全文検索とセマンティック検索をサポートしています。

注意

実験用の配置でより迅速にオンボードするには、 自己管理型配置の次のチュートリアルを参照してください。

mongot を配置する前に、次の手順を完了する必要があります。

  1. DockerとDocker Compose をインストールします。

  2. If you want MongoDB Vector Search to automatically generate embeddings for text data in your collection, create endpoint service API keys. To learn more, see Automated Embedding.

    重要

    自動埋め込みはプレビュー段階です。機能および関連するドキュメントは、プレビュー期間中にいつでも変更される可能性があります。「プレビュー機能」を参照してください。

    If you don't already have the keys, create the endpoint service API keys from the Atlas UI. We recommend that you create two keys, one for generating embeddings at index-time and another for generating embeddings at query-time, from two Atlas projects.

    注意

    埋め込みを生成するためのプロバイダーエンドポイントは、Atlas UIからAPIキーを作成するか、Voyage AIから直接 API キーを作成するかによって異なります。

警告

This procedure provides a simple and insecure default configuration that does not enable access control. The steps create a deployment intended for local experimentation only.

Before exposing these containers and using your setup in production, see the following resources to secure your deployment:

1

mongot Dockerイメージをプルするには、次のコマンドを実行します。

docker pull mongodb/mongodb-community-search:latest

イメージがDockerディスク上にあることを確認するには、次のコマンドを実行します。

docker image ls mongodb/mongodb-community-search
2

データベースと検索コンテナ間のコンテナ間通信用の Docker ネットワークを作成するには、次のコマンドを実行します。

docker network create search-community
3

MongoDB Dockerイメージをダウンロードするには、次のコマンドを実行します。

docker pull mongodb/mongodb-community-server:latest

注意

You must have a minimum of MongoDB 8.2+ to use MongoDB Search with an on-prem deployment. For more information, see MongoDB Search Compatibility.

Dockerを使用してMongoDBをインストールする方法の詳細については、 Dockerを使用してMongoDB Community をインストール を参照してください。

4

mongod に接続するための mongot 用のパスワードファイルを作成します。

例、オペレーティング システムを選択し、<mongot_password> をパスワードに置き換えます。次に、次のコマンドを実行して passwordFile というファイルを作成します。

echo -n "<mongot_password>" > passwordFile
chmod 400 passwordFile

注意

-n フラグは末尾の改行を防止します。

5

構成ファイルを作成するには、次のコードを mongod.conf または希望する場所に保存します。

# MongoDB Configuration File
# Network configuration
net:
port: 27017
bindIpAll: true # Equivalent to --bind_ip_all
# Replica set configuration
replication:
replSetName: rs0
# Search configuration parameters
setParameter:
# Server parameters to advise mongod of mongot availability for search index management and querying
searchIndexManagementHostAndPort: mongot-community.search-community:27028
mongotHost: mongot-community.search-community:27028
skipAuthenticationToSearchIndexManagementServer: false
useGrpcForSearch: true
searchTLSMode: disabled
6

mongod を起動するには次の手順に従います。

  • Replace <your_admin_username> with the username you want to specify for your admin user.

  • Replace <your_admin_password> with the password you want to specify for your admin user.

  • Replace </path/to/data/db> with the path to the local directory for the mounted volume.

  • Replace </path/to/mongod.conf> with the path to the configuration file you created above.

docker run --rm \
--name mongod \
-v </path/to/mongod.conf>:/etc/mongod.conf:ro \
-v </path/to/data/db>:/data/db \
-p 27017:27017 \
--network search-community \
mongodb/mongodb-community-server:latest \
--config /etc/mongod.conf \
--replSetMember=mongod.search-community:27017
7

次のコマンドを実行して、ポート 27017 で起動した mongodインスタンスに接続し、<your_admin_username><your_admin_password> を管理者ユーザー用に作成したユーザー名とパスワードに置き換えます。

docker exec -it mongod mongosh --port 27017
8

mongot must be able to connect to your MongoDB deployment through a user with the searchCoordinator role.

次のコマンドを実行して、adminデータベースに接続します。

use admin

searchCoordinator ロールを持つユーザーを作成するには:

  • Replace <your-mongot-username> with a username for your mongot user.

  • <your-mongot-password> を、ステップ 5 の passwordFile で指定したパスワードに置き換えます。

  • 次のコマンドを実行します:

db.createUser(
{
user: "<mongot_username>",
pwd: "<mongot_password>",
roles: [ "searchCoordinator" ]
}
)

For more information on creating users, see Create a User on Self-Managed Deployments.

9

YAML構成ファイルを使用して mongot を構成できます。前の手順で指定したユーザー名をsyncSource.replicaSet.username として指定する必要があります。また、前の手順で作成した passwordFilesyncSource.replicaSet.passwordFile として指定する必要があります。

For more information on mongot configuration options, see mongot Options.

例では、以下に示すように 設定をローカル構成に合わせて調整できます。

# mongot.conf
syncSource:
replicaSet:
hostAndPort: "mongod.search-community:27017"
scramAuth:
username: "mongotUser"
passwordFile: "/passwordFile"
authSource: "admin"
tls:
enabled: false
replicationReader:
readPreference: "secondaryPreferred"
storage:
dataPath: "/data/mongot"
server:
grpc:
address: "mongot-community.search-community:27028"
tls:
mode: "disabled"
metrics:
enabled: true
address: "mongot-community.search-community:9946"
healthCheck:
address: "mongot-community.search-community:8080"
logging:
verbosity: INFO

ファイルをmongot.config またはご希望のファイルロケーションに保存します。

どちらのコンテナも同じ search-community Dockerネットワークで動作します。

10

コミュニティ バイナリで検索を開始するには、mongot は次の手順に従います。

  • Replace </path/to/data/mongot> with the path to the local directory for the mounted volume to store mongot data.

  • </path/to/mongot.conf> を、前のステップで作成した mongot構成ファイルへのパスに置き換えます。

  • </path/to/passwordFile> を作成したパスワードファイルへのパスに置き換えます。

docker run --rm \
--name mongot-community \
-v </path/to/data/mongot>:/data/mongot \
-v </path/to/mongot.conf>:/mongot-community/config.default.yml \
-v </path/to/passwordFile>:/passwordFile:ro \
--network search-community \
-p 8080:8080 \
-p 9946:9946 \
mongodb/mongodb-community-search:latest

このコマンド:

  • ボリュームをマウントします。

  • ローカル ボリュームから構成ファイルをマウントします。

  • ポート範囲を指定します。

  • メトリクス ポートを公開します。

  • mongot-community という名前のコンテナを使用して search-community Dockerネットワーク上のコンテナを起動します。

11

To verify, send a request by using a HTTP client or curl to the /health endpoint. For example, send a curl request similar to the following sample request:

curl localhost:8080/health

エンドポイントは、応答として次のいずれかを返します。

  • SERVING, if the mongot process is running

    mongot might not serve queries as it doesn't check the status of the indexes, which must be in Ready state to serve queries.

  • NOT_SERVING, if the mongot process isn't running

For more information, see Verify Your mongot Connection.

To completely remove MongoDB Search and MongoDB Vector Search from a system, remove the container image, the configuration files, and any data or log directories. The following section guides you through the necessary steps.

1

mongotUser ユーザーを削除するには、次のコマンドを実行します。

use admin
db.dropUser("mongotUser")

For details, see db.dropUser().

2

mongot プロセスを停止するには、 Dockerで実行中のコンテナイメージを停止します。

3

mongotmongod 構成ファイルを削除するには、構成ファイルへのフルパスを使用して次のコマンドを実行します。

rm /path/to/config.default.yml
rm /path/to/mongod.conf
4

To remove the password file, run the following commands using the full path to the password file:

rm /path/to/passwordFile
5

mongot データを保存しているデータディレクトリを削除するには、mongotデータディレクトリへのフルパスを使用して次のコマンドを実行します。

rm /path/to/mongot/data