• Linux磁盘空间爆满,MySQL无法启动


    OS: Cent OS 6.3

    DB: 5.5.14


    看到一个帖子,在服务器上安装了oracle和mysql数据库,mysql数据库忘记开启innodb_file_per_table,导致插入测试数据后磁盘空间爆满,mysql启动报错,并且无法启动。

    1、可以直接删除ibdata文件后重建mysql数据库,but,里面还有一些有用数据,因此无法直接删除ibdata进行操作,只能另谋出路。
    2、Linux默认会保留5%的空间,用tune2fs命令

    模拟:

    服务器上也有oracle和mysql数据库,用dd直接把磁盘空间撑爆

    dd  if=/dev/zero   of=/export/test   bs=50MB  count=2000


    [root@db01 export]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                           50G   48G     0 100% /
    tmpfs                 7.7G     0  7.7G   0% /dev/shm
    /dev/sda1             485M   32M  429M   7% /boot


    [root@db01 ~]# service mysqld stop
    Shutting down MySQL............................................ SUCCESS! 


    [root@db01 ~]# service mysqld start
    Starting MySQL.................................................................................................................................................................................................................................................................................................................................无法正常启动


    数据库忘记设置innodb_fiile_per_table,其它库中又有有用数据,无法直接删除ibdata重新配置

    在Linux系统中,默认会保留5%的空间

    [root@db01 log]# tune2fs -m 1 /dev/mapper/VolGroup-lv_root
    tune2fs 1.41.12 (17-May-2010)
    Setting reserved blocks percentage to 1% (131072 blocks)

    查看磁盘空间:

    [root@db01 log]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup-lv_root
                           50G   48G  783M  99% /
    tmpfs                 7.7G     0  7.7G   0% /dev/shm
    /dev/sda1             485M   32M  429M   7% /boot


    空间由原来的100%变成了99%,尝试启动mysql数据库
    [root@db01 ~]# service mysqld start
    Starting MySQL SUCCESS! 

    [root@db01 ~]# ps -ef | grep mysql
    root     31405     1  3 00:37 pts/2    00:00:00 /bin/sh /export/servers/mysql/bin/mysqld_safe --datadir=/export/servers/mysql/data --pid-file=/export/servers/mysql/tmp/mysql.pid
    mysql    32200 31405 63 00:37 pts/2    00:00:01 /export/servers/mysql/bin/mysqld --basedir=/export/servers/mysql --datadir=/export/servers/mysql/data --plugin-dir=/export/servers/mysql/lib/plugin --user=mysql --log-error=/export/servers/mysql/log/error.log --open-files-limit=65535 --pid-file=/export/servers/mysql/tmp/mysql.pid --socket=/export/servers/mysql/tmp/mysql.sock --port=3306
    root     32218 27979  0 00:37 pts/2    00:00:00 grep mysql


    [root@db01 bin]# ./mysql -uroot -S /export/servers/mysql/tmp/mysql.sock 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 1
    Server version: 5.5.14-log Source distribution


    Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.


    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.


    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.


    mysql> show databases;
    +--------------------+
    | Database           |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sakila             |
    | test               |
    | yoon               |
    +--------------------+
    6 rows in set (0.05 sec)


    mysql> 

    最后通过mysqldump备份数据库,删除ibdata重新配置mysql,并设置innodb_file_per_table 为 on 

    tune2fs用法:
    1、tune2fs --help
    2、找度娘

  • 相关阅读:
    int是逻辑炸弹吗?
    悲剧
    下班啦
    Android SDK 2.2 开发环境安装
    MVC
    用于主题检测的临时日志(61d47e0cd5874842a9f56a725c1f25f6 3bfe001a32de4114a6b44005b770f6d7)
    ASP.NET读取XML文件
    asp.net执行顺序
    理解POCO
    乐观中谨慎 招聘调薪现"贫富差距"
  • 原文地址:https://www.cnblogs.com/hankyoon/p/5169632.html
Copyright © 2020-2023  润新知