当前位置:网站首页>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 &
边栏推荐
- 取余操作是一个哈希函数
- CUDA Programming atomic operation atomicadd reports error err:msb3721, return code 1
- Data security -- 14 -- Analysis of privacy protection governance
- Debug insights
- [groovy] closure (closure call is associated with call method | call () method is defined in interface | call () method is defined in class | code example)
- CSDN正文自动生成目录
- 775 Div.1 B. integral array mathematics
- AutoCAD - isometric annotation
- Managed service network: application architecture evolution in the cloud native Era
- Flutter tips: various fancy nesting of listview and pageview
猜你喜欢
Wan broadband access technology V EPON Technology
Live broadcast preview | container service ack elasticity prediction best practice
2022-2028 global and Chinese video coding and transcoding Market Research Report
SQL set operation
XSS injection
Number theoretic function and its summation to be updated
xss注入
【Leetcode】1352. 最后 K 个数的乘积
AutoCAD - isometric annotation
【acwing】240. food chain
随机推荐
2022 thinking of mathematical modeling a problem of American college students / analysis of 2022 American competition a problem
Thematic information | carbon, carbon neutrality, low carbon, carbon emissions - 22.1.9
Solutions and answers for the 2021 Shenzhen cup
AutoCAD - stretching
Wan broadband access technology V EPON Technology
QT Bluetooth: a class for searching Bluetooth devices -- qbluetooth devicediscoveryagent
Matplotlib draws three-dimensional scatter and surface graphs
[groovy] closure (closure call | closure default parameter it | code example)
Flink cluster configuration
质量体系建设之路的分分合合
PostgreSQL 超越 MySQL,“世界上最好的编程语言”薪水偏低
Chapter 6 text processing tools for shell programming (awk)
Flink集群配置
2022 U.S. college students' mathematical modeling e problem ideas / 2022 U.S. game e problem analysis
中国金刚烷行业研究与投资预测报告(2022版)
windows下Redis-cluster集群搭建
[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator
Raki's notes on reading paper: code and named entity recognition in stackoverflow
[groovy] closure (closure parameter binding | curry function | rcurry function | ncurry function | code example)
The 22nd Spring Festival Gala, an immersive stage for the yuan universe to shine into reality