zoukankan      html  css  js  c++  java
  • mysqld: Out of memory Centos 创建swap分区解决

    云服务器mariadb异常 mysqld: Out of memory Centos 创建swap分区解决

    最近几天,服务器异常,常报500错误,数据库无法连接,网站不能访问。查看mariadb日志,打开: /var/log/mariadb/mariadb.log
    
    160915 19:44:22 InnoDB: Fatal error: cannot allocate memory for the buffer pool
    160915 19:44:22 [ERROR] Plugin 'InnoDB' init function returned error.
    160915 19:44:22 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
    160915 19:44:22 [ERROR] mysqld: Out of memory (Needed 128917504 bytes)
    160915 19:44:22 [ERROR] mysqld: Out of memory (Needed 96681984 bytes)
    160915 19:44:22 [ERROR] mysqld: Out of memory (Needed 72499200 bytes)
    
    
    
    是内存不够,购买是阿里云主机1G内存,不够用了,可以创建swap分区来解决。
    

    解决方案

    创建4g swap分区
    dd if=/dev/zero of=/var/swap bs=1024 count=4194304 
    mkswap /var/swap
    
    
    激活swap分区
    swapon /var/swap
    
    
    设置自动挂载
    vi /etc/fstab  
    /var/swap               swap                    swap    defaults        0 0
    
    
    重启服务器
    shutdown -r now
    
    
    查看内存使用状态
    free -m
    			  total        used        free      shared  buff/cache   available
    Mem:            991         347         261          40         382         382
    Swap:          4096           0        4096
    创建swap分区成功,再没因内存不够而maridb自动关闭了。
    

    删除分区

    swapoff /var/swap
    希望你眼眸有星辰,心中有山海,从此以梦为马,不负韶华
  • 相关阅读:
    POJ Problem 1363 Rails 【栈】
    POJ Problem 3040 Allowance 【贪心】
    ACM 程序对拍
    HDU Problem
    POJ
    HDU Problem
    HDU Problem—2124 Repair the Wall 【贪心】
    HDU Problem 1052 Tian Ji -- The Horse Racing 【贪心】
    POJ Problem Radar Installation 【贪心】
    Beyond Compare和输出文件比较的方法
  • 原文地址:https://www.cnblogs.com/daviddd/p/12597819.html
Copyright © 2011-2022 走看看