2023-09-22 20:53:26 +00:00
|
|
|
# Building MongoDB
|
2009-11-19 10:49:34 -05:00
|
|
|
|
2020-05-06 09:54:29 -04:00
|
|
|
Please note that prebuilt binaries are available on
|
|
|
|
|
[mongodb.org](http://www.mongodb.org/downloads) and may be the easiest
|
|
|
|
|
way to get started, rather than building from source.
|
|
|
|
|
|
2014-05-09 14:54:09 -04:00
|
|
|
To build MongoDB, you will need:
|
|
|
|
|
|
2024-04-03 16:12:53 -07:00
|
|
|
- A modern C++ compiler capable of compiling C++20. One of the following is required:
|
2025-08-26 08:49:19 -05:00
|
|
|
- GCC 14.2
|
|
|
|
|
- Clang 19.1
|
|
|
|
|
- Apple XCode 16.4
|
|
|
|
|
- Visual Studio 2022 version 17.0
|
2024-04-03 16:12:53 -07:00
|
|
|
- On Linux and macOS, the libcurl library and header is required. MacOS includes libcurl.
|
|
|
|
|
- Fedora/RHEL - `dnf install libcurl-devel`
|
|
|
|
|
- Ubuntu/Debian - `libcurl-dev` is provided by three packages. Install one of them:
|
|
|
|
|
- `libcurl4-openssl-dev`
|
|
|
|
|
- `libcurl4-nss-dev`
|
|
|
|
|
- `libcurl4-gnutls-dev`
|
|
|
|
|
- On Ubuntu, the lzma library is required. Install `liblzma-dev`
|
|
|
|
|
- On Amazon Linux, the xz-devel library is required. `yum install xz-devel`
|
2025-03-31 11:05:00 -05:00
|
|
|
- Python 3.10
|
2024-04-03 16:12:53 -07:00
|
|
|
- About 13 GB of free disk space for the core binaries (`mongod`,
|
2025-10-31 15:26:52 -05:00
|
|
|
`mongos`, and `mongo`).
|
2017-05-16 11:12:05 -04:00
|
|
|
|
2025-08-26 08:49:19 -05:00
|
|
|
If using a newer version of a C++ compiler than listed above, it may work. However the versions listed above have been verified to work.
|
|
|
|
|
|
2020-05-06 09:54:29 -04:00
|
|
|
MongoDB supports the following architectures: arm64, ppc64le, s390x,
|
2024-02-27 11:47:14 -08:00
|
|
|
and x86-64. More detailed platform instructions can be found below.
|
2014-05-09 14:54:09 -04:00
|
|
|
|
2024-05-30 17:29:35 -07:00
|
|
|
## Quick (re)Start
|
|
|
|
|
|
2025-03-31 11:05:00 -05:00
|
|
|
### Linux
|
2024-06-14 18:30:15 -07:00
|
|
|
|
2024-05-30 17:29:35 -07:00
|
|
|
```bash
|
2025-03-31 11:05:00 -05:00
|
|
|
python buildscripts/install_bazel.py
|
|
|
|
|
export PATH=~/.local/bin:$PATH
|
|
|
|
|
bazel build install-dist-test
|
2025-05-20 12:49:11 -05:00
|
|
|
bazel-bin/install/bin/mongod --version
|
2024-05-30 17:29:35 -07:00
|
|
|
```
|
2014-11-19 18:39:54 -05:00
|
|
|
|
2025-03-31 11:05:00 -05:00
|
|
|
## Bazel
|
2012-02-21 10:04:37 -05:00
|
|
|
|
2020-05-06 09:54:29 -04:00
|
|
|
If you only want to build the database server `mongod`:
|
|
|
|
|
|
2025-03-31 11:05:00 -05:00
|
|
|
$ bazel build install-mongod
|
2009-11-19 10:49:34 -05:00
|
|
|
|
2024-02-27 11:47:14 -08:00
|
|
|
**_Note_**: For C++ compilers that are newer than the supported
|
2020-05-06 09:54:29 -04:00
|
|
|
version, the compiler may issue new warnings that cause MongoDB to
|
|
|
|
|
fail to build since the build system treats compiler warnings as
|
|
|
|
|
errors. To ignore the warnings, pass the switch
|
2025-03-31 11:05:00 -05:00
|
|
|
`--disable_warnings_as_errors=True` to the bazel command.
|
2022-09-09 21:25:29 +00:00
|
|
|
|
2025-03-31 11:05:00 -05:00
|
|
|
$ bazel build install-mongod --disable_warnings_as_errors=True
|
2018-07-24 16:00:02 -04:00
|
|
|
|
2020-05-06 09:54:29 -04:00
|
|
|
If you want to build absolutely everything (`mongod`, `mongo`, unit
|
|
|
|
|
tests, etc):
|
2009-11-19 10:49:34 -05:00
|
|
|
|
2025-03-31 11:05:00 -05:00
|
|
|
$ bazel build --build_tag_filters=mongo_binary //src/mongo/...
|
2009-11-19 10:49:34 -05:00
|
|
|
|
2025-03-31 11:05:00 -05:00
|
|
|
## Bazel Targets
|
2009-11-19 11:20:03 -05:00
|
|
|
|
2025-03-31 11:05:00 -05:00
|
|
|
The following targets can be named on the bazel command line to build and
|
2022-06-15 17:47:34 +00:00
|
|
|
install a subset of components:
|
2020-05-06 09:54:29 -04:00
|
|
|
|
2024-04-03 16:12:53 -07:00
|
|
|
- `install-mongod`
|
|
|
|
|
- `install-mongos`
|
|
|
|
|
- `install-core` (includes _only_ `mongod` and `mongos`)
|
2025-03-31 11:05:00 -05:00
|
|
|
- `install-dist` (includes all server components)
|
2024-04-03 16:12:53 -07:00
|
|
|
- `install-devcore` (includes `mongod`, `mongos`, and `jstestshell` (formerly `mongo` shell))
|
2022-06-15 17:47:34 +00:00
|
|
|
|
2025-03-31 11:05:00 -05:00
|
|
|
**_NOTE_**: The `install-core` and `install-dist` targets are _not_
|
2022-06-15 17:47:34 +00:00
|
|
|
guaranteed to be identical. The `install-core` target will only ever include a
|
2025-03-31 11:05:00 -05:00
|
|
|
minimal set of "core" server components, while `install-dist` is intended
|
2022-06-15 17:47:34 +00:00
|
|
|
for a functional end-user installation. If you are testing, you should use the
|
2025-03-31 11:05:00 -05:00
|
|
|
`install-devcore` or `install-dist` targets instead.
|
2020-05-06 09:54:29 -04:00
|
|
|
|
2023-09-22 20:53:26 +00:00
|
|
|
## Where to find Binaries
|
2020-05-06 09:54:29 -04:00
|
|
|
|
2025-03-31 11:05:00 -05:00
|
|
|
The build system will produce an installation tree into `bazel-bin/install`, as well
|
|
|
|
|
individual install target trees like `bazel-bin/<install-target>`.
|
2019-02-02 14:50:52 -05:00
|
|
|
|
2023-09-22 20:53:26 +00:00
|
|
|
## Windows
|
2009-11-19 10:49:34 -05:00
|
|
|
|
2012-02-21 10:04:37 -05:00
|
|
|
Build requirements:
|
2017-05-16 11:12:05 -04:00
|
|
|
|
2024-04-03 16:12:53 -07:00
|
|
|
- Visual Studio 2022 version 17.0 or newer
|
|
|
|
|
- Python 3.10
|
2009-11-19 10:49:34 -05:00
|
|
|
|
2024-02-27 11:47:14 -08:00
|
|
|
Or download a prebuilt binary for Windows at www.mongodb.org.
|
2020-05-06 09:54:29 -04:00
|
|
|
|
2023-09-22 20:53:26 +00:00
|
|
|
## Debian/Ubuntu
|
2010-07-13 17:45:22 -04:00
|
|
|
|
2014-05-09 14:54:09 -04:00
|
|
|
To install dependencies on Debian or Ubuntu systems:
|
2012-02-21 10:05:00 -05:00
|
|
|
|
2019-06-14 17:44:15 +01:00
|
|
|
# apt-get install build-essential
|
2012-02-21 10:05:00 -05:00
|
|
|
|
2023-09-22 20:53:26 +00:00
|
|
|
## OS X
|
2010-07-13 17:45:22 -04:00
|
|
|
|
2025-06-09 10:39:12 -04:00
|
|
|
Install Xcode 16.4 or newer. Make sure macOS 15.5 platform
|
|
|
|
|
is installed.
|
|
|
|
|
|
|
|
|
|
Install llvm and lld, version 19 from brew:
|
|
|
|
|
brew install llvm@19 lld@19
|