Correct opening posture of mysql core files

Source: Internet
Author: User

Correct opening posture of mysql core files
In the past two days, crash has frequently occurred to an instance, analyzed the log, and roughly understood the cause of the crash. However, the specific SQL statement is not found, there is no good way to avoid it. Therefore, I want to automatically save the memory stack-related information to the core file when mysql crashes, then, use gdb analysis and the source code to determine the root cause of mysql crash. Because you have previously set the core file in linux, you can use ulimit-c unlimited to open the core File Settings in linux, and then have tea, waiting for the creation of the core file. Finally, the crash instance appears, but the core file is not generated as scheduled. I checked the official mysql documentation and found that you also need to start or configure core_file to the configuration file through -- core-file, and then restart the instance. As shown in the official documentation:
This time, when the instance is restarted, the Service may be affected. In order to be cautious, a test environment is specially found and operated according to the following Configuration: 1. Open the linux core file and configure ulimit-c unlimited2. Add the mysql core_file configuration (note: the configuration is under [mysqld ), restart the test instance. 3. Simulate the mysql crash scenario. After the command kill-SEGV 'pidof mysqld 'is executed, the core file does not appear as scheduled, google found that someone encountered the same confusion as me, and found that there are still a few places to be set up, continue the test, this time follow the steps below: 1. Open the linux core file and configure ulimit-c unlimited2. Add the mysql core_file configuration (note: the configuration is under [mysqld ), and restart the test instance 3. Configure suid_dumpable (mysql usually starts in suid mode) echo 2>/proc/sys/fs/su Id_dumpable4. Set the directory where the core file is stored and set full control permissions mkdir/data/core & chmod 777/data/core & echo "/data/core">/proc /sys/kernel/core_pattern5. Simulate the crash scenario of mysql, after executing the following command kill-SEGV 'pidof mysqld 'kill, the core file is displayed for a long time. Summary: The correct way to open the mysql core file is as follows: 1. Enable the linux core file to configure ulimit-c unlimited2 and add the mysql core_file configuration (note: the configuration is under [mysqld ), and restart the test instance 3. Configure suid_dumpable (mysql usually starts in suid Mode) echo 2>/proc/sys/fs/suid_dumpable4. Set the directory where the core file is stored and set the full control permission mkdir/data/core & chmod 777/data/core & echo" /data/core ">/proc/sys/kernel/core_pattern
Note: After core configuration is enabled, there are two risks: 1. the disk space may be full-because all memory information of mysql server will be exported to the core file, including the content in the buffer pool, there may be dozens of hundreds of GB
2. mysql starts slowly after crash occurs-because a large amount of data needs to be exported to the core file, the startup speed will be much slower.

References:
Https://dev.mysql.com/doc/refman/5.5/en/server-options.html#option_mysqld_core-file
Https://www.percona.com/blog/2011/08/26/getting-mysql-core-file-on-linux/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.