Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. |
MySQL Shell:
the daily tool
for devs
and admins
Vittorio Cioe
MySQL Sr. Sales Consultant
vittorio.cioe@oracle.com
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes 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
upon in making purchasing decisions. The development, release, and timing of any
features or functionality described for Oracle’s products remains at the sole discretion of
Oracle.
2
whoami
•Used MySQL since 2006
•Working at Oracle/MySQL since 2017, covering Eastern Europe
•Previously working in the Security and Digital Transformation
(API) space
•From Italy but based in Warsaw
•Love movies, travelling, cooking...
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Agenda
4
Intro: state of the dolphin
MySQL Shell overview
MySQL Shell and NoSQL: XDev API
MySQL Shell and HA: Admin API for InnoDB Cluster
Summary
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Intro:
State of the dolphin
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
#1 MySQL is the #1 database for
the web, used by 10 of the top
10 websites
6Oracle Confidential – Authorized Partner Internal Use Only
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Authorized Partner Internal Use Only 7
Most popular open source
relational database*
*according to db-engines.com
Most popular database
behind only Oracle DB*
*according to db-engines.com
By 2022, more than 70% of
new in-house applications
will be developed on an
Open Source RDBMS
By 2022, 50% of commercial
RDBMS instances will have
been converted to open
source DBs
MySQL Facts & Figures
#1 #2
70% 50%
Source: Gartner, State of Relational Open Source RDBMSs 2018 Source: Gartner, State of Relational Open Source RDBMSs 2018
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
MySQL Innovation: 5.7 -> 8.0
- 3x Better Performance
- Replication Enhancements
- Optimizer Cost Model
- JSON Support
- Improved Security
- Sys & Performance Schema
- GIS
MySQL 5.7
MySQL InnoDB Cluster
- MySQL Group Replication
- MySQL Router
- MySQL Shell
MySQL 8.0
- 2x Better Performance
- NoSQL Document Store
- JSON
- CTEs
- Window Functions
- Data Dictionary
- InnoDB
- Replication
- Roles
- Unicode
- GIS
2 Years in Development
400+ Worklogs
5000+ Bugs Fixed
500 New Tests
GA
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
MySQL Community
Edition
MySQL Enterprise
Edition
MySQL Database •MySQL Database
•Advanced Features
•Management Tools
•24x7 Support
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL shell overview
MySQLShell: Introduction
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
11
•Interactive multi-language console interface that supports
development and administration for the MySQLServer
•Canbe used to perform data queries or updates, and
administration operations:
Scriptable “DevOps” APIs
Unified Interface for MySQLDevelopers and DBAs:one tool!
•Intuitive and easy to use
1.0
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
12
•Supports MySQLServer
5.7
8.0
Supports MySQLServer 5.7 and
8.0
Higly recommended version!
Note: Upgrade to 8.0 right
awayif you’re still using 1.0
MySQLShell:
Versions
MySQLShell: Goal
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
13
•One tool for MySQLdevelopment and administrative
tasks
•Natural interface for all MySQLrelated ”DevOps”!
–Unified Interface for Developers and DBAs
•Intuitive, flexible and powerful
•Provides scripting with development and
administrative APIs
Copyright @ 2018 Oracle and/or its affiliates. All right
MySQL
Server 5.7
MySQL 8.0
Upgrade Checker
Prompt Themes
Auto Completion
&
Command History
MySQL
Server 8.0
Document Store
X DevAPI
InnoDB ClusterSQL CLI
Output Formats
(Table, JSON, Tabbed)
Batch Execution
JavaScript
Python
SQL
MySQLShell: Architecture
MySQLShell: Features
•Multi-language support
– JavaScript, Python and SQL
– Both interactive and batch operations MySQL
Developme
nt
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
15
MySQLShell: Features
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
16
Scripting
•Support for scripting in Python and JavaScript
•APIsfor MySQLDBs,Document Store, InnoDB cluster, Shell and
more
•Import any installed module (in Python)
•Execute scripts from
– Interactive REPLinterface (interactive interpreter)
– Directly from the commandline
•mysqlsh --py –e "print 'Hello world'"
– From Python, JS,SQLscriptfiles
MySQLShell: Features
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
17
Scripting – Globals
•session
– Assigned to the DBsession when the shell connects to
MySQL
– The MySQLsession used by the Shell in SQLmode
– Execute queries
mysql-js> session.query(“show status”);
MySQLShell: Features
Scripting – Examples
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
18
•Connect to myserver.foo.com
•Execute create_account.js with any extra arguments forwarded
to the script (sys.argv[])
•The script can use the session global variable to execute SQLin
the target server
$ mysqlsh root@myserver.foo.com –f create_account.js appuser@’192.168.%.%’
MySQLShell: Features
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
19
Other development APIs
•mysql
– mysql.getSession(), etc.
– Connects to MySQLserver using classic MySQL
protocol
– run SQLqueries
– mysqlx for Xprotocol sessions and XDevAPI
MySQLShell: Features
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
20
Other development APIs
•shell
– Programmatic access to most shellfeatures
– Configuration options (option)
– Password Manager API
– Pager API (pager)
– logging
– URI parsing
– Prompting for userinput
– Establish connections:
shell.connect(‘user@host:port’)
MySQLShell: Features
•Shell Utilities: util object
– Upgrade checker
•Verify whether instances are ready for upgrading to
MySQL8
– Import JSONdocuments
•From a file or standard input to a MySQLServer
•Supports importing to a collection orrelational table
mysql-js> util.checkForServerUpgrade(“root@localhost:3306”);
MySQL
Administrati
on
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
21
MySQLShell: Features
•API Command line integration
– New cmdline syntax to invoke built-in Shellcommands
– Requires minimal extra typing, quoting andescaping
– Supported objects: dba, cluster, shell,shell.options and
util
Syntax: mysqlsh [OPTIONS] [URI] --<object_name> <method_name> [argument_list]
$ mysqlsh root@myserver:33060 –- util import-json
~/Downloads/myData/data.json --collections=‘zip codes’ --schema=‘json_test’
MySQL
Administrati
on
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
22
MySQLShell: Features (DBA toolbox)
Customizable Prompts
•Display context information
•Custom/dynamic tags that react to context
– export PRODUCTION_SERVERS=192.168.42.16
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
23
MySQLShell: Features (DBA toolbox)
Customizable Prompts
•Sample prompt file:
– mysql-shell/share/mysqlsh/prompt/
•Customization instructions:
– mysql-shell/share/mysqlsh/prompt/README
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
24
MySQLShell: Features (DBA toolbox)
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
25
Secure Credential Manager
•MySQLserver passwords can be queried from a secure password
store
•Usesexisting OSnative password storage APIs
– Keychain (macOS)
– Credential Manager (Windows)
– MySQLlogin-path encrypted files (all)
•Optionally auto-save typed passwords (default will prompt)
•Or use APIto store programmatically
– shell.storeCredential("root@192.168.1.32","s3cr37!");
•Write your own password store backend
MySQLShell: Features (DBA toolbox)
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
26
History
•Typed command history
•Persisting disabled by default, enable with
– option history.autoSave=true
•Filter SQL statements that may contain
sensitiveinfo
– e.g. SETPASSWORD='my password'
– option history.sql.ignorePattern
MySQLShell: Features (DBA toolbox)
Pager
•PassSQLresults through an external screen paging
program
– pager less
– showstatus;
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
27
MySQLShell: Features (DBA toolbox)
Built-in Help
•Documentation for included APIs, shell commands,
SQL, etc.
•help keyword
– (wildcardsallowed)
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
28
Shell meets continuous automation
•Continuous automation frameworks provide mechanisms
for setup, configuration and management of MySQL
Server
•DBAcan automate operations by usingmodules.
•Classic example:
Ensure MySQLServer deployments use the latest available version
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
29
Shell meets continuous automation
Let’s use asan example using
MySQLShell upgrade checker:
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
30
service { ‘mysql’: ensure => latest, enable => true,
require => Package[‘mysql-server-community’], before => Exec [‘upgrade
checker’]
}
exec { “upgrade checker”:
command => “mysqlsh -- util check-for-server-upgrade { --user=root --
host=localhost --port=3306} --password=‘myPwd’”
require => Service[“mysqlsh”]
}
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Shell
and NoSQL:
XDev API
MySQLShell: Features
•Document and Relational models
– Supports the classic relational model
– Modern fluent APIfor the MySQLDocumentStore
•CRUDand Relational
– Supports the traditional Table results, aswell as
JSONor Tabseparated output
MySQL
Developme
nt
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
32
35 / 112
MySQL Document Store
Copyright @ 2018 Oracle and/or its affiliates. All right
MySQL Document Store: Architecture
Copyright @ 2018 Oracle and/or its affiliates. All right
MySQLShell: Features
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
35
Document Store – X DevAPI
•Support for MySQLDocument Store API
•Create collections
•Import JSONdumps
•Try out queries and write simple scripts interactively
•XDevAPI CRUDoperations
•SQL
MySQLShell: Features
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
36
Document Store – X DevAPI Examples
•Operations on collections:
– collection.add()
– collection.find()
– collection.remove()
– collection.modify()
– ...and much more..
•Operations on tables:
– table.insert()
– table.select()
– table.update()
– table.delete()
– ...and much more..
•Session Operations:
– session.create|drop.schema()
– session.StartTransaction()
– session.commit()|rollback()
– session.getSchemas()
– ...and much more..
•Operations on schemas:
– schema.getTable()
– schema.getCollection()
– schema.dropTable()
– schema.dropCollection()
– ...and much more..
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
MySQL Shell
and HA:
Admin API
for InnoDB Cluster
MySQLInnoDB Cluster:
Vision
“Asingleproduct— MySQL — withhigh availabilityand scaling features
bakedin;providingan integratedend-to-endsolution thatiseasy touse.”
– Engineering Team
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
38
MySQLInnoDB Cluster: Background
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
39
•High Availability: critical
factor
•Replication asa common
solution
•MySQLhas support for:
– Classic master-slave
replication
– DRBDS
– Other OSor VMsolutions…
Group Replication !
•Update-everywhere (m-m)
•Virtually synchronous
replication
•Automatic server fail-over
– Distributed recovery
– Group reconfiguration
•Powered by a GCS:
Implementation of Paxos
MySQLInnoDB Cluster: Background
•Challenging task
– Not easy to setup andmaintain
– Technical knowledge needed
– How to configure the
applications?
– How to integrate all the
components?
? ?
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
40
MySQLGroup Replication
InnoDB cluster
App Servers with
MySQL Router
MySQLShell
Setup,
Manage,
Orchestrate
Clients
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
41
MySQLShell: Features
•Administration API: AdminAPI
– Creation and Management of InnoDB
Clusters
– Hides the complexity of:
•Configuration
•Provisioning
•Orchestration
– Simple and straight-forward
– Doesn’t require MySQLexpertise
– Flexible, powerful and secure
– Available in both JavaScript andPython
MySQL
Administrati
on
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
42
MySQLShell: Features
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
43
AdminAPI - options
--cluster
• Prepares the Shell for managing the InnoDB cluster the target server
belongs to
•Automatically assigns the cluster global variable
--redirect-primary
• Connects the shell to the primary of the InnoDB cluster group, in case
the one we connect to is asecondary
--redirect-secondary
• Connects the shell to a secondary member of the InnoDB cluster group
MySQLShell: Features
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
44
AdminAPI - Create and Manage
•Deploy and manage InnoDBCuster:
– dba.configureInstance()
– dba.createCluster()
– dba.getCluster()
– dba.rebootClusterFromCompleteOutage()
– ...and much more...
•Manage InnoDBCuster:
– cluster.addInstance()
– cluster.removeInstance()
– cluster.rejoinInstance()
– cluster.status()
– ...and much more...
MySQLShell: Features
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
45
AdminAPI - Sandboxes
•Deploy and manage MySQL sandboxes:
– dba.deploySandboxInstance()
– dba.stopSandboxInstance()
– dba.startSandboxInstance()
– dba.deleteSandboxInstance()
– dba.killSandboxInstance()
Important: Sandbox instances are only suitable for testing
purposes!
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
Summary
Summary
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
47
•MySQLShell brings together developers andDBAs
• Unified interface: one tool!
• Development and Administration APIsand features
•MySQLInnoDB Cluster is THEbuilt-in HAsolution for MySQL:
• Full-stack: High Availability out-of-the-box
• Acces to data SQL + NoSQL
• Easyto use: usability asa topconcern
Resources
Copyright © 2018, Oracle and/or its affiliates. All rights
reserved. |
48
•MySQLShellUserguide:
– https://dev.mysql.com/doc/refman/en/mysql-shell.html
•MySQLInnoDB ClusterUserguide:
– http://dev.mysql.com/doc/refman/en/mysql-innodb-cluster-userguide.html
•APIsReference manuals
– JavaScript: https://dev.mysql.com/doc/dev/mysqlsh-api-javascript/
– Python: https://dev.mysql.com/doc/dev/mysqlsh-api-python/
•Blogging
– http://mysqlserverteam.com/category/high-availability
MySQL Shell: the daily tool for devs and admins. By Vittorio Cioe.

