MySQL配置最佳化(一)——慢查日誌

來源:互聯網
上載者:User

標籤:mysql   mysqldump   mysqldumpslow   

(1) ERRLOG包含了當mysqd啟動和停止時,以及伺服器在運行過程中發生任何嚴重錯誤時的相 關資訊;可以用--log-error[=file_name]選項來指定mysqld儲存錯誤記錄檔檔案的位置。如果沒有給定file_name值,mysqld使用錯誤記錄檔名host_name.err 並在資料目錄中寫入記錄檔;# * Logging and Replication# Both location gets rotated by the cronjob.# Be aware that this log type is a performance killer.# As of 5.1 you can enable the log at runtime!#general_log_file        = /var/log/mysql/mysql.log fg#general_log             = 1# Error log - should be very few entries.log_error = /var/log/mysql/error.log
(2)BINLOG二進位日誌包含了所有更新了資料或者已經潛在更新了資料(例如,沒有匹配任何 行的一個DELETE)的所有語句。語句以“事件”的形式儲存,它描述資料更改;[email protected]:/# mysqlbinlog log-file 
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 
/*!40019 SET @@session.max_insert_delayed_threads=0*/; 
/*!50003 SET @[email protected]@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 
DELIMITER /*!*/; 
mysqlbinlog: File ‘log-file‘ not found (Errcode: 2) 
DELIMITER ; 
# End of log file 
ROLLBACK /* added by mysqlbinlog */; 
/*!50003 SET [email protected]_COMPLETION_TYPE*/; ddkosooodfdsfsfs
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 
[email protected]:/#

(3) 慢查詢日誌記錄包含所有執行時間超過long_query_time秒的SQL語句的記錄檔。獲得初使表 鎖定的時間不算作執行時間。用--log-slow-queries[=file_name]選項啟動它。如果沒有給出file_name值, 默 認為主機名稱,尾碼為-slow.log。如果給出了檔案名稱,但不是絕對路徑名,檔案則寫 入資料目錄。[email protected]:/var/log/mysql# mysqldumpslow log-file
[email protected]:~# mysqldumpslow /var/log/mysql/mysql-slow.log 
Reading mysql slow query log from /var/log/mysql/mysql-slow.log 
Count: 1 Time=0.88s (0s) Lock=0.00s (0s) Rows=0.0 (0), debian-sys-maint[debian-sys-maint]@localhost 
select count(*) into @discard from `information_schema`.`COLUMNS` 

Count: 1 Time=0.16s (0s) Lock=0.00s (0s) Rows=35.0 (35), debian-sys-maint[debian-sys-maint]@localhost 
select concat(‘S‘, 
TABLE_SCHEMA, ‘S‘, TABLE_NAME, ‘S‘) 
from information_schema.TABLES where ENGINE=‘S‘ 
[email protected]:~#




























MySQL配置最佳化(一)——慢查日誌

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.