日本免费全黄少妇一区二区三区-高清无码一区二区三区四区-欧美中文字幕日韩在线观看-国产福利诱惑在线网站-国产中文字幕一区在线-亚洲欧美精品日韩一区-久久国产精品国产精品国产-国产精久久久久久一区二区三区-欧美亚洲国产精品久久久久

利用logrotate對MySQL日志進行輪轉(zhuǎn)( 二 )


從上面我們可以知道,這個默認的配置文件將讀取目錄/etc/logrotate.d,所以我們只要把自己寫的配置文件放到該目錄下即可 。
MySQL本省提供了一個rotate的參考配置文件,在support-files目錄下,文件名為mysql-log-rotate,內(nèi)容如下:
雙擊代碼全選

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/null
then
/opt/mysql/bin/mysqladmin flush-logs
fi
endscript
}
logrotate常見選項:

利用logrotate對MySQL日志進行輪轉(zhuǎn)



我們只要根據(jù)自己的需要,修改相應配置即可,下面是一個例子:
1)創(chuàng)建MySQL root密碼文件
vi /root/.my.cnf
雙擊代碼全選

1
2
3
[mysqladmin]
password = ***
user= root
chmod 600 /root/.my.cnf
2)把mysql-log-rotate拷貝至/etc/logrotate.d目錄下,修改其內(nèi)容為:
雙擊代碼全選

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
}

推薦閱讀