当前位置:网站首页>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 &
边栏推荐
- Special information | real estate and office buildings - 22.1.9
- 3 minutes learn to create Google account and email detailed tutorial!
- 中国聚氨酯硬泡市场调研与投资预测报告(2022版)
- SQL set operation
- 中国溶聚丁苯橡胶(SSBR)行业研究与预测报告(2022版)
- 解密函数计算异步任务能力之「任务的状态及生命周期管理」
- Cookie learning diary 1
- 中国艾草行业研究与投资前景预测报告(2022版)
- Chapter 6 text processing tools for shell programming (awk)
- Wenet: E2E speech recognition tool for industrial implementation
猜你喜欢
2022-2028 global and Chinese virtual data storage Market Research Report
QT Bluetooth: a class for searching Bluetooth devices -- qbluetooth devicediscoveryagent
Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
windows下Redis-cluster集群搭建
Advanced length of redis -- deletion strategy, master-slave replication, sentinel mode
[groovy] closure (closure as function parameter | code example)
On-off and on-off of quality system construction
Introduction to JVM principle and process
Special information | real estate and office buildings - 22.1.9
Observable time series data downsampling practice in Prometheus
随机推荐
You Li takes you to talk about C language 7 (define constants and macros)
English topic assignment (26)
[groovy] closure (closure as function parameter | code example)
flutter 对象和列表
Wan broadband access technology V EPON Technology
自动语音识别(ASR)研究综述
中国金刚烷行业研究与投资预测报告(2022版)
Interface joint commissioning test script optimization V5.0 (end)
Managed service network: application architecture evolution in the cloud native Era
AutoCAD - workspace settings
Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 006 unity toolbar
【acwing】528. cheese
2021 electrician cup (the 12th "China Society of electrical engineering Cup" National Undergraduate electrician mathematical modeling) detailed ideas + codes + references
Data security -- 14 -- Analysis of privacy protection governance
Matplotlib draws three-dimensional scatter and surface graphs
2021 Higher Education Club Cup mathematical modeling national tournament ABCD problem - problem solving ideas
Invalid bound statement (not found) in idea -- problem solving
Chapter 6 text processing tools for shell programming (awk)
AutoCAD - isometric annotation
次小生成树