V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Tony1ee
V2EX  ›  问与答

服务器宕机后 mysql 数据库出现问题求解

  •  
  •   Tony1ee · 2016-06-20 11:05:54 +08:00 · 3932 次点击
    这是一个创建于 2871 天前的主题,其中的信息可能已经有所发展或是发生改变。

    今天早些时候经历了宕机,服务器恢复以后,网站就挂了。
    访问 tony1ee.com 提示建立数据库连接时出错。
    ssh 连接服务器,启动 mysql 遇到了问题
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
    登入phpmyadmin也登入不上
    应该是Mysql出的问题 当时是一键安装的 lnmp 现在求助大伙这是个什么情况,怎么解决?

    第 1 条附言  ·  2016-06-20 11:36:42 +08:00
    启动 mysql 就提示 The server quit without updating PID file (/usr/local/mysql/var/tony1ee.pid).
    19 条回复    2016-06-20 15:30:21 +08:00
    Livid
        1
    Livid  
    MOD
       2016-06-20 11:07:58 +08:00   ❤️ 1
    看 MySQL 的出错日志,里面会有具体的错误信息。
    McContax
        2
    McContax  
       2016-06-20 11:10:13 +08:00 via Android
    打个赌,内存被 php-fpm 占满, Mysql 内存不足挂掉
    Tony1ee
        3
    Tony1ee  
    OP
       2016-06-20 11:11:09 +08:00
    @McContax 内存空的很
    9hills
        4
    9hills  
       2016-06-20 11:14:56 +08:00
    打个赌, MySQL 数据文件损坏无法启动
    Tony1ee
        5
    Tony1ee  
    OP
       2016-06-20 11:17:26 +08:00
    @Livid
    @9hills
    @McContax
    mysql 无法启动 提示 ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
    izoabr
        6
    izoabr  
       2016-06-20 11:17:52 +08:00
    手工启动一下数据库,然后看下日志
    lijinma
        7
    lijinma  
       2016-06-20 11:18:38 +08:00
    明显你连数据库服务器都没启动吧。。。你看看进程?
    jugelizi
        8
    jugelizi  
       2016-06-20 11:18:52 +08:00
    删除那个文件
    之前也在 linux 下遇到过
    p2p
        9
    p2p  
       2016-06-20 11:25:11 +08:00
    重启动下 mysql 就完了
    Tony1ee
        10
    Tony1ee  
    OP
       2016-06-20 11:30:40 +08:00
    @Livid
    @izoabr
    错误日志:
    160620 08:59:13 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
    160620 8:59:13 InnoDB: The InnoDB memory heap is disabled
    160620 8:59:13 InnoDB: Mutexes and rw_locks use GCC atomic builtins
    160620 8:59:13 InnoDB: Compressed tables use zlib 1.2.8
    160620 8:59:13 InnoDB: Using Linux native AIO
    160620 8:59:13 InnoDB: Initializing buffer pool, size = 16.0M
    160620 8:59:13 InnoDB: Completed initialization of buffer pool
    160620 8:59:13 InnoDB: highest supported file format is Barracuda.
    InnoDB: The log sequence number in ibdata files does not match
    InnoDB: the log sequence number in the ib_logfiles!
    160620 8:59:13 InnoDB: Database was not shut down normally!
    InnoDB: Starting crash recovery.
    InnoDB: Reading tablespace information from the .ibd files...
    InnoDB: Restoring possible half-written data pages from the doublewrite
    InnoDB: buffer...
    InnoDB: Database page corruption on disk or a failed
    InnoDB: file read of page 661.
    InnoDB: You may have to recover from a backup.
    160620 8:59:13 InnoDB: Page dump in ascii and hex (16384 bytes):
    后面是一堆乱码》》》?
    是需要 recover from a backup.吗?
    求教下一步怎么办
    ThreeBody
        11
    ThreeBody  
       2016-06-20 11:38:37 +08:00 via Android
    df 看看是不是空间满了
    scys
        12
    scys  
       2016-06-20 11:39:40 +08:00
    和 @9hills 说的一样,文件损坏了,你备份了吗?
    Tony1ee
        13
    Tony1ee  
    OP
       2016-06-20 11:41:20 +08:00
    @scys 似乎没有过 平时都不管数据库的 ……
    9hills
        14
    9hills  
       2016-06-20 11:42:04 +08:00 via iPhone
    @Tony1ee 数据文件损坏,找备份吧
    izoabr
        15
    izoabr  
       2016-06-20 11:45:58 +08:00
    我记得 innoDB 可以修复的,查查文档
    izoabr
        16
    izoabr  
       2016-06-20 11:48:30 +08:00
    http://www.downcc.com/tech/4842.html

    参考一下这个,确认是不是类似,但修复之前记得把这个坏的先 tar 一个备份。
    majunbo
        17
    majunbo  
       2016-06-20 11:50:41 +08:00
    楼主,我周 6 也碰到跟你类似的问题:
    Thread pointer: 0x0
    Attempting backtrace. You can use the following information to find out
    where mysqld died. If you see no messages after this, something went
    terribly wrong...
    stack_bottom = 0 thread_stack 0x40000
    /usr/local/mysql/bin/mysqld(my_print_stacktrace+0x35)[0x79e385]
    /usr/local/mysql/bin/mysqld(handle_fatal_signal+0x403)[0x66e113]
    /lib64/libpthread.so.0[0x33fc60eca0]
    /lib64/libc.so.6(gsignal+0x35)[0x33fba30265]
    /lib64/libc.so.6(abort+0x110)[0x33fba31d10]
    /usr/local/mysql/bin/mysqld[0x8adda6]
    /usr/local/mysql/bin/mysqld[0x8993f6]
    /usr/local/mysql/bin/mysqld[0x817a0f]
    /usr/local/mysql/bin/mysqld[0x7ccf73]
    /usr/local/mysql/bin/mysqld[0x8b551b]
    /usr/local/mysql/bin/mysqld[0x8b5ec4]
    /usr/local/mysql/bin/mysqld[0x8ab55d]
    /usr/local/mysql/bin/mysqld[0x7eb525]
    /usr/local/mysql/bin/mysqld[0x7e05b8]
    /lib64/libpthread.so.0[0x33fc60683d]

    我的解决方案是-----恢复数据库。
    Felldeadbird
        18
    Felldeadbird  
       2016-06-20 14:39:28 +08:00
    Mysql 启动不了来来去去问题就是几点:
    1.内存不足。 这个再意外崩溃的情况下导致的。这时候需要重启电脑才可以解决。
    2.硬盘空间满了,或者 MYSQL 启动进程的挂载空间满了。
    3.其他
    剩下的就针对解决就好了。。。
    PS :平时弄多几台机器做备份和主从。 MYSQL 崩溃起来 哭爹娘没用。
    zhouquanbest
        19
    zhouquanbest  
       2016-06-20 15:30:21 +08:00
    这么常见的一个问题 你真的只要 stackoverflow 上搜搜就有一堆答案
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2222 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 02:22 · PVG 10:22 · LAX 19:22 · JFK 22:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.