Explains how to use CMake options like `PLUGIN_xxx` to control which plugins are built statically, dynamically, or not at all during compilation.
Compile MariaDB Server with extra modules and options. This section details how to customize your build from source, enabling specific features or optimizations for your deployment.
Instructions on building and configuring MariaDB to use alternative memory allocators like TCMalloc or jemalloc for improved performance and profiling.
jemalloc/usr/lib64/libjemalloc.so.2sudo systemctl edit mariadbsudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl restart mariadbmariadb -e "SHOW GLOBAL VARIABLES LIKE 'version_malloc_library';"
+------------------------+------------------------------------------------------------+
| Variable_name | Value |
+------------------------+------------------------------------------------------------+
| version_malloc_library | jemalloc 5.2.1-0-gea6b3e973b477b8061e0076bb257dbd7f3faa756 |
+------------------------+------------------------------------------------------------+sudo cat /proc/$MARIADB_PID/environ | tr '\0' '\n' | grep LD_PRELOAD
LD_PRELOAD=/usr/lib64/libjemalloc.so.2# On Debian/Ubuntu
find /usr/lib -name "libjemalloc.so.*"
# On RHEL/CentOS
find /usr/lib64 -name "libjemalloc.so.*"SHOW GLOBAL VARIABLES LIKE 'version_malloc_library';
+------------------------+--------+
| Variable_name | Value |
+------------------------+--------+
| version_malloc_library | system |
+------------------------+--------+cmake -DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc' -DWITH_SAFEMALLOC=OFF/usr/sbin/mariadbd-safe --malloc-lib=tcmalloc[mariadbd-safe]
malloc-lib=tcmalloc# jemalloc
find /usr/lib -name "libjemalloc.so.*"
# tcmalloc
find /usr/lib -name "libtcmalloc.so.*"LD_PRELOAD=/path/to/library mariadbdsystemctl status mariadb | grep Loaded[Service]
Environment=LD_PRELOAD=<path-to-library>[Service]
Environment=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2systemctl daemon-reload
systemctl restart mariadbENV LD_PRELOAD=<path-to-library># jemalloc
docker exec -ti <container-name> find /usr/lib -name "libjemalloc.so.*"
# tcmalloc
docker exec -ti <container-name> find /usr/lib -name "libtcmalloc.so.*"docker run -P -d --name mariadb --env LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libjemalloc.so.2" --env MARIADB_ROOT_PASSWORD=Password123! mariadb:latestfind /usr -name "libjemalloc.so.*"MALLOC_CONF=prof_leak:true,lg_prof_sample:0,prof_final:true \
LD_PRELOAD=${JEMALLOC_PATH}/lib/libjemalloc.so.2 path-to-mariadbd<jemalloc>: Leak summary: 267184 bytes, 473 objects, 20 contexts
<jemalloc>: Run jeprof on "jeprof.19678.0.f.heap" for leak detailjeprof --show_bytes path-to-mariadbd jeprof.19678.0.f.heapjeprof --show_bytes --pdf path-to-mariadbd jeprof.19678.0.f.heap > /tmp/mariadbd.pdf[Service]
Environment="LD_PRELOAD=/usr/lib64/libjemalloc.so.2"sudo cat /proc/$MARIADB_PID/maps | grep jemalloc
7f6981c00000-7f6981c06000 r--p 00000000 fd:00 50981369 /usr/lib64/libjemalloc.so.2
7f6981c06000-7f6981c76000 r-xp 00006000 fd:00 50981369 /usr/lib64/libjemalloc.so.2
7f6981c76000-7f6981c81000 r--p 00076000 fd:00 50981369 /usr/lib64/libjemalloc.so.2
7f6981c81000-7f6981c87000 r--p 00080000 fd:00 50981369 /usr/lib64/libjemalloc.so.2
7f6981c87000-7f6981c88000 rw-p 00086000 fd:00 50981369 /usr/lib64/libjemalloc.so.2