expire_logs_days

来源:互联网 发布:数据正态分布含义 编辑:程序博客网 时间:2024/05/17 03:07

expire_logs_days
设置完这个参数之后需要执行flush logs

The number of days for automatic binary log file removal. The default is 0, which means “no automatic removal.” Possible removals happen at startup and when the binary log is flushed. Log flushing occurs as indicated in Section 5.2, “MySQL Server Logs”.
To remove binary log files manually, use the PURGE BINARY LOGS statement. See Section 12.5.1.1, “PURGE BINARY LOGS Syntax”.

In addition, the binary log is flushed when its size reaches the value of the max_binlog_size system variable.

max_binlog_size
If a write to the binary log causes the current log file size to exceed the value of this variable, the server rotates the binary logs (closes the current file and opens the next one). The minimum value is 4096 bytes. The maximum and default value is 1GB.

You might face sutch a problem if the mysql-bin.index file is no longer matching the reality (for exemple, if you manually deleted logs files).

cat your /var/log/mysql/mysql-bin.index (or whatever your .index file is), it is a text file that contains the names of all used binary log files. There shouldn't be a difference between its content and the list of log files on your filesystem.

You might try this (changing the paths according to your configuration) :
# /bin/ls -1 /var/log/mysql/mysql-bin.[0-9]* | diff /var/log/mysql/mysql-bin.index -


If there is a difference, try this :
- stop your mysql server
- backup your mysql-bin.index file
- re-create a file with the logs that still exists
- start your mysql server

Example (again, you might change the paths according to your own configuration) :
# /etc/init.d/mysql stop
# cd /var/log/mysql
# cp mysql-bin.index mysql-bin.index-
# ls -1 /var/log/mysql/mysql-bin.[0-9]* > mysql-bin.index
# /etc/init.d/mysql start

原创粉丝点击