MongoDB Community Edition では、検索プロセス mongot をインストールできます。検索プロセスは、 Dockerではイメージとして配置で利用できます。mongot プロセスは、独自の埋め込みまたは自動埋め込みを使用した全文検索とセマンティック検索をサポートしています。
Install MongoDB Search and Vector Search with Docker
注意
実験用の配置でより迅速にオンボードするには、 自己管理型配置の次のチュートリアルを参照してください。
始める前に
mongot を配置する前に、次の手順を完了する必要があります。
DockerとDocker Compose をインストールします。
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:
Download the MongoDB Docker image.
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 をインストール を参照してください。
mongod構成ファイルを作成します。
構成ファイルを作成するには、次のコードを 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
Start your mongod.
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
Create a user for the mongot process on your MongoDB deployment.
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 yourmongotuser.<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.
検索構成オプションを指定します。
YAML構成ファイルを使用して mongot を構成できます。前の手順で指定したユーザー名をsyncSource.replicaSet.username として指定する必要があります。また、前の手順で作成した passwordFile を syncSource.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ネットワークで動作します。
mongot プロセスを開始します。
コミュニティ バイナリで検索を開始するには、mongot は次の手順に従います。
Replace
</path/to/data/mongot>with the path to the local directory for the mounted volume to storemongotdata.</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-communityDockerネットワーク上のコンテナを起動します。
Verify the health of the mongot process.
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 themongotprocess is runningmongotmight not serve queries as it doesn't check the status of the indexes, which must be inReadystate to serve queries.NOT_SERVING, if themongotprocess isn't running
For more information, see Verify Your mongot Connection.
Uninstall MongoDB Search and MongoDB Vector Search with Docker
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.
Drop the mongotUser user.
mongotUser ユーザーを削除するには、次のコマンドを実行します。
use admin db.dropUser("mongotUser")
For details, see db.dropUser().