MySQL8.0データベース監査

CentOS 7.6 では MySQL 8.0.28 がインストールされます。
データベース監査はデータベース セキュリティのカテゴリに分類されます。

シリアルナンバー データベースのセキュリティ
1 データベース監査
2 データベースファイアウォール
3 データベースの暗号化
4 データの非感作化
5 データベースの脆弱性スキャン
6 データベースのセキュリティ運用・保守

背景

  1. アクティブなセキュリティ保護: 攻撃の発生から発見までの時間を短縮します。
  2. 法的に義務付けられている: 少なくとも 180 日間のログ保存。

プラグイン

  1. 公式エンタープライズ版
  2. ペルコナ MySQL
  3. MariaDB 監査プラグイン
  4. McAfee 監査プラグイン(MySQL 8.0 をサポート)

マカフィー監査プラグイン

sysbench ストレス テストを使用すると、監査を有効にした後、約 25% のパフォーマンスが低下します。

ダウンロードパス

ドキュメントパス

インストール

# 解压
unzip audit-plugin-mysql-8.0-1.1.12-999-linux-x86_64.zip

# 將插件拷贝到 MySQL 的 plugin 下
cp /root/audit-plugin-mysql-8.0-1.1.12-999/lib/libaudit_plugin.so /usr/lib64/mysql/plugin/
chown -R mysql.mysql /usr/lib64/mysql/plugin/libaudit_plugin.so
chmod +x /usr/lib64/mysql/plugin/libaudit_plugin.so

# 连接 MySQL,加载插件
mysql> INSTALL PLUGIN AUDIT SONAME 'libaudit_plugin.so';
Query OK, 0 rows affected (5.97 sec)

mysql> show global status like 'AUDIT_version';
+---------------+------------+
| Variable_name | Value      |
+---------------+------------+
| Audit_version | 1.1.12-999 |
+---------------+------------+
1 row in set (0.01 sec)

# 开启审计
mysql> set global audit_json_file=ON;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like 'audit_json_file';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| audit_json_file | ON    |
+-----------------+-------+
1 row in set (0.01 sec)

# 为了重启能生效,写入到 /etc/my.cnf 中
[mysqld]
audit_json_file=on
plugin-load=AUDIT=libaudit_plugin.so

data_dir(/var/lib/mysql)デフォルトでは、次のパスにファイルmysql-audit.json生成されます。

スイッチログ

mv mysql-audit.json mysql-audit.json.`date +%F`
mysql -e 'set global audit_json_file_flush=on;'

トレースログ

tail -f -n 20 mysql-audit.json | gerp "关键词"

おすすめ

転載: blog.csdn.net/qq_45594962/article/details/127051360