首页 > 代码库 > 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
二进制日志包含了所有更新了数据或者已经潜在更新了数据(例如,没有匹配任何 行的一个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:/#
/*!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:/#
记录包含所有执行时间超过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:~#
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:~#
MySQL配置优化(一)——慢查日志
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。