NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
MySQL四大日志(log_error、slow_query_log、bin_log、general_log) # 日志清理 ---- 其他blog的解决办法 binlog就有40多G,原来根源出在这里,查看了一下my.cnf,看到binlog的size是1G就做分割,但没有看到删除的配置,在mysql里show了一下variables, mysql> show variables like '%log%'; 查到了 | expire_logs_days | 0 | 这个默认是0,也就是logs不过期,这个是一个global的参数,所以需要执行 set global expire_logs_days=5; 这样2天前的log就会被删除了,如果有回复的需要,请做好备份工作,但这样设置还不行,下次重启mysql了,配置又恢复默认了,所以需在my.cnf中设置 expire_logs_days = 8 这样重启也不怕了, PURGE MASTER LOGS BEFORE DATE_SUB(CURRENT_DATE, INTERVAL 2 DAY); //删除10天前的MySQL binlog日志,附录2有关于PURGE MASTER LOGS手动 PURGE MASTER LOGS TO 'master-binlog.002195'; ueidrh.broker.lwork.com crm.fxhuge.cn 错误日志不重启清理 --------- 可以用--log-error=/var/log/mysqld.log选项来开启mysql错误日志 shell> mv mysqld.log mysqld.log.bak shell>touch mysqld.log shell>chown mysql.mysql mysqld.log shell> mysqladmin -uroot -p flush-logs Note For the server to recreate a given log file after you have renamed the file externally, the file location must be writable by the server. This may not always be the case. For example, on Linux, the server might write the error log as /var/log/mysqld.log, where /var/log is owned by root and not writable by mysqld. In this case, the log-flushing operation will fail to create a new log file. To handle this situation, you must manually create the new log file with the proper ownershiop after renaming the original log file. For example, execute these commands as root: shell> mv /var/log/mysqld.log /var/log/mysqld.log.old shell> install -omysql -gmysql -m0644 /dev/null /var/log/mysqld.log 需要重启