Compiling Percona XtraBackup for ARMThis blog post will show how to compile the Percona XtraBackup (PXB) tool for ARM. For this, we are going to use an AWS EC2 ARM instance with Ubuntu 20.04(Focal Fossa).

The motivation for this was born in my interest in the new generation of ARM processors and if this is a viable option for the future. Ideally, I do not recommend installing all the necessary packages to compile Xtrabackup in a production environment for security reasons. Still, you can have a “compiling” server for this purpose and then move the binaries around.

Machine Configuration

For this blog post, I picked a c6g.2xlarge instance. The machine has the following hardware configuration:

Instance SizevCPUMemory (GiB)Instance Storage (GiB)Network Bandwidth (Gbps)EBS Bandwidth (Mbps)
c6g.2xlarge816EBS-OnlyUp to 10Up to 4,750

And the OS specifications:

Note that the hardware capacity does not matter in the final result. But having a higher number of cores allows us to compile PXB faster. With all set, let’s start the compiling process.

Installing Dependencies

First, we will install and upgrade some packages necessary for this task:

Cloning XtraBackup Repository

Now, we will get the XtraBackup code in GitHub:

Note that I’m picking the percona-xtrabackup-8.0.23-16  version. The reason is that the latest MySQL release is MySQL 8.0.24, and PXB will work only with equal or lower versions than the one we currently selected. In this case, it is MySQL 8.0.23.

Compiling

Ok, we are ready to begin our first compilation! Let’s fire the necessary commands:

Remember in the beginning when I mentioned a better machine could compile faster? So, note in the last command above the option j -8. This will tell to make command to compile using all the 8 CPUs that I have available for this instance. You can adjust for any number of threads that you have (ideally should lesser or equal).

This process will take a while to finish, so we need to be patient.

Testing

Once the process is done, we are ready to run the binaries. They will be located in the /compile_xtrabackup/percona-xtrabackup/build/bin directory.

The backup process is the same for x86 platforms. For example:

At this moment, Oracle does not provide ARM packages for Ubuntu 20.04, so I opened this Feature Request for it:

Add Packages for Ubuntu to ARM architecture

And if you are wondering about PMM for ARM, my colleague Agustin Galego (GitHub) wrote a blog post about compiling the Percona Monitoring and Management client for ARM:

Compiling a Percona Monitoring and Management v2 Client in ARM Architecture

Conclusion

Compiling MySQL and PXB are not recommended for production systems, but for me, it is an excellent way to learn more about the code and its internal things. If you are interested in ARM, it is a way to start testing in advance to evaluate if it is the right architecture for your needs.

Useful Resources

Finally, you can reach us through the social networks, our forum, or access our material using the links presented below:

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Jinxiao Zhang

I encountered an error during compilation:

Building C object CMakeFiles/cmTC_1cfa3.dir/src.c.o
/usr/bin/cc -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fno-omit-frame-pointer -ffp-contract=off -ftls-model=initial-exec -g -O2 -fdebug-prefix-map=/percona-xtrabackup/build=. -fstack-protector-strong -Wformat -Werror=format-security  -Wdate-time -D_FORTIFY_SOURCE=2 -moutline-atomics -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Wwrite-strings -Wjump-misses-init -Wstringop-truncation -Wmissing-include-dirs -fno-strict-aliasing -DHAVE_SOLARIS_AFFINITY -fPIE  -o CMakeFiles/cmTC_1cfa3.dir/src.c.o  -c /percona-xtrabackup/build/CMakeFiles/CMakeTmp/src.c
/percona-xtrabackup/build/CMakeFiles/CMakeTmp/src.c:3:10: fatal error: sys/lwp.h: No such file or directory
  3 | #include <sys/lwp.h>
   |     ^~~~~~~~~~~
compilation terminated.
make[1]: *** [CMakeFiles/cmTC_1cfa3.dir/build.make:66: CMakeFiles/cmTC_1cfa3.dir/src.c.o] Error 1
make[1]: Leaving directory '/percona-xtrabackup/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_1cfa3/fast] Error 2

Source file was:

#include <sys/types.h>
#include <sys/lwp.h>
#include <sys/processor.h>
#include <sys/procset.h>
int main()
{
 processorid_t cpu_id = (processorid_t)0;
 id_t tid = _lwp_self();
 processor_bind(P_LWPID, tid, cpu_id, 0);
}
Performing C++ SOURCE FILE Test HAVE_CXX_W_shadow_field failed with the following output:
Change Dir: /percona-xtrabackup/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_478be/fast && /usr/bin/make -f CMakeFiles/cmTC_478be.dir/build.make CMakeFiles/cmTC_478be.dir/build
make[1]: Entering directory '/percona-xtrabackup/build/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_478be.dir/src.cxx.o
/usr/bin/c++ -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -std=c++17 -fno-omit-frame-pointer -ffp-contract=off -ftls-model=initial-exec -g -O2 -fdebug-prefix-map=/percona-xtrabackup/build=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -moutline-atomics -march=armv8-a+crc -Wall -Wextra -Wformat-security -Wvla -Wundef -Wmissing-format-attribute -Woverloaded-virtual -Wcast-qual -Wimplicit-fallthrough=5 -Wstringop-truncation -Wsuggest-override -Wmissing-include-dirs -Wextra-semi -Wlogical-op -DHAVE_CXX_W_shadow_field -Wshadow-field -fPIE  -o CMakeFiles/cmTC_478be.dir/src.cxx.o -c /percona-xtrabackup/build/CMakeFiles/CMakeTmp/src.cxx
c++: error: unrecognized command line option '-Wshadow-field'; did you mean '-Wshadow-ivar'?
make[1]: *** [CMakeFiles/cmTC_478be.dir/build.make:66: CMakeFiles/cmTC_478be.dir/src.cxx.o] Error 1
make[1]: Leaving directory '/percona-xtrabackup/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_478be/fast] Error 2

Last edited 1 year ago by Jinxiao Zhang