审计日志插件用于记录MySQL服务器活动信息。默认情况下,被设置成记录所有事件日志。这是可以配置的,改变记录信息类型和策略,避免不必要的资源浪费。
如果审计日志插件只是用来监视访问数据库服务器,那么只有登录事件需要记录的。文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-how-to-record-login-events/
mysqlauditadmin 工具用来维护管理审计日志的。文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-how-to-record-login-events/
实例
shell> mysqlauditadmin --server=root@localhost:3306 policy --value=LOGINS \ --show-options # # Showing options before command. # # Audit Log Variables and Options # +---------------------------+---------------+ | Variable_name | Value | +---------------------------+---------------+ | audit_log_buffer_size | 1048576 | | audit_log_file | audit.log | | audit_log_flush | OFF | | audit_log_policy | ALL | | audit_log_rotate_on_size | 0 | | audit_log_strategy | ASYNCHRONOUS | +---------------------------+---------------+ # # Executing POLICY command. # # Showing options after command. # # Audit Log Variables and Options # +---------------------------+---------------+ | Variable_name | Value | +---------------------------+---------------+ | audit_log_buffer_size | 1048576 | | audit_log_file | audit.log | | audit_log_flush | OFF | | audit_log_policy | LOGINS | | audit_log_rotate_on_size | 0 | | audit_log_strategy | ASYNCHRONOUS | +---------------------------+---------------+
要改变审计日志记录的事件类型,必需改变策略。有哪些策略可以看看前面的文件。文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-how-to-record-login-events/
在上面的例子中,将策略值改为LOGINS,只记录登录日志。其他值有: ALL (记录所有事件), QUERIES (只记录查询事件), NONE (禁用日志记录), DEFAULT (使用默认策略)。文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-how-to-record-login-events/
权限
对mysql数据库要有SELECT权限。为了查看日志文件,需要能访问到日志文件的权限。文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-how-to-record-login-events/ 文章源自运维生存时间-https://www.ttlsa.com/mysql/mysql-utilities-how-to-record-login-events/
评论