0

Attempting to use jemalloc for mysql 5.7.30

Linux db1 4.18.0-193.6.3.el8_2.x86_64 #1 SMP Wed Jun 10 11:09:32 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

MySQL 5.7.30

yum list installed shows: jemalloc.x86_64 5.2.1-2.el8 @epel

jemalloc file evident in /usr/lib64/libjemalloc.so.2

Adding...

 [mysqld-safe]
malloc-lib=/usr/lib64/libjemalloc.so.2

...to my.cnf returns an "unknown variable" error for malloc-lib

Setting

[Service]
Environment="LD_PRELOAD=/usr/lib64/libjemalloc.so.2"

in the systemctl override file doesn't change anything

Manually doing

export LD_PRELOAD=/usr/lib64/libjemalloc.so.2

prior to a restart doesn't have any effect either.

What am I missing?

Andrew Poodle
  • 346
  • 3
  • 7
  • I used the instructions from Percona to setup jemalloc: https://www.percona.com/blog/2020/12/02/enabling-jemalloc-on-percona-server-for-mysql-5-7-and-8-0-series/ Hope that helps! – Doyle B Feb 23 '21 at 04:25
  • I'd seen that, but it doesn't really offer anything I've not already tried. – Andrew Poodle Feb 24 '21 at 15:40

1 Answers1

0

You need to edit systemd configuration file somewhere at:

/etc/systemd/system/mariadb.service.d/

or

/etc/systemd/system/multi-user.target.wants/mariadb.service

try to find mariadb configuration file there.

Then add line:

Environment="LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2"

Make sure you have that file at that path. You may have it at different location or with different name (like libjemalloc.so.1).

After that:

systemctl daemon-reload

And restart MariaDB.

Use that to check if Jemalloc is installed use in MariaDB console:

SHOW VARIABLES LIKE 'version_malloc_library';

If should show "jemalloc", not "system".

M_per
  • 313
  • 2
  • 12