This 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 Size | vCPU | Memory (GiB) | Instance Storage (GiB) | Network Bandwidth (Gbps) | EBS Bandwidth (Mbps) |
---|---|---|---|---|---|
c6g.2xlarge | 8 | 16 | EBS-Only | Up to 10 | Up to 4,750 |
And the OS specifications:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | $ cat /etc/*release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=20.04 DISTRIB_CODENAME=focal DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS" NAME="Ubuntu" VERSION="20.04.2 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.2 LTS" VERSION_ID="20.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=focal UBUNTU_CODENAME=focal |
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:
1 2 3 4 5 6 7 8 9 | # apt-get -y install dirmngr # apt-get update -y # apt-get -y install cmake # apt-get -y install lsb-release wget # apt-get -y install build-essential flex bison automake autoconf libtool cmake libaio-dev mysql-client libncurses-dev zlib1g-dev libev-dev libcurl4-gnutls-dev vim-common # apt-get install git # apt-get -y install devscripts libnuma-dev openssl libssl-dev libgcrypt20-dev |
Cloning XtraBackup Repository
Now, we will get the XtraBackup code in GitHub:
1 2 3 4 5 | # mkdir -p /compile_xtrabackup # cd /compile_xtrabackup/ # git clone https://github.com/percona/percona-xtrabackup.git # cd percona-xtrabackup # git checkout percona-xtrabackup-8.0.23-16 |
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:
1 2 3 4 5 | cd /compile_xtrabackup/percona-xtrabackup mkdir build && cd build mkdir /boost cmake .. -DWITH_NUMA=1 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/boost -DWITH_NUMA=1 -DCMAKE_INSTALL_PREFIX=/compile_xtrabackup/percona-xtrabackup/build make -j 8 && make install |
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.
1 2 | # ./bin/xtrabackup -version ./bin/xtrabackup version 8.0.23-16 based on MySQL server 8.0.23 Linux (aarch64) (revision id: 934bc8fb1d1) |
The backup process is the same for x86 platforms. For example:
1 2 | ./bin/xtrabackup --user=root --socket=/tmp/n1.sock --backup --target-dir=<target-backup-dir> --datadir=<datadir> ./bin/xtrabackup --prepare --target-dir=<target-dir> |
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:
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