MySQL fifth day - Logs


Journal

  1. log_error (error log)
    • MySQL error messages for the operation of the recording process, such as, can not load MySQL database data files, or incorrect permissions, etc. will be recorded here.
    • By default, the error log is open and can not be disabled.
    • By default, the error log file data stored in the directory database, the name hostname.err, where hostname is the host name of the server.
    • After MySQL5.5.7, error logs can not be deleted, only to rename the original log files, and then manually flush the log to create a new command is as follows:
      mv hostname.err hostname.err.oldbak mysqladmin flush-logs
  2. general_log query log (Common Log)
    • In fact query log records all commands executed by the database, regardless of whether the statement is correct.
    • The role of the query log is to help us analyze which statements performing intensive, intensive implementation of the select statement whether the corresponding data can be cached, but can also help us to analyze the problem.
    • Query log is off by default, you can open the query log with the following command:
        set global general_log=1 set global logoutput='tabel' 
        --1为开启查询日志,0为关闭查询日志,这个命令设置后立即生效,不用重启MySQL.
  3. query log (slow query log)
    • Slow query will cause CPU / IOPS / memory consumption is too high, when the database performance bottlenecks encountered, most of the time due to the slow query results in the Turn on slow query log, you can let statement to query exceeds the specified time under the MySQL records, after operation and maintenance personnel by locating the analysis, it can be well optimized database functions.
    • By default, queries are not slow to open, only manually opened, slow query will be logged to the slow query log.
    • Open the way 1: Temporary open
        set global slow_query_log='ON'
        -- 只对当前数据库有效,且如果MySQL重启后就会失效.
    • Open the way 2: permanently open
      if you want to permanently take effect, it is necessary to modify the configuration file my.cnf, set the slow-query-log = 1 and restart MySQL.
  4. redo log (redo log) specific details
    • To avoid data write, IO operation occurs too frequently due to performance issues, MySQL uses a mechanism writes data to memory, and then brush into the bulk of the disk.
    • Settings
        innodb_flush_log_at_trx_commit 变量取值012,默认为1,三种情况用来控制commit动作是否将log buffer刷入到磁盘里.
    innodb_flush_log_at_timeout 秒数,表示刷日志的频率.
  5. undo log (rollback log)
    • Storing a value before the log is modified, if the modification to ensure that if an exception occurs, the log undo log can be used to achieve rollback operation.
    • logical undo log is the log, may be considered when the delete a record, records corresponding to a recording insert, when the rollback can read the content from a logical undo log records in the rollback.
  6. bin log (binary log)
    • A binary file that records all database table structure changes and modify table data, statements and time of occurrence, long time to perform, operational data and other additional information, but it does not record the SELECT / SHOW, which do not modify data in SQL statements.
      ****

Guess you like

Origin www.cnblogs.com/sweetXiaoma/p/12010942.html