Enable jemalloc for MySQL 5.7 WHM Server
Hi
i want to enable jemalloc on MySQL 5.7 on cPanel/WHM server on Centos 7.
i install jemalloc:
after that edit /etc/my.cnf and add:
then restart mysql server from whm. but when i check if jemalloc if enabled using pt-mysql-summary and also using below:
but the result that it is not enabled yet. how to enable it? Thanks,
yum list jemalloc
yum install jemalloc.x86_64after that edit /etc/my.cnf and add:
[mysqld_safe]
malloc-lib=/usr/lib64/libjemalloc.so.1
then restart mysql server from whm. but when i check if jemalloc if enabled using pt-mysql-summary and also using below:
lsof -p $(pidof mysqld) | grep membut the result that it is not enabled yet. how to enable it? Thanks,
-
Centos 7 requires more steps because it doesn't work when just editing the my.cnf I use the similar TCMALLOC and had to create a conf file at /etc/systemd/system/mysqld.service.d/ I used limits.conf but I believe it doesn't matter what you use. You would put the following in it [Service] Environment="LD_PRELOAD=/usr/lib64/libjemalloc.so.1"
Here's a link to tell you how to use systemctl edit to do it. I had to use the same method to change memory limits (LimitNOFILE, LimitMEMLOCK) that no longer works in my.cnf as well. systemd brought about these changes.0 -
Hi Thanks for your reply. is there a specific name i must name the new file inside " mysqld.service.d "? mention "TCMALLOC", in your opinion and experience which is one is better to use with mysql: TCMALLOC or jemalloc? since iam facing a problem with mysql that with time memory consume and increase to high level even if no load at that time but as some memory not free. Thanks, 0 -
You can name it limits.conf like I did. I have both tcmalloc and jemalloc installed just in case but I've only ever activated tcmalloc. From what I've read jemalloc is a good choice due to lower memory overhead and may be faster that tcmalloc with larger number of threads. Low threads tcmalloc wins. I should test jemalloc as well, but just never got around to it. I installed the mallocs for the same reason. MySQL 5.7 built in memory allocator leaks like a sieve and just grows and grows. tcmalloc solved that problem for me but I'm sure that jemalloc should do the same if not better for you. 0 -
ok, very thanks i will try it. 0 -
Look back at things, I think I went with tcmalloc because the latest version I could find for Centos was from 2017, while the latest for jemalloc was from 2014. Both have more recent versions, so not sure why there's not more recent versions for either in the repositories. Not sure if there's some issue with later versions if custom compiled, so I just stuck with what I've had. 0
Please sign in to leave a comment.
Comments
6 comments