How to Build Percona Server for MySQL From Sources

Build Percona Server for MySQL From SourcesLately, the number of questions about how to build Percona software has been increased. More and more people try to add their own patches, add some modifications, and build software by themselves. But this raises the question of how to do this in the same way as Percona does, as sometimes the compiler flag can make a drastic impact on the final binary.

First of all, let’s talk about the stages of compiling software.

I would say that at the beginning you need to prepare the build environment, install all the needed dependencies, and so on. For each version, the dependency list would be different. How do you get the correct dependency list? You can get all build requirements from the spec file (on rpm-based systems) or from the control file( on deb-based systems).

The next stage is to get the source code of Percona Server for MySQL. You can do it in different ways:

  • Get source tarball from the website

We publish source tarball for each release we issue and you can easily get it for any released version (this is the link for the latest 8.0.22 version).

  • Download tarball from GitHub

Here is the link:

Once you have prepared the build environment, you need to decide what result you should get: binary tarball, rpm, or deb package.

So everything looks easy. But what is the way we use, internally, to prepare our release packages? As I mentioned earlier, each compiler option can make a significant effect.

Everyone tries to make life easier and automate all tasks. It is great, as automation is one of the keys to success as you can work on other tasks once the release build is in progress. So we have created a builder script that is used for making builds. It can be found in the Percona Server GitHub repo and can be used by anyone to make his own builds.

This script can install all needed dependencies for the build environment, create binary tarballs, source RPMs and debs, RPMs, debs itself, and the binary tarball. So it covers all build cycles. So how do you use it?

The script has various params:

So let’s see how we can make the build process easier:

1. Download build script:

2. Create a build directory where you are going to perform all build actions:

3. Install dependencies(please note root permissions are required):

4. Download source code:

– From Percona repo (it is used by default):

– From your own repo and branch:

5. Prepare src rpm:

Please note if you already have your source tarball, just create a directory named source_tarball in the build directory and put it into it.

6. Prepare source deb:

Please note if you already have your source tarball, just create a directory named source_tarball in the build directory and put it into it.

7. Prepare rpm:

8. Prepare deb:

9. Prepare tarball:

So as you can see, the build procedure becomes easier and you don’t need to think about what dependencies are needed, what cmake params should be used, etc. This build script will make everything for you and will use all build flags (if you didn’t change them in your sources) that we use for release builds.

Share this post

Comments (2)

  • Francisco Miguel Biete Banon Reply

    This a great help, thank you!. Could we make some minor tweaks?
    The repo is quite big, could we clone only the branch we are going to use as base? (git clone -b branch –single-branch)
    Could we add RHEL8 support to the script? It looks like is not contemplating it (not disabling mysql module and pulling jemalloc v5).
    I would also like to see future blog posts about the following steps: how to format code prior contributions, what to do when your contribution is ready, what to expect during reviews…

    March 14, 2021 at 5:03 am
    • Evgeniy Patlan Reply

      Hi Francisco.
      Thanks for your feedback.
      Sure you can clone only branch. And script works well for RHEL8. We prepare packages for RHEL8 using this script and the same approach.

      April 8, 2021 at 3:06 pm

Leave a Reply