1

Raspberry on the Rocks: Build Percona Server for MySQL With MyRocks on Your Rasp...

 1 year ago
source link: https://www.percona.com/blog/raspberry-on-the-rocks-build-percona-server-for-mysql-with-myrocks-on-your-raspberry-pi/
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.

Raspberry on the Rocks: Build Percona Server for MySQL With MyRocks on Your Raspberry Pi

Percona Server for MySQL With MyRocks on Your Raspberry PiRaspberry PI is a small single-board computer (SBCs) developed by the Raspberry Pi Foundation in association with Broadcom. This tiny computer is extremely popular and widely used in many areas. Thanks to its size, low cost, and low energy requirements, it can be used to collect data in remote locations or from sensor devices. We often need to be able to store large amounts of data efficiently on these devices.

MyRocks is a MySQL engine that uses RocksDB to store data. It is space efficient and able to handle writes quite efficiently.

First things first

Building and installing Percona Server for MySQL with MyRocks engine enabled is easy but requires some time. It is essential to make sure that you have all the ingredients and meet all the requirements:

  • Raspberry PI 3, 4, 400, or superior.
  • SD Card with Raspberry Pi OS 11 Bullseye 64 bits
  • Internet connectivity
  • 2 ounces gin
  • 1/2 ounce lemon juice, freshly squeezed
  • 1/2 ounce raspberry syrup
  • One egg white
  • Three raspberries

Preparation tasks

You need a Raspberry PI with a 64bits processor. We assume you already have installed the most recent version of Raspios. As of this writing, the version is 11 Bullseye.

Install screen package

Screen will allow you to reconnect if the connection is lost during the installation procedure. We install it, and we open a new session.

Shell
sudo -i
apt-get install screen
screen -LS install_mysql

Increase available memory

To build and install MySQL, you need a significant amount of memory. We recommend adding at least 4Gb of swap.

Shell
dd if=/dev/zero of=/swapfile4GB bs=1M count=4096
mkswap /swapfile4GB
chmod 0600 /swapfile4GB
swapon /swapfile4GB

Install additional packages

We need git to clone the Percona repository that contains MySQL.

Shell
apt-get install git

And some packages and libraries are needed to build and run MySQL.

Shell
apt-get install libjemalloc-dev libjemalloc2
apt-get install libzstd-dev zstd libevent-dev libicu-dev lz4 \
liblz4-dev cmake libprotobuf-dev protobuf-compiler \
libfido2-dev libssl-dev libldap-dev libsasl2-dev \
libsasl2-modules-gssapi-mit libkrb5-dev \
libncurses-dev libaio-dev libreadline-dev \
libprotoc-dev bison libcurl4-openssl-dev

Once we have all those packages installed, we can download the MySQL code.

Build Percona Server for MySQL

Configure the environment and download the source code

First, we create a working directory and move the working directory there.

Shell
mkdir ws

Then we clone the source code. This process will take some time.

Shell
git clone https://github.com/percona/percona-server.git

The Clover Club Cocktail

The Clover Club was a men’s club established in 1882 in Philadelphia. The club met in the Bellevue-Stratford Hotel. It was pretty popular, having writers, lawyers, and businessmen among its members. The club gatherings were not used only to discuss issues of the day, but also included drinks. One of the most liked ones was a cocktail made of gin, lemon juice, raspberry syrup, and egg white.

The Clover Club Cocktail enjoyed some popularity for some time but almost disappeared for most of the 20th century. The cocktail recovered some of its popularity during the first decade of the 21st century thanks to modern cocktail books. More on this later…

Configure the code

The first step is changing to the branch you want to build. In our example, we are using the most recently released branch. But you could use a development branch if you want; just make sure that you understand the implications of using a version that hasn’t been released yet.

Shell
cd percona-server
git checkout -b current Percona-Server-8.0.29-21
git submodule init
git submodule update

This will download some additional code.

Fix configuration

If you are building a version previous to 8.0.30, then you need to edit the MyRocks cmake file to allow MyRocks to be built on a different architecture than i86_64. The file is located in percona-server/storage/rocksdb and the name is CMakeLists.txt

What needs to be done is adding arm64 to the supported CPU architectures and checking that specific intel i86_64-specific extensions are not used. If you prefer, you can just replace the file with the version from my GitHub repository.

https://raw.githubusercontent.com/peppla/blog_posts/main/RaspberryOnTheRocks/storage/rocksdb/CMakeLists.txt

Configure

We create a directory only for the build process:

Shell
mkdir percona-build
cd percona-build

And we launch the configuration process. This process takes some minutes to complete.

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

The configuration should finish without errors. If you get any error regarding the version of zlib, you can add a flag to the configuration to use the bundled version:

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 \
-DWITH_ZLIB=bundled

Build

Once we complete the configuration, the build process is quite straightforward. Just run the following command:

Shell
cmake --build . -- -j 4

The building process will take some time, depending on the speed of your processor and how fast your storage is. In any case, if executed successfully, it should take a few hours.

In the meantime…

To prepare the raspberry syrup:

  • Add one cup of sugar and 1/2 cup of water to a pot.
  • Stir over medium heat until the sugar has dissolved.
  • Reduce heat to low, add 1/2 cup fresh raspberries, and macerate into a pulp.
  • Fine-strain to remove the berry’s tiny seeds.
  • Optionally, add 1/2 oz vodka as a preservative.
  • Refrigerate in a jar until ready for use.

Once the raspberry syrup is ready, we can proceed with the Clover Club Cocktail: Add the gin, lemon juice, raspberry syrup, and egg white into a shaker with ice and shake vigorously until well-chilled. Strain into a chilled cocktail glass. Garnish with three speared raspberries.

Testing

Once the build process has finished, you can test the results using the MySQL test suite:

Shell
./mysql-test/mtr rocksdb.1st

You should get results similar to these:

Shell
==============================================================================
TEST NAME RESULT TIME (ms) COMMENT
------------------------------------------------------------------------------
worker[1] mysql-test-run: WARNING: running this script as _root_ will cause some tests to be skipped
[ 25%] rocksdb.1st 'write_prepared' [ pass ] 138
[ 50%] rocksdb.1st 'write_unprepared' [ pass ] 519
[ 75%] rocksdb.1st 'write_committed' [ pass ] 132
[100%] shutdown_report [ pass ]
------------------------------------------------------------------------------
The servers were restarted 2 times
The servers were reinitialized 0 times
Spent 0.789 of 116 seconds executing testcases
Completed: All 4 tests were successful.

Install and distribute

You can install the binaries you recently built by executing the following command:

Shell
make install

Or create a compressed tar file that you can use to install the server manually:

Shell
make package

Once the binaries are installed, follow the standard procedure to initialize and configure the server.

Warning

According to the Surgeon General, women should not drink alcoholic beverages during pregnancy because of the risk of birth defects. Consumption of alcoholic beverages impairs your ability to drive a car or operate machinery, including databases, and may cause health problems. Consuming raw and lightly cooked eggs poses a risk of foodborne illness.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK