Contenu connexe Similaire à MySQL Quick Dive (20) MySQL Quick Dive1. Quick Dive into MySQL
Sudipta – sudipta.sahoo@oracle.com
Joshi – madhusudhan.joshi@oracle.com
2. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.2
Safe Harbour 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.
3. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.3
Program Agenda
What is MySQL ?
MySQL Server Overview
What‟s New in 5.6
MySQL Enterprise Components
Q & A
4. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.4
What is MySQL ?
5. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.5
“MySQL is the world's most widely used open
source relational database management
system (RDBMS) that runs as a server
providing multi-user access to a number of
databases”
7. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.7
What is MySQL ?
Robust ACID compliant RDBMS
Open Source (GPL v2 + proprietary)
Used by some of the largest web properties in the world
Abundantly present in all major Linux distributions and
hosting providers
Properly documented and professionally supported by
Oracle
Simple to get and easy to use
8. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.8
Picking the Right Variant
9. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.9
Server and
Connectors
Security
Scalability
InnoDB
Monitoring,
Backup etc
Cluster
Community
Classic library
Standard
Enterprise
Cluster Carrier
Grade
MySQL Editions
10. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.10
MySQL Version Numbering
Major Version Minor Version Milestone
Current 5.6 5.6.17 5.7.4-m14
Incompatible
changes
Upgradable
New Features *
Compatible
Released every approx. 2 years 2 months 2-4 Months
11. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.11
Installer vs. Archive Distribution ?
vs.
12. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.12
MySQL Concepts
13. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.13
MySQL Building Blocks
Client Apps
Connectors: C, JDBC, ODBC, PHP, Python, .NET
Server
Parser + Optimizer
Query Execution
Storage Engines
InnoDB MyISAM Memory …
System Apps
“Not Only SQL”
Plugin
Plugin
Plugin
Plugin
14. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.14
Storage Engines
Implement data storage and retrieval at table level
Every table needs one
Some storage engines:
– InnoDB (default since 5.5) – fully transactional, ACID compliant
– MyISAM (previous default) – non-transactional, file based
– INFORMATION_SCHEMA – fully virtual
– PERFORMANCE_SCHEMA – volatile generated data
– black hole storage engine – data go in, nothing goes out
15. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.15
Plugins
Extend the server functionality at run time
Interesting plugin types
– Authentication
– Storage engines
– SQL accessible functions
– Password validation
– INFORMATION_SCHEMA tables
16. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.16
User Accounts
Two parts : „user name‟@‟host name‟.
Can use wildcards in host names: empty („‟), „%‟ and „_‟.
Host part can be IP addresses/net masks too.
Authentication methods are pluggable.
No passwords are stored in tables, only hashes.
GRANT commands can create users too.
17. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.17
“Logged in” and “Current” User ID
Joe connects from the data entry department
MySQL finds a record ’’@’%.dataentry’ and authenticates Joe to it
Joe can use all privileges granted to ’’@’%.dataentry’
joe@p1.dataentry
Users table
‟‟@%.dataentry
user() current_user()
18. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.18
Granting Privileges
Always granted to a user@host combination
Only DROP USER is guaranteed to clean up properly !
INSERT can be granted on a column subset
Privileges are checked against current_user()
19. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.19
Privileges in MySQL
Server : USAGE, SHUTDOWN, SUPER, CREATE …
– Database : CREATE, DROP, EXECUTE, SELECT, …
Table : INSERT, SELECT, …
– Column : INSERT, SELECT, UPDATE
– Stored routine : EXECUTE, CREATE ROUTINE, ALTER ROUTINE
User : PROXY
20. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.20
Replication
One way : master to slave(s)
– NEW ! This is changing. Check labs.mysql.com
Asynchronous or Semi-Synchronous
Replication log formats
– Statements
– Row data
– Mixed
21. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.21
Partitioning
A storage engine
Horizontal partitioning
Partition by
– List : BY LIST(<expr>) (PARTITION <name> VALUES IN (3,5,6,9,17)
– Range : BY RANGE (<expr>) (PARTITION <name> VALUES LESS THAN
(<num>), …
– Hash/Key: BY HASH( <expr> ) PARTITIONS (4)
22. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.22
User Variables
Connection specific
Weak typed
No declaration needed
mysql> SELECT @min_price:=MIN(price),@max_price:=MAX(price) FROM shop;
mysql> SELECT * FROM shop WHERE price=@min_price OR price=@max_price;
+---------+----------+---------+
| article | dealer | price |
+---------+----------+---------+
| 0003 | D | 1.25 |
| 0004 | D | 19.95 |
+---------+----------+---------+
23. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.23
Basic Operations
24. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.24
Connecting to the Database
IPv4 and IPv6 are supported
Designated TCP port 3306
Transparent SSL encryption layer supported
Protocol Connection Type Operating Systems
TCP/IP Local and Remote Any
UNIX Socket File Local only UNIX
Named Pipe Local only Windows
Shared Memory Local only Windows
IPv4 and IPv6 are supported
Designated TCP port 3306
Transparent SSL encryption layer supported
25. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.25
Executing Queries Using the „mysql‟ Tool
„?‟ Is help
Statements end with a semicolon (or whatever delimiter is set to).
You can set a “current” database : USE or through the command line
Commands come from standard input, if not on a console
Results go to standard output, errors to standard error
Command line editing on the console
Don‟t forget SHOW WARNINGS
26. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.26
Exploring Databases and Objects
Backward Compatible MySQL Commands
– SHOW DATABASES / TABLES / TRIGGERS / PROCEDURE /FUNCTION
STATUS
– SHOW CREATE TABLE / VIEW / TRIGGER
– SHOW PROCEDURE / FUNCTION CODE
INFORMATION_SCHEMA tables
– TABLES, TRIGGERS, VIEWS, ROUTINES, COLUMNS etc
ls, dir etc.
27. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.27
Disk Structure
Databases are file system directories
Tables are just a bunch of files
Can add tables and databases through the file system mid-flight.
28. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.28
The SQL Dialect(s)
Most common gotchas
– AVG() ≠ AVG<space>()
– ‟this is a string‟ (single quote)
– ”this is a string too” (double quote)
– `this is a quoted identifier` (back tick)
– b, n, r, t, Z work as in C
– || is OR, not CONCAT(), && works as an AND too !
29. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.29
Unique Commands and Functionality
DROP TABLE/DATABASE … IF EXISTS
Set and read user variables from inside other commands
Case insensitive string comparisons by default
30. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.30
Mind the Storage Engine
Every table needs a storage engine. And there‟s a default one too !
mysql> create table t1 (a integer) engine='vaporware';
Query OK, 0 rows affected, 2 warnings (0,05 sec)
mysql> show create table t1;
CREATE TABLE `t1` (
`a` integer(11) DEFAULT NULL
) ENGINE=InnoDB
31. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.31
MySQL Tries to be Nice. Too Nice.
SELECT 1 FROM DUAL WHERE 1 = ‘1 starting string’ returns a row
Strings are silently truncated when inserted into smaller columns
Out-of-range integer values are auto-adjusted
Syntax known not to work is still accepted : e.g. FOREIGN KEYS and
MyISAM
32. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.32
What‟s new in MySQL 5.6 ?
33. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.33
MySQL 5.6 : Best Release Ever !
Improved Performance and Scalability
– Scales to 48 CPU threads
– Up to 230% performance gain over MySQL 5.5
Improved InnoDB
– Better Transaction Throughput and availability
Improved Optimizer
– Faster query execution and diagnostics for query tunning and debugging
34. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.34
MySQL 5.6 : Best Release Ever !
Improved Replication
– Higher Performance, availability and data integrity
Improved PERFORMANCE_SCHEMA
– Better Instrumentation, User/Application level statistics and monitoring
New ! NoSQL Access to InnoDB
– Fast, Key/Value access with full ACID compliance, better developer agility
New ! MySQL Hadoop applier
– Uses the binary log for real-time push of the data
Continued
45. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.45
Oracle Premier
Lifetime Support
Oracle Product
Certifications/Integrations
MySQL Enterprise
High Availability
MySQL Enterprise
Security
MySQL Enterprise
Scalability
MySQL Enterprise
Backup
MySQL Enterprise
Monitor/Query Analyzer
MySQL Workbench
MySQL Enterprise Edition
Highest Levels of Security, Performance and Availability
MySQL Enterprise
Audit
46. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.46
Oracle Premier
Lifetime Support
DBA Concern…is my data safe ???
…Who can see it ?
… What was seen ?
… Who can change it ?
… What was changed ?
47. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.47
Out-of-the-box logging of connections, logins, query activity
User defined policies, filtering and log rotation
Dynamically enabled, disabled: no server restart
XML-based audit stream per Oracle audit specification
Easily implemented via MySQL 5.5 Audit API
MySQL 5.5.28 and higher
Adds regulatory compliance to MySQL applications.
HIPAA, Sarbanes-Oxley, PCI, etc.
MySQL Enterprise Audit
Policy-based Auditing for MySQL Applications
48. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.48
PAM (Pluggable Authentication Modules)
- Access external authentication methods
- Standard interface (Unix, LDAP, Kerberos, others)
- proxied and non-proxied users
Windows
- Access native Windows services
- Authenticate users already logged into Windows (Windows Active
Directory)
Pluggable Authentication API
Integrates MySQL with existing security infrastructures and SOPs.
MySQL Enterprise Security
External Authentication
49. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.49
MySQL default thread-handling – excellent performance, can
limit scalability as user connections grow
MySQL Thread Pool improves sustained performance/scale as
user connections grow
Thread Pool API
Ensures better, sustained performance as user loads continue to grow.
MySQL Enterprise Scalability
MySQL Thread Pool
50. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.50
Internal Clients
Default
Thread Handling
Connections
/statements
assigned
to Threads
for life
Connections assigned to 1 thread for the life of the connection, same thread used
for all statements
No prioritization of threads, statement executions
Many concurrent connections = many concurrent execution threads to consume
server memory, limit scalability
Connection Execution Threads
External Clients
Default Thread Handling
51. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.51
Internal Clients
Connection Execution Threads
External Clients
Thread Pool
Thread Group 1
Threads 1 - 4096
Thread Group 2
Threads 4097 - 8193
Thread Group N
Threads 8194 - N
Thread Pool contains configurable number of thread groups (default = 16), each
manages up to 4096 re-usable threads
Each connection assigned to thread group via round robin
Threads are prioritized, statements queued to limit concurrent executions, load on
server, improve scalability as connections grow
Thread Group 1
Thread Group 2
Thread Group N
With Thread Pool Enabled
52. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.52
MySQL Enterprise Edition
With Thread Pool
MySQL Community Server
Without Thread Pool
60x Better Scalability with Thread Pool
MySQL 5.6.11
Oracle Linux 6.3, Unbreakable Kernel 2.6.32
4 sockets, 24 cores, 48 Threads
Intel(R) Xeon® E7540 2GHz CPUs
512GB DDR RAM
With Thread Pool Enabled
0
2000
4000
6000
8000
10000
12000
1 4 16 32 64 128 256 512 1024 2048 4096 8192
TransactionsPerSecond
Simultaneous Database Connections
MySQL 5.6 Sysbench OLTP Read/Write
53. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.53
MySQL Enterprise Edition
With Thread Pool
MySQL Community Server
Without Thread Pool
18x Better Scalability with Thread Pool
MySQL 5.6.11
Oracle Linux 6.3, Unbreakable Kernel 2.6.32
4 sockets, 24 cores, 48 Threads
Intel(R) Xeon® E7540 2GHz CPUs
512GB DDR RAM
With Thread Pool Enabled
0
2000
4000
6000
8000
10000
12000
14000
16000
1 4 16 32 64 128 256 512 1024 2048 4096 8192
TransactionsPerSecond
Simultaneous Database Connections
MySQL 5.6 Sysbench OLTP Read Only
54. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.54
MySQL Enterprise Monitor
Real-time MySQL performance and availability monitoring
Visually find & fix problem queries
Disk monitoring for capacity planning
Cloud friendly architecture (no agents)
Start monitoring MySQL in 10 minutes
Remote agent option provides OS monitoring
New!
55. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.55
Online Backup for InnoDB (scriptable interface)
Full, Incremental, Partial Backups (with compression)
Point in Time, Full, Partial Recovery options
Monitoring and Alerts on Backup Operations
Metadata on status, progress, history
Unlimited Database Size
Windows, Linux, Unix
Certified with Oracle Secure Backup, NetBackup, Tivoli, others
MEB Backup
Files
MySQL
Database Files
mysqlbackup
Ensures quick, online backup and recovery of your on premise and Cloud
based MySQL applications.
MySQL Enterprise Backup
56. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.56
MySQL Enterprise Backup
4h 17 mins
5.25 mins
0
50
100
150
200
250
300
mysqldump MySQL Enterprise Backup
Minutes
Backup: 73 GB Database
MySQL Enterprise Backup: 49x Faster than mysqldump
49x
More
Performance
57. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.57
MySQL Enterprise Backup
MySQL Enterprise Backup: 80x Faster than mysqldump
18h 45 mins
14 mins
0
200
400
600
800
1,000
1,200
mysqldump MySQL Enterprise Backup
Minutes
Restore: 73 GB Database
80x
More
Performance
58. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.58
Database Design
Visual Design, modeling
Forward/Reverse Engineer
Schema validation, Schema doc
SQL Development
SQL Editor - Color Syntax Highlighting
Objects - Import/Export, Browse/Edit
Database Administration
Status, Configuration, Start/Stop
Users, Security, Sessions
Import/Export Dump Files
New! Database Migration Wizard
for SQL Server, Sybase, SQLite, SQL Anywhere & PostgreSQL
MySQL Workbench
59. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.59
What Do the Tools Look Like ?
60. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.60
Other Useful Utilities
GUI
– MySQL Workbench
– MS Visual Studio
Command line
– mysqldump
– mysqlbinlog
– mysql_config_editor
MySQL Enterprise Tools
61. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.61
Oracle Linux (w/DRBD Stack)
Oracle VM
Oracle VM Template for MySQL EE
Oracle Solaris Clustering
Oracle GoldenGate
Oracle Secure Backup
Oracle Database Firewall
My Oracle Online Support
Oracle Product Integrations/Certifications
Available Now
62. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.62
Oracle Product Integrations/Certifications
In Progress
Oracle Fusion MiddleWare
- WebCenter Suite
- Enterprise Content Management
- Oracle Business Intelligence Suite
Oracle Clusterware
Oracle Audit Vault
Oracle Enterprise Manager
And More…
63. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.63
How to Continue With
Your MySQL Studies?
64. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.64
Training
Training courses
– MySQL for Beginners, MySQL for Developers, MySQL for DBAs
– Performance Tuning, High Availability, Cluster
– MySQL and PHP : Developing Dynamic Web Applications
Certification
– Oracle Certified Associate, Professional, Expert
Learning paths
http://www.mysql.com/training/
65. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.65
Support
Oracle Lifetime Support for MySQL
– Largest Team of MySQL Experts
– Backed by MySQL Developers
– Direct Access to MySQL Support Engineers
– Forward Compatible Hot Fixes
– MySQL Maintenance Releases
– Support in 29 Languages
– 24/7/365
– Unlimited Incidents
– Knowledge Base
– MySQL Consultative Support
http://www.mysql.com/support
Only from
Oracle
66. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.66
Join the MySQL Community
Online manuals
Forums
Mailing lists
Bug tracker
Development articles
Design documents database
Downloads
Blogs
MySQL Developer Zone: http://dev.mysql.com
67. Copyright © 2014, Oracle and/or its affiliates. All rights reserved.67
mysql.com
- MySQL Products and Editions
- TCO calculator
- Customer success stories
dev.mysql.com
- Downloads, Documentation
- Forums
- PlanetMySQL
eDelivery.oracle.com
- Download and evaluate all MySQL products
Learn More
Notes de l'éditeur User() = ‘joe@p1.dataentry’, current_user() = ‘’@’%.dataentry’ http://dev.mysql.com/doc/refman/5.6/en/grant.html : for all privileges Semi-synchronous replication means that the master waits on commit until at least one slave confirmed the transaction.Multi-master replication in labs.mysql.comNeed cluster for synchronous HASH/KEY can be linear : faster to calculate the hash, less likely to be evenly distributedNormal hashing is : PartN = MOD(key, Nparts)Linear hash is : IGNORE_SPACESANSI_QUOTESNO_BACKSLASH_ESCAPES IGNORE_SPACESANSI_QUOTESNO_BACKSLASH_ESCAPES Real-time MySQL Performance and Availability MonitoringVisual Dashboad for Better VisibilityVisually Find and Fix Problem QueriesPinpoint SQL code that causing a slowdownVisual Capacity PlanningForecasting using Projections and Trend AnalysisAgentless, Cloud Friendly ArchitectureRemotely Monitor MySQL without agentsStart Monitoring MySQL in 10 minutesEasy to use with zero configuration MySQL Enterprise Edition is also certified with these Oracle products. And we’re working on a number of additional integrations: Consultative : Remote Troubleshooting, Replication Review, Partitioning Review, Schema Review, Query Review, Performance Tuning, Customer Code Review: Client APIs, Install Support