当前位置:网站首页>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 &
边栏推荐
- Label exchange experiment
- windows下Redis-cluster集群搭建
- [Business Research Report] top ten trends of science and technology and it in 2022 - with download link
- [groovy] closure (Introduction to closure class closure | closure parametertypes and maximumnumberofparameters member usage)
- Neural networks and deep learning Chapter 6: Circular neural networks reading questions
- Solution of circular dependency
- Leetcode hot topic Hot 100 day 33: "subset"
- 775 Div.1 B. integral array mathematics
- 可观测|时序数据降采样在Prometheus实践复盘
- [AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator
猜你喜欢
An article takes you to thoroughly understand descriptors
AutoCAD - feature matching
[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator
[groovy] closure (closure as function parameter | code example)
Introduce Hamming distance and calculation examples
自动语音识别(ASR)研究综述
10 programming habits that web developers should develop
windows下Redis-cluster集群搭建
[Business Research Report] Research Report on male consumption trends in other economic times -- with download link
Special information | finance, accounting, audit - 22.1.23
随机推荐
Hypothesis testing -- learning notes of Chapter 8 of probability theory and mathematical statistics
Introduce Hamming distance and calculation examples
2022-2028 global and Chinese FPGA prototype system Market Research Report
次小生成树
How can CIOs use business analysis to build business value?
3 minutes learn to create Google account and email detailed tutorial!
Live broadcast preview | container service ack elasticity prediction best practice
Flutter 小技巧之 ListView 和 PageView 的各种花式嵌套
The difference between bundle, chunk and module
Use assimp library to read MTL file data
Construction d'un Cluster redis sous Windows
Raki's notes on reading paper: code and named entity recognition in stackoverflow
Inline built-in function
Introduction to JVM principle and process
AutoCAD - Document Management
Wenet: E2E speech recognition tool for industrial implementation
Decryption function calculates "task state and lifecycle management" of asynchronous task capability
Download the details and sequence of the original data access from the ENA database in EBI
SQL set operation
[groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)