MYSQL, innodb_buffer_pool_size memory allocation method, innodbbufferpool

Source: Internet
Author: User

MYSQL, innodb_buffer_pool_size memory allocation method, innodbbufferpool

I used to think that MYSQL, innodb_buffer_pool_size = 8 GB, MySQL will occupy 8 GB of memory when it moves together (I think TOP can see that the memory is used 8 GB), but I have studied it carefully recently, it turns out that this is not the case (maybe I only know about the Linux malloc memory allocation). When MySQL is started, it actually only allocates the address space in the virtual memory, but it does not actually map to the physical memory.

Because malloc allocates memory by allocating addresses in the virtual memory, which is truly mapped to the physical memory only when used.

Therefore, in this case, if the machine memory is improperly used and MySQL needs to map physical memory, if the physical memory is insufficient, an error or even exit.


But here is also a wonderful thing: the OOM Killer in Linux:

Assume that A program A is running and has allocated 22 GB of memory (the host configuration is physical memory 16 GB + SWAP 8 GB), but it is not mapped to physical memory;

When MySQL is started, innodb_buffer_pool_size = 8 GB. the startup is normal;

Then program A starts to actually allocate the physical memory, leaving only 2 GB of SWAP memory at once;

At this time, MYSQL also began to actually use the memory, because there is only 2g swap, so the performance is very poor, more than 2G, the memory is exhausted, then OOM Killer began to kill the process, how to kill it, who takes up more memory to kill, so process A is killed, and the memory is suddenly back, MySQL will not quit;

However, in general systems, MySQL has the largest memory allocation, so MySQL is often killed.


For details about Linux OOM Killer, refer to: Understanding and configuring OOM Killer in Linux.


Change innodb_buffer_pool_size of mysql innodb in linux

Is your memory not large enough? paste the my. cnf File
 
I changed the mysql configuration file and added innodb buffer_pool_size to myini. Why is it useless?

Add more after [mysqld]
Do not add

Mysql needs to be restarted

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.