MariaDB日志类型
MariaDB日志类型
日志
1.binary
log
记录数据库所有修改动作的事件描述,二进制格式,需要和服务器兼容的mysqlbinlog来读取
开启方式:
[mysqld]
log_bin=/opt/mariadb/data/mysql_bin
#log_bin=mysql_bin默认也是放在data目录
读取binlog
mysqlbinlog
/opt/mariadb/data/mysql-bin.000001
2.error
log(critical errors)
记录数据库startup,shutdown,fails 默认文件名为hostname.err,
开启方式:
[mysqld]
log_error =
/opt/mariadb/log/mysqld.log
3.general
query log(performance killer)
默认禁用, 任何对mysql的操作都会记录日志,即使没有改变任何数据,
开启方式:
[mysqld]
general_log = 1 #on(=1), off(=0)
general_log_file = /opt/mariadb/log/general.log
4.slow query
log(optimizing&tuning)
默认禁用,数据库调优时非常有用
开启方式:
[mysqld]
slow_query_log = 1
slow_query_log_file = /opt/mariadb/log/mysqld-slow.log
long_query_time = 0.05
log_slow_rate_limit = 30 #记录slow query的频率,默认是每次都记录,适当的值可以避免日志暴涨
log_slow_verbosity = query_plan,standard
#log_slow_verbosity有如下几个参数
-
microtime: Makes the log to log the queries in microseconds
-
query_plan: Logs query execution plan information
-
innodb: Adds additional statistical information about queries that touch XtraDB and InnoDB tables
-
standard: Turns on both the microtime and innodb variables
-
full: Turns on all options
-
profiling: Allows the logged queries to be pro led