In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
You can dump MySQL-related log files (error log, general query log file and slow query log file) on a daily basis according to your needs, and only keep backup files for a specified number of days. Here is an example:
1), install the crond service (if yum install logrotate crontabs is not installed)
Rpm-qa | grep crontabs
Yum install crontabs
Chkconfig crond-- list # if it is not set to restart automatically, modify it with the following command
Chkconfig crond on
Service crond restart
2), create a MySQL root password file
Vi / root/.my.cnf
[mysqladmin]
User = sysadmin
Password = mysql
Chmod 600 / root/.my.cnf
3) copy mysql-log-rotate to the / etc/logrotate.d directory and modify its contents as follows:
# mysql_error.log error log file
# mysql_general.log Universal query Log File
# mysql_slow.log slow query log file
/ app/mysql/mysql3306/logs/mysql_error.log
/ app/mysql/mysql3306/logs/mysql_general.log
/ app/mysql/mysql3306/logs/mysql_slow.log {
# create 600 mysql mysql
Notifempty
Daily
Rotate 5
Copytruncate
Nocreate
Missingok
Compress
Dateext
Postrotate
# just if mysqld is really running
If test-x / app/mysql/mysql3306/bin/mysqladmin & &\
/ app/mysql/mysql3306/bin/mysqladmin ping & > / dev/null
Then
/ app/mysql/mysql3306/bin/mysqladmin flush-logs
Fi
Endscript
}
4) execute the following command to test whether the configuration is correct
/ usr/sbin/logrotate-f / etc/logrotate.d/mysql-log-rotate
Note: you need to view the backed-up compressed files and execute gunzip file_name.gz.
5) regular execution (every morning)
# vim / etc/crontab
59 23 * / usr/sbin/logrotate-f / etc/logrotate.d/mysql-log-rotate
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.