从上面我们可以知道,这个默认的配置文件将读取目录/etc/logrotate.d,所以我们只要把自己写的配置文件放到该目录下即可 。
MySQL本省提供了一个rotate的参考配置文件,在support-files目录下,文件名为mysql-log-rotate,内容如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# This logname can be set in /etc/my.cnf # by setting the variable "err-log" # in the [safe_mysqld] section as follows: # # [safe_mysqld] # err-log=/opt/mysql/data/mysqld.log # # If the root user has a password you have to create a # /root/.my.cnf configuration file with the following # content: # # [mysqladmin] # password = <secret> # user= root # # where "<secret>" is the password. # # ATTENTION: This /root/.my.cnf should be readable ONLY # for root ! /opt/mysql/data/mysqld.log { # create 600 mysql mysql notifempty daily rotate 3 missingok compress postrotate # just if mysqld is really running if test -x /opt/mysql/bin/mysqladmin &&/opt/mysql/bin/mysqladmin ping &>/dev/nullthen /opt/mysql/bin/mysqladmin flush-logs fi endscript }logrotate常见选项:

我们只要根据自己的需要,修改相应配置即可,下面是一个例子:
1)创建MySQL root密码文件
vi /root/.my.cnf
1
2
3
[mysqladmin] password = *** user= rootchmod 600 /root/.my.cnf
2)把mysql-log-rotate拷贝至/etc/logrotate.d目录下,修改其内容为:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/data/mysql/log/slow.log /data/mysql/log/alert.log { create 600 mysql mysql notifempty daily rotate 7 missingok # compress postrotate # just if mysqld is really running if test -x /opt/mysql/bin/mysqladmin &&/opt/mysql/bin/mysqladmin ping &>/dev/null then /opt/mysql/bin/mysqladmin flush-logs fi endscript }
推荐阅读
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 对爱情的理解,爱情的理解是什么?
- 冬笋如何采挖
- 香肠派对房卡怎么得
- 男人吃什么水果好
- 看对方微博主页对方知道吗 浏览微博对方知道吗
- 男人喝可乐好吗
- 信鸽的冬管
- 抖音里显示在连线是什么意思 抖音显示对方在连线是什么意思
- 微信通话显示对方忙是什么原因
- 江原道粉底液真假对比
