<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        MySQLAuditPluginnowavailableinPerconaServer5.5and5_MySQL

        來源:懂視網 責編:小采 時間:2020-11-09 19:15:12
        文檔

        MySQLAuditPluginnowavailableinPerconaServer5.5and5_MySQL

        MySQLAuditPluginnowavailableinPerconaServer5.5and5_MySQL:The newPercona Server 5.5.37-35.0andPercona Server 5.6.17-65.0-56, announced yesterday (May 6), both include the open source version of the MySQL Audit Plugin. The MySQL Audit Plugin is used to log all queries or connections (audit MySQL
        推薦度:
        導讀MySQLAuditPluginnowavailableinPerconaServer5.5and5_MySQL:The newPercona Server 5.5.37-35.0andPercona Server 5.6.17-65.0-56, announced yesterday (May 6), both include the open source version of the MySQL Audit Plugin. The MySQL Audit Plugin is used to log all queries or connections (audit MySQL
        The MySQL Audit Plugin is now available for free in Percona ServerThe newPercona Server 5.5.37-35.0andPercona Server 5.6.17-65.0-56, announced yesterday (May 6), both include the open source version of the MySQL Audit Plugin. The MySQL Audit Plugin is used to log all queries or connections (“audit” MySQL usage). Until yesterday’s release, the MySQL Audit Plugin was only available inMySQL Enterprise.

        Logging all MySQL usage is very important for a number of applications, for example:

      1. Required: applications which deals with sensitive data (credit cards, medical records, etc); required for security compliances (i.e. HIPAA)
      2. Very helpful: multi-tenants applications or MySQL as a service; MySQL administrators can audit the MySQL usage from the security and performance standpoint
      3. Very helpful: investigating and troubleshooting; it is great to have a full log ofall queries, which can help a lot for troubleshooting of MySQL and even for performance audit.
      4. Originally, the only “easy” option was toenable general log. (Other options included using binary logs which does not include select queries or enabling queries “trace” in the application or MySQL connector). However, logging all queries using a general log may dramatically decrease performance in the highly loaded MySQL applications: Aleksandr Kuzminsky published a benchmark in 2009 to showthe overhead of MySQL general and slow log. The main benefit of MySQL Log Audit plugin is that it logs all queriesasynchronously(can be changed in the config). I’ve decided to try the new audit plugin in Percona Server and measure the performance impact of the new plugin compared to enabling the general log for the CPU bound applications.

        How to start with MySQL Audit Plugin

        First, we will need to enable (or “install”) MySQL audit plugin asdecribed in the doc:

        mysql> select version();+-------------+| version() |+-------------+| 5.5.37-35.0 |+-------------+1 row in set (0.00 sec)mysql> INSTALL PLUGIN audit_log SONAME 'audit_log.so';Query OK, 0 rows affected (0.00 sec)

        mysql>selectversion();

        +-------------+

        |version() |

        +-------------+

        |5.5.37-35.0

        +-------------+

        1rowinset(0.00

        mysql>INSTALL PLUGINaudit_logSONAME'audit_log.so';

        QueryOK,0rowsaffected

        Now can see all MySQL audit plugin options:

        mysql> show global variables like '%audit%';+--------------------------+--------------+| Variable_name| Value|+--------------------------+--------------+| audit_log_buffer_size| 1048576|| audit_log_file | audit.log|| audit_log_flush| OFF|| audit_log_format | OLD|| audit_log_policy | ALL|| audit_log_rotate_on_size | 0|| audit_log_rotations| 0|| audit_log_strategy | ASYNCHRONOUS |+--------------------------+--------------+8 rows in set (0.00 sec)

        mysql>showglobalvariableslike'%audit%';

        +--------------------------+--------------+

        |Variable_name |Value |

        +--------------------------+--------------+

        |audit_log_buffer_size |1048576 |

        |audit_log_file |audit.log |

        |audit_log_flush |OFF |

        |audit_log_format |OLD |

        |audit_log_policy |ALL |

        |audit_log_rotate_on_size|0 |

        |audit_log_rotations |0 |

        |audit_log_strategy |

        +--------------------------+--------------+

        8rowsinset(0.00

        There are a bunch of options we can tweak here, the most important for MySQL performance are:

      5. audit_log_buffer_size; this buffer is used to cache the queries (for asynchronous operation).
      6. audit_log_strategy; All options are listed in the documentation page:
      7. ValueMeaning
        ASYNCHRONOUSLog asynchronously, wait for space in output buffer
        PERFORMANCELog asynchronously, drop request if insufficient space in output buffer
        SEMISYNCHRONOUSLog synchronously, permit caching by operating system
        SYNCHRONOUSLog synchronously, call sync() after each request

        The most useful option in my mind is ASYNCHRONOUS, providing us with good balance between performance and not loosing transactions if the output buffer is not large enough.

      8. audit_log_policy; we can log all queries or MySQL logins only (very useful if we only need to audit MySQL connections)
      9. Open Source Audit Plugin in MySQL Community server

        You can also use Percona Open Source version of Audit Plugin in MySQL community version (5.5.37 and 5.6.17). Simply download the linux tarball of Percona Server and copy the audit_log.so to your MySQL plugin dir.

        Find plugin dir:

        mysql> show global variables like '%plugin%';+---------------+------------------------------+| Variable_name | Value|+---------------+------------------------------+| plugin_dir| /usr/local/mysql/lib/plugin/ |+---------------+------------------------------+1 row in set (0.00 sec)

        mysql>showglobalvariableslike'%plugin%';

        +---------------+------------------------------+

        |Variable_name|Value |

        +---------------+------------------------------+

        |plugin_dir |/usr/local/mysql/lib/plugin/

        +---------------+------------------------------+

        1rowinset(0.00

        Copy the file:

        # cp audit_log.so /usr/local/mysql/lib/plugin/

        # cp audit_log.so /usr/local/mysql/lib/plugin/

        Install plugin:

        Server version: 5.5.37 MySQL Community Server (GPL)mysql> INSTALL PLUGIN audit_log SONAME 'audit_log.so';Query OK, 0 rows affected (0.00 sec)Server version: 5.6.17 MySQL Community Server (GPL)mysql> INSTALL PLUGIN audit_log SONAME 'audit_log.so';Query OK, 0 rows affected (0.00 sec)

        Serverversion:5.5.37MySQLCommunityServer(GPL)

        mysql>INSTALLPLUGINaudit_logSONAME'audit_log.so';

        QueryOK,0rowsaffected(0.00sec)

        Serverversion:5.6.17MySQLCommunityServer(GPL)

        mysql>INSTALLPLUGINaudit_logSONAME'audit_log.so';

        QueryOK,0rowsaffected(0.00sec)

        Using MySQL audit plugin

        When plugin is enabled, it will log entries in audit.log file in XML format. Example:

        "NAME"="Audit"

        "RECORD"="1_2014-04-30T00:04:42"

        "TIMESTAMP"="2014-04-30T00:04:42 UTC"

        "MYSQL_VERSION"="5.5.37-35.0"

        "STARTUP_OPTIONS"="--basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/lib/mysql/localhost.localdomain.pid --socket=/var/lib/mysql/mysql.sock"

        "OS_VERSION"="x86_64-Linux",

        /> "NAME"="Query"

        "RECORD"="2_2014-04-30T00:04:42"

        "TIMESTAMP"="2014-04-30T00:04:42 UTC"

        "COMMAND_CLASS"="install_plugin"

        "CONNECTION_ID"="1"

        "STATUS"="0"

        "SQLTEXT"="INSTALL PLUGIN audit_log SONAME 'audit_log.so'"

        "USER"="root[root] @ localhost []"

        "HOST"="localhost"

        "OS_USER"="" "IP"=""/> "NAME"="Query"

        "RECORD"="3_2014-04-30T00:04:42"

        "TIMESTAMP"="2014-04-30T00:05:07 UTC"

        "COMMAND_CLASS"="show_variables"

        "CONNECTION_ID"="1"

        "STATUS"="0"

        "SQLTEXT"="show global variables like '%audit%'"

        "USER"="root[root] @ localhost []"

        "HOST"="localhost"

        "OS_USER"="" "IP"=""/>

        "NAME"="Query"

        "RECORD"="10_2014-04-30T00:04:42"

        "TIMESTAMP"="2014-04-30T12:33:20 UTC"

        "COMMAND_CLASS"="grant"

        "CONNECTION_ID"="2"

        "STATUS"="0"

        "SQLTEXT"="grant all on sbtest.* to sb@localhost identified by 'sb'"

        "USER"="root[root] @ localhost []"

        "HOST"="localhost"

        "OS_USER"="" "IP"=""/> "NAME"="Connect"

        "RECORD"="11_2014-04-30T00:04:42"

        "TIMESTAMP"="2014-04-30T12:34:53 UTC"

        "CONNECTION_ID"="3"

        "STATUS"="0" "USER"="sb"

        "PRIV_USER"="sb"

        "OS_LOGIN"=""

        "PROXY_USER"=""

        "HOST"="localhost"

        "IP"=""

        "DB"="sbtest"

        />"RECORD"="1292_2014-04-30T00:04:42"

        "TIMESTAMP"="2014-04-30T12:45:07 UTC"

        "COMMAND_CLASS"="select"

        "CONNECTION_ID"="32"

        "STATUS"="1146"

        "SQLTEXT"="SELECT pad FROM sbtest8 WHERE id=5036031"

        "USER"="sb[sb] @ localhost []"

        "HOST"="localhost"

        "OS_USER"="""IP"=""/>

        Important notes:

      10. As all queries will be logged here, the passwords from “GRANT” will also be saved in clear text (as you can see above). It is very important to secure the file on disk.
      11. The file can grow very large on disk:
      12. ls -lah /var/lib/mysql/audit.log-rw-rw---- 1 mysql mysql 7.1G May 4 07:30 /var/lib/mysql/audit.log

        ls-lah/var/lib/mysql/audit.log

        -rw-rw----1mysqlmysql7.1GMay407:30/var/lib/mysql/audit.log

        Searching the Audit Log entries

        MySQL utilities provide a useful tool, mysqlauditgrep, to search / grep the logs file. Unfortunately, I was not able to make it work (tried both v. 1.3 and v 1.4) with audit plugin format created by Percona server. According tothis bug it can’t parse the “new” audit format. In my case, mysqlauditgrep will return a parsing error when I use the default format and returned no results when I set the “audit_log_format=NEW”. It will be nice to use the mysqlauditgrep as it looks like a very powerful tool, but for now our searching options are limited to conventional linux grep (which is not very easy for XML documents) or custom application to parse/search XML.

        Performance overhead of Audit Log Plugin and General Log

        Finally, I wanted to measure the overhead of the Audit Log Plugin compared to General Log. I did a quick benchmark withsysbenchOLTP test (CPU bound workload) with 4 modes:

        1. Audit Plugin disabled (to measure baseline)
        2. Audit Plugin enabled and logs all queries
        3. Audit Plugin enabled and logs only logins
        4. General Log enabled, Audit Plugin disabled

        Here are the results:

        TestOverhead
        Plugin + audit_log_policy = ALL~15% overhead
        Plugin + audit_log_policy = LOGINS~0% overhead (sysbench only connects once, so there may be bigger overhead here)
        General_log~62% overhead

        As we can see here, audit log is not free from overhead, however, it is much smaller than enabling general_log to log all and every query. Those are quick benchmark results and more tests are need for more accurate measurements. Also, as always, your milage can vary.

        Nice to have features

        What I would love to have for audit plugin is the ability to log only some specific actions. For example, only log activity from a specific user or access to a specific table (i.e. a table with a sensitive data), etc. This will give more control and less overhead (=better performance).

        Conclusion

        The MySQL Audit Plugin is a great feature – it is a valuable tool for MySQL security and performance audits. The performance overhead may be a concern for a highly loaded systems, however, it looks reasonable and is much better than using general log to log all queries.

        If you use general log or any other audit plugins, please share your experience in the comments.

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        MySQLAuditPluginnowavailableinPerconaServer5.5and5_MySQL

        MySQLAuditPluginnowavailableinPerconaServer5.5and5_MySQL:The newPercona Server 5.5.37-35.0andPercona Server 5.6.17-65.0-56, announced yesterday (May 6), both include the open source version of the MySQL Audit Plugin. The MySQL Audit Plugin is used to log all queries or connections (audit MySQL
        推薦度:
        標簽: and now mysql
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 一区在线免费观看| 久久亚洲精品高潮综合色a片| 九九九精品视频免费| 国产麻豆剧传媒精品国产免费 | 国产亚洲精久久久久久无码| 一级毛片视频免费观看| 亚洲精品无码久久毛片| 一区二区三区在线免费观看视频| 亚洲精品无码专区久久同性男| 国产精品玖玖美女张开腿让男人桶爽免费看| 免费v片在线观看无遮挡| 九九九国产精品成人免费视频| 亚洲乱色熟女一区二区三区丝袜| 免费无码作爱视频| 亚洲精品mv在线观看| 18禁超污无遮挡无码免费网站国产 | 亚洲黄色中文字幕| 免费观看美女用震蛋喷水的视频| 亚洲人成网站色在线观看| 在线观看免费大黄网站| 日本永久免费a∨在线视频| 在线亚洲97se亚洲综合在线| 免费一级毛片无毒不卡| 亚洲理论在线观看| 日韩免费在线观看| 99在线视频免费观看| 亚洲美女免费视频| 在线成人a毛片免费播放| 一级毛片大全免费播放| 亚洲激情视频在线观看| 在线观看免费大黄网站| 国产免费黄色无码视频| 亚洲视屏在线观看| 国产a级特黄的片子视频免费| 久久WWW免费人成—看片| 亚洲婷婷综合色高清在线| 国产99视频免费精品是看6| 日本免费A级毛一片| 亚洲一区二区三区在线观看网站| 亚洲精品国产高清嫩草影院| 国产精品1024永久免费视频 |