1. 程式人生 > >mysql 無法啟動,報too many connections,實際情況是磁碟滿了,mysql無法啟動造成的

mysql 無法啟動,報too many connections,實際情況是磁碟滿了,mysql無法啟動造成的

今天以前負責的一個網站,突然無法啟動,因為是thinkphp寫的,開啟網站直接報錯出現too many connections, 網上查了一下,說是連線數少了,還有說可能是ddos攻擊了。但是然後使用mysql -u user -p password 這樣使連不上mysql資料庫的,你發現連mysql也無法重啟,無法啟動。這個時候比較納悶,無法啟動,無法重啟,很無奈。只能檢視錯誤日誌,首先找到你的mysql錯誤日誌,看報什麼錯誤。一開始並沒有什麼有用的資訊。啟動mysql也沒有反應。

日誌出現

80520 19:39:42 InnoDB: The InnoDB memory heap is disabled
180520 19:39:42 InnoDB: Mutexes and rw_locks use GCC atomic builtins
180520 19:39:42 InnoDB: Compressed tables use zlib 1.2.3
180520 19:39:42 InnoDB: Initializing buffer pool, size = 128.0M
180520 19:39:42 InnoDB: Completed initialization of buffer pool
180520 19:39:42 InnoDB: highest supported file format is Barracuda.
180520 19:39:43  InnoDB: Waiting for the background threads to start
180520 19:39:44 InnoDB: 1.1.8 started; log sequence number 3240483408
180520 19:39:44 [Note] Recovering after a crash using mysql-bin
180520 19:39:44 [ERROR] Error in Log_event::read_log_event(): 'read error', data_len: 117, event_type: 2
180520 19:39:44 [Note] Starting crash recovery...
180520 19:39:44 [Note] Crash recovery finished.
^G/usr/local/mysql/bin/mysqld: Disk is full writing './mysql-bin.~rec~' (Errcode: 28). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)
^G/usr/local/mysql/bin/mysqld: Retry in 60 secs. Message reprinted in 600 secs
180520 19:49:52 InnoDB: The InnoDB memory heap is disabled
180520 19:49:52 InnoDB: Mutexes and rw_locks use GCC atomic builtins
180520 19:49:52 InnoDB: Compressed tables use zlib 1.2.3
180520 19:49:52 InnoDB: Initializing buffer pool, size = 128.0M
180520 19:49:52 InnoDB: Completed initialization of buffer pool
180520 19:49:52 InnoDB: highest supported file format is Barracuda.
180520 19:49:52  InnoDB: Waiting for the background threads to start
180520 19:49:53 InnoDB: 1.1.8 started; log sequence number 3240483408

180520 19:49:53 [Note] Recovering after a crash using mysql-bin

這個錯誤我搜了一下,並沒有發現什麼有用的資訊。

接下來有試著把所有的mysql程序全部殺掉重啟了,然後又試著重啟了一下mysql,在錯誤日誌裡面發現了這個資訊。

/usr/local/mysql/bin/mysqld: Disk is full writing './mysql-bin.~rec~' (Errcode: 28). Waiting for someone to free space... (Expect up to 60 secs delay for server to continue after freeing disk space)

^G/usr/local/mysql/bin/mysqld: Retry in 60 secs. Message reprinted in 600 secs

原來是磁碟滿了,使用df查了一下,發現根目錄/使用了100%.導致mysql無法寫入日誌檔案和相關資訊,刪除一部分檔案就可以了......