Following this series of blog posts started by Evgeniy Patlan:
- How to Manually Build Percona Server for MySQL RPM Packages
- How to Build Percona Server for MySQL From Sources
we’ll show you how to build Percona Server for MongoDB for various operating systems¹ using Docker on your local Linux machine/build server. In this very case, we’ll build packages of Percona Server for MongoDB 4.4.9-10 version for Centos 8 and Debian 11 (bullseye).
This can be useful when you need to test your changes to the code for different RPMs/DEBs based platforms and make sure that all works as expected in different environments. In our case, this approach is used for building Percona Server for MongoDB packages/binary tarballs for all supported OSes.
Prepare Build Environment
- Make sure that you have at least 60GB of free disk space
- Create a “build folder” – the folder where all the build actions will be performed, in our case “/mnt/psmdb-44/test“
- Make sure that you have installed the package which provides docker and docker service is up and running
Obtain Build Script of Needed Version²
You need to download the build script of the needed version to the “/mnt/psmdb-44” folder:
1 2 | cd /mnt/psmdb-44/ wget https://raw.githubusercontent.com/percona/percona-server-mongodb/psmdb-4.4.9-10/percona-packaging/scripts/psmdb_builder.sh -O psmdb_builder.sh |
Create Percona Server for MongoDB Source Tarball
- Please note that for the creation of source tarball, we use the oldest supported OS, in this case, it is Centos 7.
1 2 3 4 5 6 7 | docker run -ti -u root -v /mnt/psmdb-44:/mnt/psmdb-44 centos:7 sh -c ' set -o xtrace cd /mnt/psmdb-44 bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --install_deps=1 bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --repo=https://github.com/percona/percona-server-mongodb.git \ --branch=release-4.4.9-10 --psm_ver=4.4.9 --psm_release=10 --mongo_tools_tag=100.4.1 --jemalloc_tag=psmdb-3.2.11-3.1 --get_sources=1 ' |
- Check that source tarball has been created:
1 2 3 4 5 | $ ls -la /mnt/psmdb-44/source_tarball/ total 88292 drwxr-xr-x. 2 root root 4096 Oct 1 10:58 . drwxr-xr-x. 5 root root 4096 Oct 1 10:58 .. -rw-r--r--. 1 root root 90398894 Oct 1 10:58 percona-server-mongodb-4.4.9-10.tar.gz |
Build Percona Server for MongoDB Generic Source RPM/DEB:
Please note that for building generic source RPM/DEB, we still use the oldest supported RPM/DEB-based OS, in this case, Centos 7/ Ubuntu Xenial(16.04).
- Build source RPM:
1 2 3 4 5 6 7 | docker run -ti -u root -v /mnt/psmdb-44:/mnt/psmdb-44 centos:7 sh -c ' set -o xtrace cd /mnt/psmdb-44 bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --install_deps=1 bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --repo=https://github.com/percona/percona-server-mongodb.git \ --branch=release-4.4.9-10 --psm_ver=4.4.9 --psm_release=10 --mongo_tools_tag=100.4.1 --jemalloc_tag=psmdb-3.2.11-3.1 --build_src_rpm=1 ' |
- Build source DEB:
1 2 3 4 5 6 7 | docker run -ti -u root -v /mnt/psmdb-44:/mnt/psmdb-44 ubuntu:xenial sh -c ' set -o xtrace cd /mnt/psmdb-44 bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --install_deps=1 bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --repo=https://github.com/percona/percona-server-mongodb.git \ --branch=release-4.4.9-10 --psm_ver=4.4.9 --psm_release=10 --mongo_tools_tag=100.4.1 --jemalloc_tag=psmdb-3.2.11-3.1 --build_src_deb=1 ' |
- Check that both SRPM and Source DEB have been created:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | $ ls -la /mnt/psmdb-44/srpm/ total 87480 drwxr-xr-x. 2 root root 4096 Oct 1 11:35 . drwxr-xr-x. 6 root root 4096 Oct 1 11:35 .. -rw-r--r--. 1 root root 89570312 Oct 1 11:35 percona-server-mongodb-4.4.9-10.generic.src.rpm $ ls -la /mnt/psmdb-44/source_deb/ total 88312 drwxr-xr-x. 2 root root 4096 Oct 1 11:45 . drwxr-xr-x. 7 root root 4096 Oct 1 11:45 .. -rw-r--r--. 1 root root 10724 Oct 1 11:45 percona-server-mongodb_4.4.9-10.debian.tar.xz -rw-r--r--. 1 root root 1528 Oct 1 11:45 percona-server-mongodb_4.4.9-10.dsc -rw-r--r--. 1 root root 2075 Oct 1 11:45 percona-server-mongodb_4.4.9-10_source.changes -rw-r--r--. 1 root root 90398894 Oct 1 11:45 percona-server-mongodb_4.4.9.orig.tar.gz |
Build Percona Server for MongoDB RPMs/DEBs:
- Build RPMs:
1 2 3 4 5 6 7 | docker run -ti -u root -v /mnt/psmdb-44:/mnt/psmdb-44 centos:8 sh -c ' set -o xtrace cd /mnt/psmdb-44 bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --install_deps=1 bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --repo=https://github.com/percona/percona-server-mongodb.git \ --branch=release-4.4.9-10 --psm_ver=4.4.9 --psm_release=10 --mongo_tools_tag=100.4.1 --jemalloc_tag=psmdb-3.2.11-3.1 --build_rpm=1 ' |
- Build DEBs:
1 2 3 4 5 6 7 | docker run -ti -u root -v /mnt/psmdb-44:/mnt/psmdb-44 debian:bullseye sh -c ' set -o xtrace cd /mnt/psmdb-44 bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --install_deps=1 bash -x ./psmdb_builder.sh --builddir=/mnt/psmdb-44/test --repo=https://github.com/percona/percona-server-mongodb.git \ --branch=release-4.4.9-10 --psm_ver=4.4.9 --psm_release=10 --mongo_tools_tag=100.4.1 --jemalloc_tag=psmdb-3.2.11-3.1 --build_deb=1 ' |
- Check that RPMs for Centos 8 and DEBs for Debian 11 have been created:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | $ ls -la /mnt/psmdb-44/rpm/ total 1538692 drwxr-xr-x. 2 root root 4096 Oct 1 13:19 . drwxr-xr-x. 9 root root 4096 Oct 1 13:19 .. -rw-r--r--. 1 root root 8380 Oct 1 13:19 percona-server-mongodb-4.4.9-10.el8.x86_64.rpm -rw-r--r--. 1 root root 19603132 Oct 1 13:19 percona-server-mongodb-debugsource-4.4.9-10.el8.x86_64.rpm -rw-r--r--. 1 root root 16199100 Oct 1 13:19 percona-server-mongodb-mongos-4.4.9-10.el8.x86_64.rpm -rw-r--r--. 1 root root 382301668 Oct 1 13:19 percona-server-mongodb-mongos-debuginfo-4.4.9-10.el8.x86_64.rpm -rw-r--r--. 1 root root 37794568 Oct 1 13:19 percona-server-mongodb-server-4.4.9-10.el8.x86_64.rpm -rw-r--r--. 1 root root 829718252 Oct 1 13:19 percona-server-mongodb-server-debuginfo-4.4.9-10.el8.x86_64.rpm -rw-r--r--. 1 root root 13310328 Oct 1 13:19 percona-server-mongodb-shell-4.4.9-10.el8.x86_64.rpm -rw-r--r--. 1 root root 218625728 Oct 1 13:19 percona-server-mongodb-shell-debuginfo-4.4.9-10.el8.x86_64.rpm -rw-r--r--. 1 root root 30823056 Oct 1 13:19 percona-server-mongodb-tools-4.4.9-10.el8.x86_64.rpm -rw-r--r--. 1 root root 27196024 Oct 1 13:19 percona-server-mongodb-tools-debuginfo-4.4.9-10.el8.x86_64.rpm $ ls -la /mnt/psmdb-44/deb/ total 2335288 drwxr-xr-x. 2 root root 4096 Oct 1 13:16 . drwxr-xr-x. 9 root root 4096 Oct 1 13:16 .. -rw-r--r--. 1 root root 2301998432 Oct 1 13:16 percona-server-mongodb-dbg_4.4.9-10.bullseye_amd64.deb -rw-r--r--. 1 root root 14872728 Oct 1 13:16 percona-server-mongodb-mongos_4.4.9-10.bullseye_amd64.deb -rw-r--r--. 1 root root 35356944 Oct 1 13:16 percona-server-mongodb-server_4.4.9-10.bullseye_amd64.deb -rw-r--r--. 1 root root 12274928 Oct 1 13:16 percona-server-mongodb-shell_4.4.9-10.bullseye_amd64.deb -rw-r--r--. 1 root root 26784020 Oct 1 13:16 percona-server-mongodb-tools_4.4.9-10.bullseye_amd64.deb -rw-r--r--. 1 root root 18548 Oct 4 13:16 percona-server-mongodb_4.4.9-10.bullseye_amd64.deb |
Now, the packages are ready to be installed for testing/working on Centos 8 and Debian 11.
As you can see from the above, the process of building packages for various operating systems is quite easy and doesn’t require lots of physical/virtual machines. All you need is the build script and Docker.
Also, as you may have noticed, all the build commands are similar to each other except the last passed argument, which defines the action that should be performed. Such an approach allows us to unify the build process and make it scripted so that the last argument can be passed as a parameter to the script. Surely all the rest arguments can and should also be passed as parameters in case you are going to automate the build process.
¹ Supported operating systems(version psmdb-4.4.9-10):
- Centos 7
- Centos 8
- Ubuntu Xenial(16.04)
- Ubuntu Bionic(18.04)
- Ubuntu Focal(20.04)
- Debian Stretch(9)
- Debian Buster(10)
- Debian Bullseye(11)
² In order to build Percona Server for MongoDB of another version, you need to use the build script of the proper version. For example, it is needed to build Percona Server for MongoDB of 4.2.7-7 version:
- Open our repo at https://github.com/percona/percona-server-mongodb
- Select the required version from the tags list and switch to it(the link for this case will be the next: https://github.com/percona/percona-server-mongodb/tree/psmdb-4.2.7-7)
- Download build script: https://raw.githubusercontent.com/percona/percona-server-mongodb/psmdb-4.2.7-7/percona-packaging/scripts/psmdb_builder.sh
- Perform the steps from the post using the build script for version 4.2.7-7
Complete the 2021 Percona Open Source Data Management Software Survey