MySQL Shell:最佳DBA工具-如何使用MySQL Shell作为DBA的框架

mysql shell是mysql的新客户端。它理解标准和X协议。它还允许向服务器发送JS、Python或SQL命令。在本文中,我将向您展示如何首先配置shell,以获得MySQL良好的外观体验,并展示一些基本的命令和对象。在这个简短的概述之后,我将展示如何扩展shell,以及如何对其进行黑客攻击以在mysql shell中创建一个innotop克隆。这是一个带有额外说明的实况演示,演示期间和之后将共享代码。
这次谈话的目的也是向社区介绍如何破解shell,以及如何请求贡献和特性请求。

展开查看详情

1. 1 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 1/55

2. 2 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 2/55

3. 3 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ?   Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purpose only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied up in making purchasing decisions. The development, release and timing of any features or functionality described for Oracle´s product remains at the sole discretion of Oracle. file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 3/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

4. 4 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? about me - http://about.me/lefred Who am I ? file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 4/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

5. 5 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ?   Frédéric Descamps @lefred MySQL Evangelist Hacking MySQL since 3.23 devops believer living in Belgium 🇧🇪 http://lefred.be file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 5/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

6. 6 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? a new tool MySQL Shell file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 6/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

7. 7 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell The MySQL Shell is an interactive Javascript, Python, or SQL interface supporting development and administration for the MySQL Server and is a component of the MySQL Server. You can use the MySQL Shell to perform data queries and updates as well as various administration operations. file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 7/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

8. 8 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell (2) The MySQL Shell provides: file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 8/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

9. 9 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell (2) The MySQL Shell provides: Both Interactive and Batch operations file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 9/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

10. 10 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell (2) The MySQL Shell provides: Both Interactive and Batch operations Document and Relational Models file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 10/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

11. 11 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell (2) The MySQL Shell provides: Both Interactive and Batch operations Document and Relational Models CRUD Document and Relational APIs via scripting file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 11/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

12. 12 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell (2) The MySQL Shell provides: Both Interactive and Batch operations Document and Relational Models CRUD Document and Relational APIs via scripting Traditional Table, JSON, Tab Separated output results formats file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 12/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

13. 13 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell (2) The MySQL Shell provides: Both Interactive and Batch operations Document and Relational Models CRUD Document and Relational APIs via scripting Traditional Table, JSON, Tab Separated output results formats MySQL Standard and X Protocols file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 13/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

14. 14 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell (2) The MySQL Shell provides: Both Interactive and Batch operations Document and Relational Models CRUD Document and Relational APIs via scripting Traditional Table, JSON, Tab Separated output results formats MySQL Standard and X Protocols and more... file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 14/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

15. 15 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell and Python When using the python mode in the Shell, it's possible to use system modules (local). file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 15/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

16. 16 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell and Python (2) Of course this can be any type of modules: file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 16/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

17. 17 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell and Python (2) Of course this can be any type of modules: file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 17/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

18. 18 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? we want more ! Extending MySQL Shell file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 18/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

19. 19 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? Extending MySQL Shell Since 8.0.16, you have two different ways to extend the MySQL Shell: using the new Reporting Framework (>= 8.0.16) create your own modules to extend MySQL Shell 8.0 file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 19/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

20. 20 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell User-Defined Reports You can create reports that can be called ( ) one time or constantly refreshed ( ). Example for checking the : file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 20/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

21. 21 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell User-Defined Reports (2) This is a Python file ( ) installed in : It contains a definition and a registration: file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 21/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

22. 22 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? MySQL Shell User-Defined Reports (3) More info: https://lefred.be/content/using-the-new-mysql-shell-reporting-framework-to-monitor-innodb-cluster/ https://lefred.be/content/mysql-innodb-cluster-recovery-process-monitoring-with-the-mysql-shell-reporting-framework/ Sources of Examples: https://github.com/lefred/mysql-shell-udr Pull Requests welcome ! file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 22/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

23. 23 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? Create your own modules for MySQL Shell For calling some long statements or group of operations or sometimes to replace a missing functionality. file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 23/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

24. 24 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? Create your own modules for MySQL Shell For calling some long statements or group of operations or sometimes to replace a missing functionality. Recently, somebody pointed out that since the new DD it was not anymore possible to delete all routines for a specific schema. file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 24/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

25. 25 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? Create your own modules for MySQL Shell For calling some long statements or group of operations or sometimes to replace a missing functionality. Recently, somebody pointed out that since the new DD it was not anymore possible to delete all routines for a specific schema. Jesper explained recently how the MySQL Shell could help here see https://mysql.wisborg.dk/2018/12/02/mysql-8-drop-several- stored-events-procedures-or-functions/ file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 25/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

26. 26 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? Extending MySQL Shell file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 26/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

27. 27 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? Extending MySQL Shell file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 27/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

28. 28 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? Extending MySQL Shell Or for example, retrieve the expiration period of passwords (see https://lefred.be/content/mysql-when-will-the-password-of-my- users-expire/): file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 28/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.

29. 29 / 55 5/30/2019 Percona Live Austin 2019 - MySQL Shell : the best DBA tool ? Extending MySQL Shell Another example, retrieve the tables potentially fragmented (see https://lefred.be/content/overview-of-fragmented-mysql- innodb-tables/): file:///home/fred/ownCloud/Presentations/ORACLE/PerconaLive2019/MySQL Shell - Best DBA Tool/MySQL Day - MySQL Shell.html#1 29/55 Copyright @ 2019 Oracle and/or its affiliates. All rights reserved.