Mysql佔用大量寫I/O

來源:互聯網
上載者:User

標籤:blank   display   border   資料庫   target   

早上收到zabbix警示,發現某台存放監控資料的資料庫主機CPU的IOwait較高,一直持續較長時間。

650) this.width=650;" style="background-image: none; display: inline" title="image" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/8E/5B/wKiom1i-W9rjoJG7AAGr09LftGA628.png" "1028" height="258" />

 

登入伺服器查看磁碟IO發現隊列高達90%多,而且經常反覆如此

650) this.width=650;" style="background-image: none; display: inline" title="image" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/8E/5B/wKiom1i-W-3BUox4AAcFQvjFBNw098.png" "1028" height="811" />

通過iotop查看發現佔用io較大的進程是mysql

650) this.width=650;" style="background-image: none; display: inline" title="image" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/8E/59/wKioL1i-W-6zksjwAAE24wURii4413.png" "1028" height="79" />

 

登入mysql查看show processlist,發現基本上每次io隊列較高時都是在insert時,以為是插入語句有問題,於是開啟mysql慢查詢日誌,觀察一段時間磁碟io仍然較高,但是發現並沒有任何慢查詢語句;

尋找關於mysql IO問題最佳化資料,《【轉載】sync_binlog和innodb_flush_log_at_trx_commit 淺析》說到 sync_binlog和innodb_flush_log_at_trx_commit 兩個參數,這兩個參數是控制MySQL 磁碟寫入策略以及資料安全性的關鍵參數

650) this.width=650;" style="background-image: none; display: inline" title="image" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M01/8E/5B/wKiom1i-XDnxpCSLAAPEpTKkqPw263.png" "844" height="539" />

由於這台主機作為監控服務資料庫,所以在部署之初沒有做太多最佳化,配置基本保持預設,所以在每次事務提交都對應一次寫操作,導致寫操作太過頻繁。

於是修改sync_binlog和innodb_flush_log_at_trx_commit參數

set global sync_binlog=500;  set global innodb_flush_log_at_trx_commit=2;

 

修改完sync_binlog和innodb_flush_log_at_trx_commit兩個參數後,觀察一段時間發現CPU的IOwait明顯降低

650) this.width=650;" style="background-image: none; display: inline" title="image" border="0" alt="image" src="http://s3.51cto.com/wyfs02/M02/8E/5B/wKiom1i-XDqxfh9gAAE75tn-MVY901.png" "1028" height="258" />

Mysql佔用大量寫I/O

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.