当前位置:网站首页>mysql审计日志归档
mysql审计日志归档
2022-07-05 04:48: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 &
边栏推荐
- Interface joint commissioning test script optimization V5.0 (end)
- AutoCAD - workspace settings
- Solution of circular dependency
- 包 类 包的作用域
- Neural networks and deep learning Chapter 6: Circular neural networks reading questions
- [Business Research Report] top ten trends of science and technology and it in 2022 - with download link
- Autocad-- Real Time zoom
- 质量体系建设之路的分分合合
- Data security -- 14 -- Analysis of privacy protection governance
- AutoCAD - Document Management
猜你喜欢

10 programming habits that web developers should develop

Wan broadband access technology V EPON Technology

可观测|时序数据降采样在Prometheus实践复盘

CSDN body auto generate directory

Setting up redis cluster cluster under Windows

Solution of circular dependency

计组笔记(1)——校验码、原补码乘除计算、浮点数计算

Looking at Chinese science and technology from the Winter Olympics: what is the mystery of the high-speed camera that the whole people thank?

On-off and on-off of quality system construction

The principle of attention mechanism and its application in seq2seq (bahadanau attention)
随机推荐
Interface joint commissioning test script optimization V5.0 (end)
AutoCAD - isometric annotation
Stage experience
Debug insights
2021 electrician Cup - high speed rail traction power supply system operation data analysis and equivalent modeling ideas + code
Mode in BST (binary tree & Notes on question brushing)
Key review route of probability theory and mathematical statistics examination
English topic assignment (27)
[crampon programming] lintcode decoding Encyclopedia - 872 termination process
Use assimp library to read MTL file data
直播預告 | 容器服務 ACK 彈性預測最佳實踐
[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator
Observable time series data downsampling practice in Prometheus
Chapter 6 text processing tools for shell programming (awk)
Solution of circular dependency
Live broadcast preview | container service ack elasticity prediction best practice
Neural networks and deep learning Chapter 5: convolutional neural networks reading questions
#775 Div.1 C. Tyler and Strings 组合数学
Neural networks and deep learning Chapter 2: machine learning overview reading questions
自动语音识别(ASR)研究综述