Skip to content

Instantly share code, notes, and snippets.

@dotmanila
Created September 14, 2012 04:23
Show Gist options
  • Save dotmanila/3719757 to your computer and use it in GitHub Desktop.
Save dotmanila/3719757 to your computer and use it in GitHub Desktop.
generating core files
Here are the instructions on enabling core dumps for mysql. If you are starting, stopping mysql via the regular init scripts/mysqld_safe, you should execute/implement this changes as root. Additionally, you have to make sure that you mysqld binary is not stripped. For tarball distributions, this is usually the case. However for RPM or deb packages, they are often stripped. For RPM, you simply need to install the corresponding *-debuginfo* packages.
1. su as root
shell> su -
2. Set core-file-size ulimit to unlimited
shell> ulimit -c unlimited
3. When dumping multiple cores, best to suffix them with the current mysqld pid
shell> echo "1" > /proc/sys/kernel/core_uses_pid
4. This is IMPORTANT, if you have a large buffer pool or large MySQL memory footprint (think VIRT from top), that memory size should fit in the the directory you will set the core pattern to, for example if you have a running footprint of 5G, /var/tmp should at least have 5G free. Core files will be named like /var/tmp/core.12566
shell> echo "/var/tmp/core" > /proc/sys/kernel/core_pattern
5. Since mysql switches to mysql user when started, we need to enable suid dumpable
shell> echo 2 > /proc/sys/fs/suid_dumpable
6. Add the below options to the my.cnf on their corresponding sections as indicated.
[mysqld]
core-file
[mysqld_safe]
core-file-size=unlimited
7. Restart mysql (you can also test this by killing mysql with signal 11 i.e. kill -11 `pidof mysqld` and verify a core file is generated, restart mysql afterwards via init script or mysqld_safe to make sure it picks up the core-file-size again)
Let me know if you have questions with the instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment