So after doing some readings, I saw that there are several advantages to using TokuDB over InnoDB when we are dealing with huge databases. The thing here is that using that TokuDB requires jemalloc to run. Since CentOS 7 and 8 are systemd enabled using the methods advertised on most websites won't work.
I will write here what I did to enable it,
Installing TokuDB on CentOS
CentOS' RPMs do not include TokuDB support out of the box. The easiest way is by using MariaDB's RPM's repo; they are published at http://yum.mariadb.org/. The RPMs from MariaDB do not have all the dependencies correctly, so you will need to type yum install jemalloc to install if you haven't.
If you are using CentOS 8, you will find some issues because of the RPMs shipped in CentOS. You will need to exclude CentOS MariaDB RPMs to let DNF do its job.
Enabling TokuDB with MariaDB on a SystemD System
Here it is the tricky part. Once you installed the engine-tokudb RPM, you will have in the /etc/my.cnf.d/ some files, one of them should be called tokudb.cnf. If you don't have any, add the following content in any .conf file:
# See https://mariadb.com/kb/en/tokudb-differences/ for differences
# between TokuDB in MariaDB and TokuDB from http://www.tokutek.com/
The next step is dealing with systemd. A simple export LD_PRELOAD=/usr/lib64/libjemalloc.so.2 won't work; systemd ignores all the current system variables and it always starts a new environment. To make this happen, type systemctl edit mariadb, an editor will open and put the following content:
ExecStartPre=/usr/bin/echo never > /sys/kernel/mm/transparent_hugepage/enabled
ExecStartPre=/usr/bin/echo never > /sys/kernel/mm/transparent_hugepage/defrag
/etc/sysconfig/mariadb is a file with the following content:
After that type systemctl daemon-reload, and you can start mariadb as usual, TokuDB should be ready to be used.
Good luck!blog comments powered by Disqus