当前位置:网站首页>mysql審計日志歸檔
mysql審計日志歸檔
2022-07-05 04:49:00 【huryer】
mysql審計日志歸檔
1、開啟審計日志
# 啟動審計,在mysql中執行命令:
set global general_log=on;
set global log_timestamps=SYSTEM;
set global general_log_file='db-1.log';
2、審計日志歸檔
創建歸檔備份目錄
# 創建歸檔備份目錄
mkdir -p /data/backup/audit
cd /data/backup/audit
創建審計日志歸檔脚本
vim mysql_aud_backup.sh
脚本內容如下:
#!/bin/bash
# mysql審計日志歸檔脚本
# 保留最近30天審計日志
# crontab -l
# 0 1 * * * nohup sh /data/backup/audit/mysql_aud_backup.sh &
export PATH=.:$PATH:/usr/local/mysql-5.7.34-el7-x86_64/bin
# 設置日志文件路徑
aud_folder=/data/mysql/data
backup_folder=/data/backup/audit
# 指定審計日志文件名
fn=db-1.log
dt=$(date +%Y%m%d)
# 切換到審計日志路徑
cd $aud_folder
# 歸檔審計日志
mv $fn $fn.$dt
mysqladmin flush-logs -u root -p'my_sql_pwd'
mv $fn.$dt $backup_folder/
# 保留30天內的審計日志
find $backup_folder/ -mtime +30 -name "$fn.*" |xargs rm -f
添加可執行權限
# 添加可執行權限
chmod +x mysql_aud_backup.sh
3、添加計劃任務
# 添加計劃任務
crontab -e
0 1 * * * nohup sh /data/backup/audit/mysql_aud_backup.sh &
边栏推荐
- windows下Redis-cluster集群搭建
- Séparation et combinaison de la construction du système qualité
- Neural networks and deep learning Chapter 6: Circular neural networks reading questions
- [groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)
- Matplotlib draws three-dimensional scatter and surface graphs
- An article takes you to thoroughly understand descriptors
- Interface joint commissioning test script optimization V5.0 (end)
- 2021 Higher Education Club Cup mathematical modeling national tournament ABCD problem - problem solving ideas
- 数论函数及其求和 待更新
- 程序员应该怎么学数学
猜你喜欢

Official announcement! The third cloud native programming challenge is officially launched!

Observable time series data downsampling practice in Prometheus

Live broadcast preview | container service ack elasticity prediction best practice
![[groovy] closure (closure call is associated with call method | call () method is defined in interface | call () method is defined in class | code example)](/img/03/329adb314606f29c8a4cb2260e84c8.jpg)
[groovy] closure (closure call is associated with call method | call () method is defined in interface | call () method is defined in class | code example)

Managed service network: application architecture evolution in the cloud native Era

AutoCAD - Center zoom

AutoCAD - workspace settings

Number theoretic function and its summation to be updated

10 programming habits that web developers should develop

Understand encodefloatrgba and decodefloatrgba
随机推荐
2022 thinking of mathematical modeling D problem of American college students / analysis of 2022 American competition D problem
Neural network and deep learning Chapter 1: introduction reading questions
AutoCAD - Document Management
Introduction to JVM principle and process
[Business Research Report] top ten trends of science and technology and it in 2022 - with download link
Function overloading
windows下Redis-cluster集群搭建
Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 006 unity toolbar
The remainder operation is a hash function
#775 Div.1 C. Tyler and Strings 组合数学
Discussion on the dimension of confrontation subspace
Leetcode hot topic Hot 100 day 33: "subset"
[groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)
Autocad-- Real Time zoom
Flink cluster configuration
中国针状焦行业发展研究与投资价值报告(2022版)
[groovy] closure (Introduction to closure class closure | closure parametertypes and maximumnumberofparameters member usage)
Error statuslogger log4j2 could not find a logging implementation
Invalid bound statement (not found) in idea -- problem solving
Rip notes [rip message security authentication, increase of rip interface measurement]