More Related Content

MySQL Shell: the daily tool for devs and admins. By Vittorio Cioe.

  • 1. Copyright © 2015, Oracle and/or its affiliates. All rights reserved. | MySQL Shell: the daily tool for devs and admins Vittorio Cioe MySQL Sr. Sales Consultant vittorio.cioe@oracle.com
  • 2. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes 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 upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. 2
  • 3. whoami •Used MySQL since 2006 •Working at Oracle/MySQL since 2017, covering Eastern Europe •Previously working in the Security and Digital Transformation (API) space •From Italy but based in Warsaw •Love movies, travelling, cooking... Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
  • 4. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Agenda 4 Intro: state of the dolphin MySQL Shell overview MySQL Shell and NoSQL: XDev API MySQL Shell and HA: Admin API for InnoDB Cluster Summary
  • 5. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Intro: State of the dolphin
  • 6. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | #1 MySQL is the #1 database for the web, used by 10 of the top 10 websites 6Oracle Confidential – Authorized Partner Internal Use Only
  • 7. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | Oracle Confidential – Authorized Partner Internal Use Only 7 Most popular open source relational database* *according to db-engines.com Most popular database behind only Oracle DB* *according to db-engines.com By 2022, more than 70% of new in-house applications will be developed on an Open Source RDBMS By 2022, 50% of commercial RDBMS instances will have been converted to open source DBs MySQL Facts & Figures #1 #2 70% 50% Source: Gartner, State of Relational Open Source RDBMSs 2018 Source: Gartner, State of Relational Open Source RDBMSs 2018
  • 8. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | MySQL Innovation: 5.7 -> 8.0 - 3x Better Performance - Replication Enhancements - Optimizer Cost Model - JSON Support - Improved Security - Sys & Performance Schema - GIS MySQL 5.7 MySQL InnoDB Cluster - MySQL Group Replication - MySQL Router - MySQL Shell MySQL 8.0 - 2x Better Performance - NoSQL Document Store - JSON - CTEs - Window Functions - Data Dictionary - InnoDB - Replication - Roles - Unicode - GIS 2 Years in Development 400+ Worklogs 5000+ Bugs Fixed 500 New Tests GA
  • 9. Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | MySQL Community Edition MySQL Enterprise Edition MySQL Database •MySQL Database •Advanced Features •Management Tools •24x7 Support
  • 10. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL shell overview
  • 11. MySQLShell: Introduction Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 11 •Interactive multi-language console interface that supports development and administration for the MySQLServer •Canbe used to perform data queries or updates, and administration operations: Scriptable “DevOps” APIs Unified Interface for MySQLDevelopers and DBAs:one tool! •Intuitive and easy to use
  • 12. 1.0 Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 12 •Supports MySQLServer 5.7 8.0 Supports MySQLServer 5.7 and 8.0 Higly recommended version! Note: Upgrade to 8.0 right awayif you’re still using 1.0 MySQLShell: Versions
  • 13. MySQLShell: Goal Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 13 •One tool for MySQLdevelopment and administrative tasks •Natural interface for all MySQLrelated ”DevOps”! –Unified Interface for Developers and DBAs •Intuitive, flexible and powerful •Provides scripting with development and administrative APIs
  • 14. Copyright @ 2018 Oracle and/or its affiliates. All right MySQL Server 5.7 MySQL 8.0 Upgrade Checker Prompt Themes Auto Completion & Command History MySQL Server 8.0 Document Store X DevAPI InnoDB ClusterSQL CLI Output Formats (Table, JSON, Tabbed) Batch Execution JavaScript Python SQL MySQLShell: Architecture
  • 15. MySQLShell: Features •Multi-language support – JavaScript, Python and SQL – Both interactive and batch operations MySQL Developme nt Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 15
  • 16. MySQLShell: Features Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 16 Scripting •Support for scripting in Python and JavaScript •APIsfor MySQLDBs,Document Store, InnoDB cluster, Shell and more •Import any installed module (in Python) •Execute scripts from – Interactive REPLinterface (interactive interpreter) – Directly from the commandline •mysqlsh --py –e "print 'Hello world'" – From Python, JS,SQLscriptfiles
  • 17. MySQLShell: Features Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 17 Scripting – Globals •session – Assigned to the DBsession when the shell connects to MySQL – The MySQLsession used by the Shell in SQLmode – Execute queries mysql-js> session.query(“show status”);
  • 18. MySQLShell: Features Scripting – Examples Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 18 •Connect to myserver.foo.com •Execute create_account.js with any extra arguments forwarded to the script (sys.argv[]) •The script can use the session global variable to execute SQLin the target server $ mysqlsh root@myserver.foo.com –f create_account.js appuser@’192.168.%.%’
  • 19. MySQLShell: Features Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 19 Other development APIs •mysql – mysql.getSession(), etc. – Connects to MySQLserver using classic MySQL protocol – run SQLqueries – mysqlx for Xprotocol sessions and XDevAPI
  • 20. MySQLShell: Features Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 20 Other development APIs •shell – Programmatic access to most shellfeatures – Configuration options (option) – Password Manager API – Pager API (pager) – logging – URI parsing – Prompting for userinput – Establish connections: shell.connect(‘user@host:port’)
  • 21. MySQLShell: Features •Shell Utilities: util object – Upgrade checker •Verify whether instances are ready for upgrading to MySQL8 – Import JSONdocuments •From a file or standard input to a MySQLServer •Supports importing to a collection orrelational table mysql-js> util.checkForServerUpgrade(“root@localhost:3306”); MySQL Administrati on Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 21
  • 22. MySQLShell: Features •API Command line integration – New cmdline syntax to invoke built-in Shellcommands – Requires minimal extra typing, quoting andescaping – Supported objects: dba, cluster, shell,shell.options and util Syntax: mysqlsh [OPTIONS] [URI] --<object_name> <method_name> [argument_list] $ mysqlsh root@myserver:33060 –- util import-json ~/Downloads/myData/data.json --collections=‘zip codes’ --schema=‘json_test’ MySQL Administrati on Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 22
  • 23. MySQLShell: Features (DBA toolbox) Customizable Prompts •Display context information •Custom/dynamic tags that react to context – export PRODUCTION_SERVERS=192.168.42.16 Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 23
  • 24. MySQLShell: Features (DBA toolbox) Customizable Prompts •Sample prompt file: – mysql-shell/share/mysqlsh/prompt/ •Customization instructions: – mysql-shell/share/mysqlsh/prompt/README Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 24
  • 25. MySQLShell: Features (DBA toolbox) Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 25 Secure Credential Manager •MySQLserver passwords can be queried from a secure password store •Usesexisting OSnative password storage APIs – Keychain (macOS) – Credential Manager (Windows) – MySQLlogin-path encrypted files (all) •Optionally auto-save typed passwords (default will prompt) •Or use APIto store programmatically – shell.storeCredential("root@192.168.1.32","s3cr37!"); •Write your own password store backend
  • 26. MySQLShell: Features (DBA toolbox) Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 26 History •Typed command history •Persisting disabled by default, enable with – option history.autoSave=true •Filter SQL statements that may contain sensitiveinfo – e.g. SETPASSWORD='my password' – option history.sql.ignorePattern
  • 27. MySQLShell: Features (DBA toolbox) Pager •PassSQLresults through an external screen paging program – pager less – showstatus; Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 27
  • 28. MySQLShell: Features (DBA toolbox) Built-in Help •Documentation for included APIs, shell commands, SQL, etc. •help keyword – (wildcardsallowed) Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 28
  • 29. Shell meets continuous automation •Continuous automation frameworks provide mechanisms for setup, configuration and management of MySQL Server •DBAcan automate operations by usingmodules. •Classic example: Ensure MySQLServer deployments use the latest available version Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 29
  • 30. Shell meets continuous automation Let’s use asan example using MySQLShell upgrade checker: Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 30 service { ‘mysql’: ensure => latest, enable => true, require => Package[‘mysql-server-community’], before => Exec [‘upgrade checker’] } exec { “upgrade checker”: command => “mysqlsh -- util check-for-server-upgrade { --user=root -- host=localhost --port=3306} --password=‘myPwd’” require => Service[“mysqlsh”] }
  • 31. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Shell and NoSQL: XDev API
  • 32. MySQLShell: Features •Document and Relational models – Supports the classic relational model – Modern fluent APIfor the MySQLDocumentStore •CRUDand Relational – Supports the traditional Table results, aswell as JSONor Tabseparated output MySQL Developme nt Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 32
  • 33. 35 / 112 MySQL Document Store Copyright @ 2018 Oracle and/or its affiliates. All right
  • 34. MySQL Document Store: Architecture Copyright @ 2018 Oracle and/or its affiliates. All right
  • 35. MySQLShell: Features Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 35 Document Store – X DevAPI •Support for MySQLDocument Store API •Create collections •Import JSONdumps •Try out queries and write simple scripts interactively •XDevAPI CRUDoperations •SQL
  • 36. MySQLShell: Features Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 36 Document Store – X DevAPI Examples •Operations on collections: – collection.add() – collection.find() – collection.remove() – collection.modify() – ...and much more.. •Operations on tables: – table.insert() – table.select() – table.update() – table.delete() – ...and much more.. •Session Operations: – session.create|drop.schema() – session.StartTransaction() – session.commit()|rollback() – session.getSchemas() – ...and much more.. •Operations on schemas: – schema.getTable() – schema.getCollection() – schema.dropTable() – schema.dropCollection() – ...and much more..
  • 37. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | MySQL Shell and HA: Admin API for InnoDB Cluster
  • 38. MySQLInnoDB Cluster: Vision “Asingleproduct— MySQL — withhigh availabilityand scaling features bakedin;providingan integratedend-to-endsolution thatiseasy touse.” – Engineering Team Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 38
  • 39. MySQLInnoDB Cluster: Background Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 39 •High Availability: critical factor •Replication asa common solution •MySQLhas support for: – Classic master-slave replication – DRBDS – Other OSor VMsolutions… Group Replication ! •Update-everywhere (m-m) •Virtually synchronous replication •Automatic server fail-over – Distributed recovery – Group reconfiguration •Powered by a GCS: Implementation of Paxos
  • 40. MySQLInnoDB Cluster: Background •Challenging task – Not easy to setup andmaintain – Technical knowledge needed – How to configure the applications? – How to integrate all the components? ? ? Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 40
  • 41. MySQLGroup Replication InnoDB cluster App Servers with MySQL Router MySQLShell Setup, Manage, Orchestrate Clients Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 41
  • 42. MySQLShell: Features •Administration API: AdminAPI – Creation and Management of InnoDB Clusters – Hides the complexity of: •Configuration •Provisioning •Orchestration – Simple and straight-forward – Doesn’t require MySQLexpertise – Flexible, powerful and secure – Available in both JavaScript andPython MySQL Administrati on Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 42
  • 43. MySQLShell: Features Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 43 AdminAPI - options --cluster • Prepares the Shell for managing the InnoDB cluster the target server belongs to •Automatically assigns the cluster global variable --redirect-primary • Connects the shell to the primary of the InnoDB cluster group, in case the one we connect to is asecondary --redirect-secondary • Connects the shell to a secondary member of the InnoDB cluster group
  • 44. MySQLShell: Features Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 44 AdminAPI - Create and Manage •Deploy and manage InnoDBCuster: – dba.configureInstance() – dba.createCluster() – dba.getCluster() – dba.rebootClusterFromCompleteOutage() – ...and much more... •Manage InnoDBCuster: – cluster.addInstance() – cluster.removeInstance() – cluster.rejoinInstance() – cluster.status() – ...and much more...
  • 45. MySQLShell: Features Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 45 AdminAPI - Sandboxes •Deploy and manage MySQL sandboxes: – dba.deploySandboxInstance() – dba.stopSandboxInstance() – dba.startSandboxInstance() – dba.deleteSandboxInstance() – dba.killSandboxInstance() Important: Sandbox instances are only suitable for testing purposes!
  • 46. Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Summary
  • 47. Summary Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 47 •MySQLShell brings together developers andDBAs • Unified interface: one tool! • Development and Administration APIsand features •MySQLInnoDB Cluster is THEbuilt-in HAsolution for MySQL: • Full-stack: High Availability out-of-the-box • Acces to data SQL + NoSQL • Easyto use: usability asa topconcern
  • 48. Resources Copyright © 2018, Oracle and/or its affiliates. All rights reserved. | 48 •MySQLShellUserguide: – https://dev.mysql.com/doc/refman/en/mysql-shell.html •MySQLInnoDB ClusterUserguide: – http://dev.mysql.com/doc/refman/en/mysql-innodb-cluster-userguide.html •APIsReference manuals – JavaScript: https://dev.mysql.com/doc/dev/mysqlsh-api-javascript/ – Python: https://dev.mysql.com/doc/dev/mysqlsh-api-python/ •Blogging – http://mysqlserverteam.com/category/high-availability