MySQL Blog Archive
For the latest blogs go to blogs.oracle.com/mysql
Build MySQL 8 from the source rpm in OL7

This is the second post of a series on how to build RPMs for MySQL 8 (8.0 and 8.1) on Oracle Linux (and compatible).

The first post was dedicated on Oracle Linux 9 (OL9/EL9) and this one is about Oracle Linux 7.

To be able to build successfully MySQL 8 on OL7, I needed to solicite the MySQL Release Engineer team (thank you for the help!).

As usual, my build machine is a compute instance in OCI: VM.Standard.E4.Flex with 8 OCPUs and 128GB or ram with Oracle Linux 7.9 and a block volume of 50GB attached an mounted in /home/opc/rpmbuild:

OL7 Compute Instance

Getting the source RPM

To get the source RPM, you need first to install the MySQL Community’s repo:

$ sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-9.noarch.rpm

Depending on which version you want to compile, you can use one of the following commands:

For latest 8.0:

$ yumdownloader --source mysql-community-server

For latest Innovation Release (8.1 at the moment):

$ yumdownloader --source mysql-community-server --enablerepo=mysql-innovation-community

Now we have both files we can use:

$ ls -lh *src.rpm
-rw-rw-r--. 1 opc opc 544M Jun 25 03:05 mysql-community-8.0.34-1.el7.src.rpm
-rw-rw-r--. 1 opc opc 544M Jun 23 08:23 mysql-community-8.1.0-1.el7.src.rpm

Removing Problematic Packages

I learned from the MySQL Release Engineering Team, that ksplice packages will break any rpm build.

This mean that on my build machine, I will have to remove all ksplice packages.

$ rpm -qa | grep ksplice
ksplice-release-el7-1.0-7.el7.x86_64
ksplice-core0-1.0.59-1.el7.x86_64
ksplice-1.0.59-1.el7.x86_64
ksplice-tools-1.0.59-1.el7.x86_6

This is not much… let’s do it now:

$ sudo yum remove -y ksplice ksplice-core0 ksplice-release-el7 ksplice-tools

Dependencies

To build RPMs, we need to start by installing the following package:

$ sudo yum install rpm-build

Of course MySQL also need several packages including libraries and compiler required to compile it.

To know which one we need, we can already try to rebuild the rpm:

$ rpmbuild --rebuild mysql-community-8.1.0-1.el7.src.rpm
[...]
error: Failed build dependencies:
    cmake3 >= 3.6.1 is needed by mysql-community-8.1.0-1.el7.x86_64
    devtoolset-11-gcc is needed by mysql-community-8.1.0-1.el7.x86_64
    devtoolset-11-gcc-c++ is needed by mysql-community-8.1.0-1.el7.x86_64
    devtoolset-11-binutils is needed by mysql-community-8.1.0-1.el7.x86_64
    bison >= 2.1 is needed by mysql-community-8.1.0-1.el7.x86_64
    perl(Env) is needed by mysql-community-8.1.0-1.el7.x86_64
    perl(Data::Dumper) is needed by mysql-community-8.1.0-1.el7.x86_64
    perl(JSON) is needed by mysql-community-8.1.0-1.el7.x86_64
    libaio-devel is needed by mysql-community-8.1.0-1.el7.x86_64
    ncurses-devel is needed by mysql-community-8.1.0-1.el7.x86_64
    numactl-devel is needed by mysql-community-8.1.0-1.el7.x86_64
    openssl-devel is needed by mysql-community-8.1.0-1.el7.x86_64
    zlib-devel is needed by mysql-community-8.1.0-1.el7.x86_64
    cyrus-sasl-devel is needed by mysql-community-8.1.0-1.el7.x86_64
    openldap-devel is needed by mysql-community-8.1.0-1.el7.x86_64

So let’s start by installing those packages:

$ sudo yum install -y cmake devtoolset-11-gcc devtoolset-11-gcc-c++ \
                      devtoolset-11-binutils bison perl perl-Data-Dumper \
                      perl-JSON libaio-devel ncurses-devel numactl-devel \
                      openssl-devel zlib-devel cyrus-sasl-devel openldap-devel \
                      perl-Env
$ sudo yum install -y cmake3 --enablerepo=ol7_developer_EPEL

Then they are other packages that are required but not listed (we also need to install the system gcc-c++ to build MySQL 5.6 for the shared compat libraries):

$ sudo yum install -y systemd-devel curl-devel gcc-c++

Building RPMs

Now we are ready to build all the rpms from the source package.

This is the command to rebuild everything for the version you want:

$ rpmbuild --rebuild mysql-community-8.1.0-1.el7.src.rpm

When done, all the new rpms can be found in ~/rpmbuild/RPMS/x86_64/:

$ ls -lh ~/rpmbuild/RPMS/x86_64/
total 946M
-rw-rw-r--. 1 opc opc  17M Aug 19 00:07 mysql-community-client-8.1.0-1.el7.x86_64.rpm
-rw-rw-r--. 1 opc opc 3.6M Aug 19 00:08 mysql-community-client-plugins-8.1.0-1.el7.x86_64.rpm
-rw-rw-r--. 1 opc opc 667K Aug 19 00:07 mysql-community-common-8.1.0-1.el7.x86_64.rpm
-rw-rw-r--. 1 opc opc 486M Aug 19 00:10 mysql-community-debuginfo-8.1.0-1.el7.x86_64.rpm
-rw-rw-r--. 1 opc opc 1.9M Aug 19 00:08 mysql-community-devel-8.1.0-1.el7.x86_64.rpm
-rw-rw-r--. 1 opc opc 4.1M Aug 19 00:08 mysql-community-embedded-compat-8.1.0-1.el7.x86_64.rpm
-rw-rw-r--. 1 opc opc 2.3M Aug 19 00:07 mysql-community-icu-data-files-8.1.0-1.el7.x86_64.rpm
-rw-rw-r--. 1 opc opc 1.6M Aug 19 00:08 mysql-community-libs-8.1.0-1.el7.x86_64.rpm
-rw-rw-r--. 1 opc opc 669K Aug 19 00:08 mysql-community-libs-compat-8.1.0-1.el7.x86_64.rpm
-rw-rw-r--. 1 opc opc  36M Aug 19 00:06 mysql-community-server-8.1.0-1.el7.x86_64.rpm
-rw-rw-r--. 1 opc opc  27M Aug 19 00:07 mysql-community-server-debug-8.1.0-1.el7.x86_64.rpm
-rw-rw-r--. 1 opc opc 363M Aug 19 00:08 mysql-community-test-8.1.0-1.el7.x86_64.rpm
-rw-rw-r--. 1 opc opc 5.2M Aug 19 00:08 mysql-router-community-8.1.0-1.el7.x86_64.rpm

Conclusion

Building an RPM for MySQL on Oracle Linux 7 using the source RPM is an involved but rewarding process and you can also use the same process to build extra RPMs for your own components.

You need then to install the src rpm, modify the mysql.spec file (or work on a copy). This process is similar to what I explained in this article.

As we wrap up, it’s always a good practice to test the custom RPMs in a controlled environment before deploying it into production. This ensures that everything runs as expected and reduces the potential for unforeseen issues.

Thank you for journeying through this guide. And as usual, enjoy MySQL !