> For the complete documentation index, see [llms.txt](https://docs.percona.com/percona-search-for-mongodb/llms.txt).

# Install mongot

Before deploying Percona Search for MongoDB, ensure that you have:

- Percona Server for MongoDB 8.3 or later, installed as an initiated replica set.
- Administrative privileges to install and configure `mongot`.
- The `mongot` binary installed on the host.
- Write access to the search data and log directories for the user that runs `mongot`.
- Network connectivity from the `mongot` host to the replica set.

Note

The examples in this section use a single-node test environment with `mongod` listening on port **27017** and `mongot` listening on port **27028**. Replace the host names, ports, paths, and credentials with values that are applicable for your deployment.

Additional requirements depend on the installation method:

- **Tarballs** - An initiated replica set with keyfile access control or sharded deployment. `mongosh` installed on the host.
- **Docker** - Docker engine with Compose v2 installed on the host.

For more information, see [Vector Search compatibility](https://docs.percona.com/percona-search-for-mongodb/vector-search-compatibility.md).

For SBOM locations and scanning instructions, see [Software Bill of Materials](https://docs.percona.com/percona-search-for-mongodb/sbom.md).

## Procedure

**Tarballs**

### Install `mongot` from tarballs

Follow these steps to install `mongot` from a tarball:

1. Download the `mongot` tarball.

   **ARM64**

   Download the [ARM64 tarball](https://downloads.percona.com/downloads/percona-search-mongodb/percona-search-mongodb-1.70.3/binary/tarball/percona-search-mongodb-1.70.3-linux_aarch64.tar.gz) .

   **AMD64 (x86_64)**

   Download the [AMD64 tarball](https://downloads.percona.com/downloads/percona-search-mongodb/percona-search-mongodb-1.70.3/binary/tarball/percona-search-mongodb-1.70.3-linux_x86_64.tar.gz) .

1. Extract the tarball.

   **ARM64**

   ```sh
   tar -zxvf percona-search-mongodb-1.70.3-linux_aarch64.tar.gz
   ```

   **AMD64 (x86_64)**

   ```sh
   tar -zxvf percona-search-mongodb-1.70.3-linux_x86_64.tar.gz
   ```

   The extracted archive contains the `mongot` binary, the sample configuration file, the `mongot` launcher script, and the Percona Search for MongoDB license files.

1. Configure `mongod` to communicate with `mongot`.

   Configure the following `mongod` startup parameters.

   | Parameter                                         | Description                                                                                                                                   |
   | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
   | `searchIndexManagementHostAndPort`                | Specifies the host and port of the `mongot` service used for search index management operations.                                              |
   | `mongotHost`                                      | Specifies the host and port of the `mongot` service used to process search queries. This value must match `searchIndexManagementHostAndPort`. |
   | `skipAuthenticationToSearchIndexManagementServer` | Enables or disables authentication between `mongod` and `mongot` for search index management operations.                                      |
   | `useGrpcForSearch`                                | Enables or disables gRPC communication between `mongod` and `mongot`.                                                                         |

   Example: `mongod` configuration

   ```yaml
   setParameter:
     searchIndexManagementHostAndPort: localhost:27028
     mongotHost: localhost:27028
     skipAuthenticationToSearchIndexManagementServer: false
     useGrpcForSearch: true
   ```

   These are startup parameters. Restart `mongod` for the changes to take effect.

   ```sh
   sudo systemctl restart mongod
   ```

1. Create a user for the `mongot` process.

   `mongot` connects to your Percona Server for MongoDB deployment by using a user with the `searchCoordinator` role.

   1. Connect to `mongosh` as an administrator.

      ```sh
      mongosh --port 27017 -u <admin-username> -p <admin-password>
      ```

   1. Switch to the `admin` database.

      ```javascript
      use admin
      ```

   1. Create the `mongot` user.

      Replace:

      - `<mongot-username>` with the username for the `mongot` user.
      - `<mongot-password>` with the password that you save in the password file in the next step.

      Then run:

      ```javascript
      db.createUser({
        user: "<mongot-username>",
        pwd: "<mongot-password>",
        roles: ["searchCoordinator"]
      })
      ```

1. Prepare the required directories.

   ```sh
   sudo mkdir -p /var/lib/mongot /etc/mongot/secrets /opt/mongot
   sudo chown -R mongod:mongod /var/lib/mongot /etc/mongot /opt/mongot
   sudo chmod 750 /etc/mongot /etc/mongot/secrets
   ```

1. Create the password file.

   ```sh
   sudo mkdir -p /etc/mongot
   echo -n "<mongot-password>" | sudo tee /etc/mongot/secrets/passwordFile > /dev/null
   sudo chmod 600 /etc/mongot/secrets/passwordFile
   sudo chown mongod:mongod /etc/mongot/secrets/passwordFile
   ```

1. Create the `mongot` configuration file.

   The tarball includes a sample configuration file named `config.default.yml`. Copy it to `mongot.yml` and modify that file as needed.

   Example: `mongot.yml`

   ```yaml
   syncSource:
     replicaSet:
       hostAndPort: "localhost:27017"
       scramAuth:
         username: mongotUser
         passwordFile: "/etc/mongot/secrets/passwordFile"
         authSource: admin
         tls:
           enabled: false
   storage:
     dataPath: "/var/lib/mongot"
   server:
     grpc:
       address: "localhost:27028"
       tls:
         mode: "disabled"
   metrics:
     enabled: true
     address: "localhost:9946"
   healthCheck:
     address: "localhost:8080"
   logging:
     verbosity: INFO
   ```

   Note

   The user running `mongot` must have write access to the directory specified by `storage.dataPath`.

   For the complete list of configuration options, see the upstream [mongot configuration options](https://www.mongodb.com/docs/manual/reference/configuration-options/#std-label-mongot-configuration-options) documentation.

1. Copy the extracted files to the installation directory.

   ```sh
   sudo cp -a percona-search-mongodb/* /opt/mongot/
   sudo chown -R mongod:mongod /opt/mongot
   ```

1. Create the `systemd` service.

   Create the following file:

   ```text
   /etc/systemd/system/mongot.service
   ```

   ```ini
   [Unit]
   Description=MongoDB Search (mongot)
   Documentation=https://www.mongodb.com/docs/manual/reference/configuration-options/#std-label-mongot-configuration-options
   After=network.target

   [Service]
   User=mongod
   Group=mongod
   Type=simple
   ExecStart=/opt/mongot/mongot --config /etc/mongot/config.yml
   Restart=on-failure
   RestartSec=5
   LimitNOFILE=64000
   TimeoutStartSec=30
   TimeoutStopSec=30
   SuccessExitStatus=143

   [Install]
   WantedBy=multi-user.target
   ```

1. Set the required file permissions and SELinux contexts.

   ```sh
   sudo chown mongod:mongod /etc/mongot/config.yml
   sudo chmod 600 /etc/mongot/config.yml
   sudo restorecon -Rv /opt/mongot
   ```

1. Enable and start `mongot`.

   ```sh
   sudo systemctl daemon-reload
   sudo systemctl enable mongot
   sudo systemctl start mongot
   ```

1. Verify that `mongot` is running.

   ```sh
   curl localhost:8080/health
   ```

   Example output:

   ```json
   {"status":"SERVING"}
   ```

**Docker**

### Install Vector Search with Docker

Important

- `mongot` synchronizes data from `mongod` and requires a PSMDB replica set. Standalone deployments are not supported.

Follow these steps to install and configure `mongot` using Docker:

1. Pull the `mongod` Docker image.

   ```bash
   docker pull percona/percona-server-mongodb:<TAG>
   ```

1. Pull the `mongot` Docker image.

   ```bash
   docker pull percona/percona-search-mongodb:<TAG>
   ```

1. Verify the downloaded images.

   ```bash
   docker image ls | grep -E 'percona-search-mongodb|percona-server-mongodb'
   ```

1. Create a Docker network.

   The `mongod` and `mongot` containers must run on the same Docker network so that they can communicate using their container names. Use the same `<network-name>` value when you start both containers.

   ```bash
   docker network create <network-name>
   ```

   Replace `<network-name>` with a name for the network, for example `psmdb-search`.

1. Create the password file for the `mongot` user.

   `mongot` reads the password for its database user from a file. Create the file and restrict its permissions. The `-n` option prevents a trailing newline from being written to the file, which would otherwise become part of the password:

   ```bash
   echo -n "<mongot-password>" > mongot-password.txt
   chmod 400 mongot-password.txt
   ```

   Replace `<mongot-password>` with a password of your choice. You use the same password when you create the `mongot` database user in step 9.

1. Create the `mongod` configuration file.

   Save the following configuration as `mongod.conf`.

   ```yaml
   net:
     port: 27017
     bindIpAll: true

   replication:
     replSetName: rs0

   setParameter:
     searchIndexManagementHostAndPort: mongot:27028
     mongotHost: mongot:27028
     skipAuthenticationToSearchIndexManagementServer: false
     useGrpcForSearch: true
     searchTLSMode: disabled
   ```

   The `mongot:27028` address consists of the Docker container name and the gRPC port exposed by the `mongot` container. Specify the same value for both `searchIndexManagementHostAndPort` and `mongotHost`.

1. Start `mongod`.

   Replace:

   - `<path-to-data-db>` with the path to the MongoDB data directory.
   - `<path-to-mongod-conf>` with the path to the `mongod.conf` file.
   - `<network-name>` with the Docker network created in step 4.

   ```bash
   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 <network-name> \
     percona/percona-server-mongodb:<TAG> \
     --config /etc/mongod.conf
   ```

   The container name `mongod` becomes the hostname used by `mongot` to connect to the database. If you change the container name, update the `syncSource.replicaSet.hostAndPort` value in the `mongot` configuration file.

   To view the server logs:

   ```bash
   docker logs -f mongod
   ```

1. Initiate the replica set.

   Connect to the running container:

   ```bash
   docker exec -it mongod mongosh --port 27017
   ```

   Initialize the replica set:

   ```javascript
   rs.initiate()
   ```

   Wait until the node becomes the primary replica set member before continuing.

1. Create the `mongot` user.

   `mongot` requires a database user with the `searchCoordinator` role.

   The `searchCoordinator` role grants `readAnyDatabase` privileges and write access to the internal `__mdb_internal_search` database, which `mongot` uses to store search index metadata.

   1. Switch to the `admin` database.

      ```javascript
      use admin
      ```

   1. Create the user.

      Replace:

      - `<mongot-username>` with the username for the `mongot` user.
      - `<mongot-password>` with the password stored in `mongot-password.txt`.

      ```javascript
      db.createUser({
        user: "<mongot-username>",
        pwd: "<mongot-password>",
        roles: ["searchCoordinator"]
      })
      ```

1. Create the `mongot` configuration file.

   Important

   Set `syncSource.replicaSet.scramAuth.username` to the user created in the previous step, and `syncSource.replicaSet.scramAuth.passwordFile` to the password file created in step 5.

   For more information about the available configuration options, see the upstream documentation for [mongot configuration options](https://www.mongodb.com/docs/manual/reference/configuration-options/#std-label-mongot-configuration-options) .

   Example: `mongot.conf`

   ```yaml
   syncSource:
     replicaSet:
       hostAndPort: "mongod:27017"
       scramAuth:
         username: "mongotUser"
         passwordFile: "/passwordFile"
         authSource: "admin"
         tls:
           enabled: false
     replicationReader:
       readPreference: "secondaryPreferred"

   storage:
     dataPath: "/data/mongot"

   server:
     grpc:
       address: "mongot:27028"
       tls:
         mode: "disabled"

   metrics:
     enabled: true
     address: "mongot:9946"

   healthCheck:
     address: "mongot:8080"

   logging:
     verbosity: INFO
   ```

   Save the configuration file as `mongot.conf`.

   The `mongod` and `mongot` containers must run on the same Docker network.

   Ensure that:

   - `scramAuth.username` matches the user created in step 9.
   - `passwordFile` points to the password file created in step 5.

   The `mongot` container reads its configuration from `/mongot-community/config.default.yml`, which is mounted in the next step.

1. Start the `mongot` container.

   Replace:

   - `<path-to-data-mongot>` with the directory used to store search index data.
   - `<path-to-mongot-conf>` with the path to the `mongot.conf` file.
   - `<path-to-password-file>` with the path to the password file.
   - `<network-name>` with the Docker network created in step 4.

   ```bash
   docker run --rm \
     --name mongot \
     -v <path-to-data-mongot>:/data/mongot \
     -v <path-to-mongot-conf>:/mongot-community/config.default.yml:ro \
     -v <path-to-password-file>:/passwordFile:ro \
     --network <network-name> \
     percona/percona-search-mongodb:<TAG>
   ```

   To view the `mongot` logs:

   ```bash
   docker logs -f mongot
   ```

1. Verify the health of the `mongot` process.

   Send a request to the readiness endpoint.

   ```bash
   docker exec mongot -- curl localhost:8080/health
   ```

   If `mongot` starts successfully, the endpoint returns:

   ```text
   SERVING
   ```

**RPM packages**

### Install `mongot` on RHEL and derivatives

Follow these steps to install `mongot` using the Percona RPM repository:

1. Install the Percona repository.

   ```sh
   sudo yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
   ```

1. Enable the Percona Search for MongoDB repository.

   ```sh
   sudo percona-release enable ps4m release
   ```

1. Install `mongot`.

   ```sh
   sudo yum install percona-search-mongodb
   ```

After installing the package, continue from **step 3 onwards** in the **Tarballs** tab to configure `mongod` and `mongot`.

**DEB packages**

### Install `mongot` on Debian and Ubuntu

Follow these steps to install `mongot` using the Percona APT repository:

1. Install the Percona repository.

   ```sh
   wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb

   sudo apt install ./percona-release_latest.$(lsb_release -sc)_all.deb
   ```

1. Enable the Percona Search for MongoDB repository.

   ```sh
   sudo percona-release enable ps4m release
   ```

1. Install `mongot`.

   ```sh
   sudo apt install percona-search-mongodb
   ```

After installing the package, continue from **step 3 onwards** in the **Tarballs** tab to configure `mongod` and `mongot`.
