Skip to content

Rate this page
☆ ☆ ☆ ☆ ☆
Thanks for your feedback
Thank you! The feedback has been submitted.

Get free database assistance or contact our experts for personalized support.

Build from source code

Build Percona Server for MongoDB 9.0 from the v9.0 source branch. For a reproducible release build, select the corresponding release tag from the source repository.

Build options

Manual build

The 9.0 source tree uses Bazel. Use the 9.0 build requirements for compiler, Python, and operating system dependencies.

Build steps

  1. Clone the 9.0 source tree:

    git clone --branch v9.0 https://github.com/percona/percona-server-mongodb.git
    cd percona-server-mongodb
    
  2. (Recommended) Create and activate a Python virtual environment:

    python3 -m venv .venv
    source .venv/bin/activate
    

    You can skip the virtual environment in a temporary container or other temporary build environment. In that case, make sure python3 points to Python 3.13 or later.

  3. Install the Python dependencies:

    buildscripts/poetry_sync.sh
    

    If you skipped the virtual environment, run buildscripts/poetry_sync.sh -f in the temporary environment.

  4. Install Bazel with the repository helper:

    python3 buildscripts/install_bazel.py
    export PATH="$HOME/.local/bin:$PATH"
    
  5. Build the server binaries:

    bazel build --config=psmdb_opt_release install-mongod install-mongos
    
  6. Check the built server version:

    bazel-bin/install-mongod/bin/mongod --version
    

    The version comes from the Git metadata of your checkout. A release tag gives a release version, and a branch build shows a development version string.

The build creates target-specific installation directories under bazel-bin. For other targets, see Bazel targets.

Use the build script

The 9.0 packaging script creates source archives, binary tarballs, and DEB or RPM packages. Use a disposable build environment for the target operating system. The dependency installation step requires root access.

The examples use version 9.0.8-1 as the package version. The v9.0 branch selects branch sources, rather than an immutable release snapshot. For release builds, use the matching release tag for both the script and --branch.

Prepare the build environment

  1. Create separate script and build directories:

    mkdir -p /tmp/psmdb/scripts /tmp/psmdb/build
    cd /tmp/psmdb/scripts
    
  2. Download the script for the source branch:

    curl -fL https://raw.githubusercontent.com/percona/percona-server-mongodb/v9.0/percona-packaging/scripts/psmdb_builder.sh -o psmdb_builder.sh
    
  3. Install dependencies in the build environment:

    sudo bash ./psmdb_builder.sh --builddir=/tmp/psmdb/build --install_deps=1
    

Tarballs

Build a binary tarball from the 9.0 source branch:

bash ./psmdb_builder.sh \
  --builddir=/tmp/psmdb/build \
  --repo=https://github.com/percona/percona-server-mongodb.git \
  --branch=v9.0 --psm_ver=9.0.8 --psm_release=1 \
  --get_sources=1 --build_tarball=1

Find the generated tarballs in /tmp/psmdb/build/tarball/.

Packages

Build packages in an environment that matches the target package format:

bash ./psmdb_builder.sh \
  --builddir=/tmp/psmdb/build \
  --repo=https://github.com/percona/percona-server-mongodb.git \
  --branch=v9.0 --psm_ver=9.0.8 --psm_release=1 \
  --get_sources=1 --build_src_deb=1 --build_deb=1

Find source packages in /tmp/psmdb/build/source_deb/ and binary packages in /tmp/psmdb/build/deb/.

bash ./psmdb_builder.sh \
  --builddir=/tmp/psmdb/build \
  --repo=https://github.com/percona/percona-server-mongodb.git \
  --branch=v9.0 --psm_ver=9.0.8 --psm_release=1 \
  --get_sources=1 --build_src_rpm=1 --build_rpm=1

Find source packages in /tmp/psmdb/build/srpm/ and binary packages in /tmp/psmdb/build/rpm/.

Next steps

Connect to MongoDB