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

來源:互聯網
上載者:User

MySQL配置最佳化(一)——慢查日誌,mysql配置最佳化日誌
(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)的所有語句。語句以“事件”的形式儲存,它描述資料更改;root@kallen:/# mysqlbinlog log-file 
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 
/*!40019 SET @@session.max_insert_delayed_threads=0*/; 
/*!50003 SET @OLD_COMPLETION_TYPE=@@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 COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; ddkosooodfdsfsfs
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 
root@kallen:/#
(3) 慢查詢日誌記錄包含所有執行時間超過long_query_time秒的SQL語句的記錄檔。獲得初使表 鎖定的時間不算作執行時間。用--log-slow-queries[=file_name]選項啟動它。如果沒有給出file_name值, 默 認為主機名稱,尾碼為-slow.log。如果給出了檔案名稱,但不是絕對路徑名,檔案則寫 入資料目錄。root@kallen:/var/log/mysql# mysqldumpslow log-file
root@kallen:~# 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' 
root@kallen:~#




























相關文章

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.