Fatal error: cannot allocate memory for the buffer pool
mysql有時候會被系統kill掉,原因是內存不夠了,一般都是Ubuntu出現的,因為Ubuntu吃內存,你們又給的不多。。
咋解決呢?
重啟服務器是可以的,起碼暫時可以了,
可以考慮加內存,或者增加swap。
如果給Ubuntu增加swap請見下文:
轉載自:https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04
?
About Linux Swapping
Linux RAM is composed of chunks of memory called pages. To free up pages of RAM, a “linux swap” can occur and a page of memory is copied from the RAM to preconfigured space on the hard disk. Linux swaps allow a system to harness more memory than was originally physically available.?
However, swapping does have disadvantages. Because hard disks have a much slower memory than RAM, virtual private server performance may slow down considerably. Additionally, swap thrashing can begin to take place if the system gets swamped from too many files being swapped in and out.
Check for Swap Space
Before we proceed to set up a swap file, we need to check if any swap files have been enabled on the VPS by looking at the summary of swap usage.
sudo swapon -s
An empty list will confirm that you have no swap files enabled:
Check the File System
After we know that we do not have a swap file enabled on the virtual server, we can check how much space we have on the server with the?df?command. The swap file will take 256MB— since we are only using up about 8% of the /dev/sda, we can proceed.
df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda 20907056 1437188 18421292 8% / udev 121588 4 121584 1% /dev tmpfs 49752 208 49544 1% /run none 5120 0 5120 0% /run/lock none 124372 0 124372 0% /run/shmCreate and Enable the Swap File
Now it’s time to create the swap file itself using the dd command :
sudo dd if=/dev/zero of=/swapfile bs=1024 count=256k
“of=/swapfile” designates the file’s name. In this case the name is swapfile.?
Subsequently we are going to prepare the swap file by creating a linux swap area:
The results display:
Finish up by activating the swap file:
You will then be able to see the new swap file when you view the swap summary.
This file will last on the virtual private server until the machine reboots. You can ensure that the swap is permanent by adding it to the fstab file.
Open up the file:
Paste in the following line:
Swappiness in the file should be set to 10. Skipping this step may cause both poor performance, whereas setting it to 10 will cause swap to act as an emergency buffer, preventing out-of-memory crashes.
You can do this with the following commands:
To prevent the file from being world-readable, you should set up the correct permissions on the swap file:
轉載于:https://www.cnblogs.com/maseng/p/3741043.html
總結
以上是生活随笔為你收集整理的Fatal error: cannot allocate memory for the buffer pool的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 迭代器模式和组合模式混用
- 下一篇: How to consume AIF s