当前位置:网站首页>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 &
边栏推荐
- Pointer function (basic)
- A survey of automatic speech recognition (ASR) research
- Is $20billion a little less? Cisco is interested in Splunk?
- [groovy] closure (Introduction to closure class closure | closure parametertypes and maximumnumberofparameters member usage)
- Rip notes [rip message security authentication, increase of rip interface measurement]
- Difference between singleton and factory pattern
- 49 pictures and 26 questions explain in detail what is WiFi?
- JMeter -- distributed pressure measurement
- AutoCAD - scaling
- Flutter 小技巧之 ListView 和 PageView 的各种花式嵌套
猜你喜欢
SQL set operation
PostgreSQL 超越 MySQL,“世界上最好的编程语言”薪水偏低
Decryption function calculates "task state and lifecycle management" of asynchronous task capability
Thematic information | carbon, carbon neutrality, low carbon, carbon emissions - 22.1.9
[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator
A survey of automatic speech recognition (ASR) research
WeNet:面向工业落地的E2E语音识别工具
[groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)
[groovy] closure (Introduction to closure class closure | closure parametertypes and maximumnumberofparameters member usage)
Raki's notes on reading paper: code and named entity recognition in stackoverflow
随机推荐
Observable time series data downsampling practice in Prometheus
2022-2028 global and Chinese virtual data storage Market Research Report
XSS injection
Neural network and deep learning Chapter 1: introduction reading questions
Data security -- 14 -- Analysis of privacy protection governance
Detailed introduction of OSPF header message
Wan broadband access technology V EPON Technology
MySQL in-depth learning - index creation and deletion, index design principles, index failure scenarios, query optimization, index push down ICP
包 类 包的作用域
AutoCAD - graphic input and output
Leetcode 222 number of nodes of complete binary tree
AutoCAD - Center zoom
Key review route of probability theory and mathematical statistics examination
xss注入
Is $20billion a little less? Cisco is interested in Splunk?
775 Div.1 B. integral array mathematics
2021 higher education social cup mathematical modeling national tournament ABCD questions - problem solving ideas - Mathematical Modeling
中国针状焦行业发展研究与投资价值报告(2022版)
[groovy] closure (Introduction to closure class closure | closure parametertypes and maximumnumberofparameters member usage)
Practice | mobile end practice