3

Building Percona Server for MySQL 8.0 with RocksDB Storage Engine on macOS

 2 years ago
source link: https://www.percona.com/blog/building-percona-server-for-mysql-8-0-with-rocksdb-storage-engine-on-macos/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Building Percona Server for MySQL 8.0 with RocksDB Storage Engine on macOS

RocksDB Storage Engine on MacOS

In Percona Server for MySQL 8.0.29-21, we added one more patch that helps us to build server code on macOS. To be precise here, we still could do this even before this patch but only partially. Now it is possible to build RocksDB Storage Engine as well.

A word of disclaimer here, at the moment, by macOS we still understand macOS for Intel x86_64 architecture (the most recent ARM versions with Apple M1 / M2 processors are out of the scope of this blog post). Moreover, Percona does not provide official macOS packages for Percona Server for MySQL. It’s just that a lot of our developers use Macs and we care a lot about this platform. As proof, here is a link to our Azure pipelines CI scripts with the latest CI changes that accompany this patch.

Prerequisites

In order to build Percona Server for MySQL, we need to install a number of dependencies. The most important one is Xcode which can be downloaded and installed directly from the App Store. Make sure that you run it at least once after installing. You will be asked to install Xcode Command Line Tools – please answer “yes” as this is the component we are looking for.

We will also need to install a number of third-party libraries on which Percona Server for MySQL code depends and the easiest way to do this would be via the brew package manager. If you don’t already have it installed, please follow the instructions.

After that, install the following tools/libraries via brew:

brew install
Shell
brew install cmake zstd [email protected] libevent lz4 icu4c protobuf libfido2

Please also notice that macOS itself, Xcode Command Line Tools, and brew packages are being constantly updated and when you try to follow the provided instructions their versions may not be the same as at the time when this blog post was written and as a result, something may not go as expected. So, just in case, I am including an excerpt from the brew config output to simply give you an idea of how old those components were.

brew config output
Shell
HOMEBREW_VERSION: 3.5.4-52-g0070591
ORIGIN: https://github.com/Homebrew/brew
HEAD: 007059160f1a9d7afba296e9aa30ab52d4ef29b7
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 83ce9a03239fe496e292f23a576bc7d1bcea4cca
Core tap branch: master
Clang: 13.1.6 build 1316
Git: 2.32.1 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.79.1 => /usr/bin/curl
macOS: 12.4-x86_64
Xcode: 13.4.1

Building

The first step would be to create a workspace directory and make it default:

creating workspace directory
Shell
mkdir ws

Second, download Percona Server for MySQL source code from the git repository. In these instructions, we will be checking out code marked with the Percona-Server-8.0.29-21 tag (just because it was the most recent release when this blog post was written) but feel free to experiment with the trunk (the head of the 8.0 branch).

cloning percona-server git repository
Shell
git clone https://github.com/percona/percona-server.git
cd percona-server
git checkout -b current Percona-Server-8.0.29-21
git submodule init
git submodule update

Then, we create a separate directory percona-build for intermediate objects and result libraries/executables.

creating build directory
Shell
mkdir percona-build
cd percona-build

After that, we need to run cmake to configure the project and generate Unix Makefiles.

executing cmake
Shell
cmake ../percona-server \
  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  -DBUILD_CONFIG=mysql_release \
  -DMYSQL_MAINTAINER_MODE=OFF \
  -DDOWNLOAD_BOOST=ON \
  -DWITH_BOOST=../deps \
  -DWITH_SYSTEM_LIBS=ON \
  -DWITHOUT_TOKUDB=ON
  -DWITH_ROCKSDB=ON

I am not going to describe every parameter here as there is an official MySQL Server documentation page but the most important ones are:

  • -DCMAKE_BUILD_TYPE=RelWithDebInfo – configure to build optimized binaries with Debug information
  • -DMYSQL_MAINTAINER_MODE=OFF – do not treat compiler warnings as errors
  • -DWITH_SYSTEM_LIBS=ON – use system libraries (those we installed via the brew) instead of their bundled version
  • -DWITHOUT_TOKUDB=ON – do not build TokuDB Storage Engine, it is deprecated and is incompatible with macOS
  • -DWITH_ROCKSDB=ON – build with RocksDB Storage Engine (the main reason for this blog post)

And finally, initiate the build process

building percona-server
Shell
cmake --build . -- -j

Please be patient as this may take from 15 to 60 min depending on your hardware.

Testing

Just to make sure that everything has been built successfully let us run a few MySQL tests via MTR.

running mtr
Shell
./mysql-test –debug-server rocksdb.1st

If you see something like this:

brew install
Shell
==============================================================================
                  TEST NAME                       RESULT  TIME (ms) COMMENT
------------------------------------------------------------------------------
[ 25%] rocksdb.1st 'write_prepared'              [ pass ]     89
[ 50%] rocksdb.1st 'write_unprepared'            [ pass ]     85
[ 75%] rocksdb.1st 'write_committed'             [ pass ]     85
[100%] shutdown_report                           [ pass ]
------------------------------------------------------------------------------

Congratulations, you have successfully built Percona Server for MySQL with RocksDB on macOS.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK