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:

Filename				Type		Size	Used	Priority

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/shm

Create 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:

sudo mkswap /swapfile

The results display:

Setting up swapspace version 1, size = 262140 KiB
no label, UUID=103c4545-5fc5-47f3-a8b3-dfbdb64fd7eb

Finish up by activating the swap file:

sudo swapon /swapfile

You will then be able to see the new swap file when you view the swap summary.

swapon -s
Filename Type Size Used Priority
/swapfile file 262140 0 -1

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:

sudo nano /etc/fstab

Paste in the following line:

 /swapfile       none    swap    sw      0       0 

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:

echo 10 | sudo tee /proc/sys/vm/swappiness
echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf

To prevent the file from being world-readable, you should set up the correct permissions on the swap file:

sudo chown root:root /swapfile
sudo chmod 0600 /swapfile

Fatal error: cannot allocate memory for the buffer pool的更多相关文章

  1. centos Cannot allocate memory for the buffer pool

    mysql 无法启动 ,查看日志: --01T15::.401599Z [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. P ...

  2. mysql启动报错cannot allocate memory for the buffer pool处理

    今天启动mysql服务器时失败了.去/var/log/mysql/查看error.log,报错信息如下: 160123 22:29:26 InnoDB: Initializing buffer poo ...

  3. [ERROR] InnoDB: Cannot allocate memory for the buffer pool

    :: mysqld_safe Starting mysqld daemon with databases from /data/mysqldb -- :: [Note] /usr/local/mysq ...

  4. MySql启动,提示:Plugin 'FEDERATED' is disabled....Cannot allocate memory for the buffer pool

    2016-05-27 09:25:01 31332 [Note] Plugin 'FEDERATED' is disabled. 2016-05-27 09:25:01 31332 [Note] In ...

  5. mysql报错mmap(137428992 bytes) failed; errno 12,Cannot allocate memory for the buffer pool

    mysql以`systemctl start mysqld.service`的方式启动一段时间后发现突然无法启动,尝试重新启动也不能解决问题,排查问题时,先后通过`systemctl status m ...

  6. Cannot allocate memory for the buffer pool

    优化了一通,启动不了 直接上日志 innodb_buffer_pool_size”.”key_buffer_size” 的大小设置,适当的调大内存分配,减小,然后保存配置文件,重新尝试启mysql 成 ...

  7. PHP运行错最有效解决办法Fatal error: Out of memory (allocated 786432) (tried to allocate 98304 bytes) in H:\freehost\zhengbao2\web\includes\lib_common.php on line 744

    原文 PHP运行错最有效解决办法Fatal error: Out of memory (allocated 6029312) Fatal error: Out of memory (allocated ...

  8. MySQL:cannot allocate the memory for the buffer pool

    InnoDB: The InnoDB memory heap is disabled InnoDB: Mutexes and rw_locks use GCC atomic builtins Inno ...

  9. 黄聪:wordpress中PHP运行错最有效解决办法Fatal error: Out of memory (allocated 6029312)(转)

    近日在升级wordpress 3.2.1和若干插件的过程中,发现了一个wordpress的错误:Allowed memory size of XXX bytes exhausted Fatal err ...

随机推荐

  1. 制作OpenStack用的RHEL7系统镜像

    制作OpenStack使用的RHEL7系统镜像,并进行相关设置,安装XRDP以进行远程访问. 1.在KVM中安装RHEL7.2客户机: 2.设置网卡为dhcp并onboot=yes,使得虚拟机能自动获 ...

  2. DES,3DES,AES这三种对称密钥的区别与联系

    DES:Data Encryption Standard(数据加密标准,又美国国密局,选中的IBM的方案,密钥长度为56,标准提出是要使用64位长的密钥,但是实际中DES算法只用了64位中的56位密钥 ...

  3. 【转载】openldap 备份与导入 及相关问题--扩展

    http://www.cnblogs.com/ccdc/p/3356518.html 摘要: 对openldap进行备份时,直接使用slapcat命令进行备份,使用ldapadd还原出现问题及解决. ...

  4. 如何不通过系统升级来安装window10正式版?(特别针对Xp用户)

    今天是个特殊的日子7/29,相信大家都等了很久了吧,win10正式版终于上线,一些不懂电脑的人只会通过360和腾讯管家等来升级到win10(XP用户除外),而对于大多数像我这样对系统比较热衷的人,我相 ...

  5. android开发 wifi开发工具类

    import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.Iterator; import j ...

  6. 【Same Tree】cpp

    题目: Given two binary trees, write a function to check if they are equal or not. Two binary trees are ...

  7. django Forgienkey字段 在前台用js做处理

    在我做的项目中有个选择省城市的选项,这两个字段的关系是一对多的关系class Province(models.Model): # 省会      name = models.CharField(max ...

  8. 奶牛通讯 usaco 网络流

    这道题很有意思,原题是只需输出最小割集大小,现在oj上改成了输出字典序最小的割集: 题解:可以考虑从小到大删边,若删掉这条边后,最小割变小,保持不变,记录此时的最小割大小: 若最小割不变,恢复这条边: ...

  9. 小试牛刀MVC简单网页

    上次我们创建了第一个MVC的网站,没用下,这次就简单来运行下,首先大家要去理解下MVC模式到底什么关系.在这里我就不多说,直接创建一个网页,用来显示一些数据,数据库的话我就先简单用这样创建先,为了方便 ...

  10. 浅谈ASP.NET报表控件

    OWC似乎使用者居多,但看见有网友在帖中抱怨OWC在使用时需要许可证书,于是将其排除,我可不想BOSS在看报表时弹出一个“没有许可证书”的窗口. 接着找到了ComponentOne的Web chart ...