<Insert Picture Here> MySQL Administration and Management Essentials Craig Sylvester MySQL Sales Consultant 1
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 decision. The development, release, and timing of any features or functionality described for Oracle s products remains at the sole discretion of Oracle. 2
Tool Categories for DBAs/Admins Basic Command Lines Internal Schemas / Scripts GUIs for rapid design, development, admin Backup and Recovery Monitoring and Management Performance and Stress Testing 3
Basic Command Lines 4
MySQL Client Programs mysql mysqladmin mysqlcheck mysqldump mysqlimport mysqlshow mysqlslap Mysql command line/shell for SQL statements Performing administrative operations. You can use it to check the server's configuration and current status, to create and drop databases, and more Performs table maintenance: It checks, repairs, optimizes, or analyzes tables Used to export a database(s) for backup or transfer to another server. The dump contains SQL statements to create tables, populate it with data, or both. Can also generate files in CSV, delimited text, or XML format. Command-line interface to the LOAD DATA INFILE SQL statement.. Shows databases, their tables, or a table's columns or indexes. A diagnostic program designed to emulate client load for a MySQL server and to report the timing of each stage. It works as if multiple clients are accessing the server. http://dev.mysql.com/doc/refman/5.5/en/programs-client.html 5
Startup Programs mysqld mysqld_safe mysql.server The mysql daemon Script - recommended way to start on Unix. Starts angel process for mysqld daemon. Used on systems (Linux and Solaris) that use System V-style run directories to start and stop system services. Also used by the Mac OS X mysqld_multi Manage Multiple MySQL Servers running on different ports or sockets http://dev.mysql.com/doc/refman/5.5/en/programs-server.html 6
Internal Schemas / Scripts 7
MySQL Information_Schema ANSI SQL (SQL:2003) - a method of accessing database metadata Views that allow you to look at the description of your database objects http://dev.mysql.com/doc/refman/5.5/en/information-schema.html 8
MySQL Performance_Schema Used to monitor low level events - Inspect internal execution of the server at runtime Collects data using instrumentation points in the server source code. This data is stored in tables in the performance_schema database. Activate performance_schema to collect data - Add performance_schema to my.cnf file http://dev.mysql.com/doc/refman/5.5/en/performance-schema.html 9
MySQL Workbench The Official MySQL GUI Application Combines Three Major Feature Sets in One Tool Cross platform and Native UI (Windows, Linux, Mac OS X) 10
MySQL Workbench - Development SQL Editor - Color Syntax Highlighting Object Management - Import/Export, Browser and Edit Connection Management - Wizard, Concurrent, SSH Multi-Pane Results View, In-grid data edits 11
MySQL Workbench - Modeling Visual Design - Create and Manage Models Forward/Reverse Engineer Compare and Synchronize Schemas Change Management and Documentation 12
MySQL Workbench - Administration Full listing of server and status variables Configuration, Start/Stop, Replication Users, Security, and Session Management - Roles support Import/Export Dump Files 13
MySQL Workbench - Utilities mysqldbcopy mysqldbexport mysqldbimport mysqlindexcheck mysqlmetagrep mysqlprocgrep mysqlreplicate mysqlserverclone Copy databases between servers. Export databases to a file in different formats: SQL, CSV, and tabseparated files (and more). Import object definitions and/or data from a file in different formats into a database. Check for redundant/duplicate indexes on a list of tables or databases. Can generate DROP statements to remove redundant indexes. Search MySQL servers for objects containing fields matching a pattern. Search MySQL servers for processes matching a pattern and perform actions. Setup replication between two servers. Start a new instance of a server to experiment with. This is used to test the utilities, but can be used whenever you need to set up a scratch server to test something. mysqluserclone Copy a MySQL user to one or more new users on another server And more coming soon. Contribute your own. http://wb.mysql.com/utilities/index.html 14
MySQL Workbench Standard Edition (next page) 15
MySQL Workbench Standard Edition 16
MySQL Workbench Standard Edition Model Validation General Schema Validation MySQL Specific Schema Validation - Integrity - Syntax - Duplicated identifiers 17
Backup and Recovery 18
DBA Challenge Core responsibility for backup and recovery But, its not easy Databases are growing exponentially Backup times are increasing even faster Your Backups impact other activities End Users DBA Maintenance And your storage costs are out of control And when bad things happen Needs to work Taking forever to recover 19
Database Backup Types Advantages & Disadvantages 20
MySQL Backup Tools Hot Backup (online) - MySQL Enterprise Backup - mysqlbackup Export/Import (a logical backup) - mysqldump Standby Copy (hot swap) - MySQL Replication Cold Backup (offline) - Simple File Copies when server is shutdown File System Volume Managers (snapshots) - LVM for example 21
mysqldump Advantages - Good for small databases or tables - Good assurance that database files are not corrupt - Logical Backup thus flexible and portable Disadvantages - Very slow restore times - Uses database processing cycles and resources - Not online (requires Transaction or Locks on Tables in the database) - Not incremental (requires a Full Backup every time) - Not consistent (unless transaction is used) 22
MySQL Replication Advantages - Rolling snapshot - Quick Recovery - via failover - Non-Blocking - Works well in conjunction with other backup options Disadvantages - Only latest Point in Time (point it time keeps moving forward) - Not historical - Not for archival purposes - Doesn t protect from oops 23
LVM Snapshots Advantages - Quick - Feature of Linux - Good to use in conjunction with backups Disadvantages - It s a snapshot Still need to make a backup copy which is full in size - Performance degrades with each concurrent snapshot Snapshots need to be released - Cross File System Limitations 24
MySQL Enterprise Backup Advantages - Physical Backup (so it s fast esp. restores) - Flexible - many options - Archival - Scalable - Consistent - Supported Disadvantages - Requires some planning 25
MySQL Enterprise Backup Online Backup for MySQL databases High Performance Full, Incremental, Partial Backups - Compressed Tables - Partition files - In-memory database Compression Point in Time Recovery MEB Backup Files Metadata on status, progress, history Unlimited Database Size Streaming, single file support - Backup to tape device mysqlbackup MySQL Database Files 26
Monitoring and Management 27
MySQL Enterprise Monitor Consolidated view Enterprise Support SNMP LDAP Customizable Query Analysis with Correlation Graphs 28
Enterprise Monitor Deployment Management Reporters Stand alone databases MEM Agents Replication databases MEM Server MEM Agents DBAs/Administrators Cluster Servers 29
MySQL Expert Advisors 150+ Rules 50+ MySQL/OS specific Graphs 30
MySQL Expert Advisors - Upgrade Details 31
Automated Replication Monitor Auto-detects, groups & maintains Master/Slave topologies Consolidated, real time status/synch check Notifications on Synch Issues 32
EM - Query Analyzer 33
Query Execution Drill Downs Example query with variable substitution Trace query exec back to source code Explain Plan 34
Example of adding a custom advisor (or rule) 35
Enterprise Monitor - Create New Rule 36
Enterprise Monitor - Copy Existing Rule 37
Enterprise Monitor - Copy Existing Rule 38
Enterprise Monitor - Copy Existing Rule 39
Let s generate some events (we ll use Workbench) 40
Workbench - Create Table 41
Enterprise Monitor - Check Events 42
Enterprise Monitor - Check Event Details 43
Enterprise Monitor - Query Analyzer Here are the CREATE TABLE details 44
Workbench - Create User 45
Enterprise Monitor - Check Events Select the Group from Servers browser and filter on Rules 46
Query Analysis thru Agent Proxy 47
Query Analysis thru.net or Java Application Server 3. Connector (SQL statements & result sets) MySQL Database 3306 4. Plugin for Connector (SQL performance data: statements, examples, EXPLAINs, aggregated stats) (MySQL & OS monitoring data) 2. MySQL Agent 18080 1. MySQL Enterprise Monitor ( Dashboard (Service Manager, List of components to download & configure: 1. MySQL Enterprise Monitor & Query Analyzer 2. MySQL Agent 3. Connector/NET (v6.2+) or Connector/J (v5.1+) 4. MySQL Enterprise Plugin for Connector 48
Query Analysis thru Aggregator PHP and C connectors - release candidates available 49
Performance and Stress Testing 50
Performance/Stress Testing Sysbench - http://sysbench.sourceforge.net/ DBT-2 - Like OLTP benchmark - Very popular with many MySQL users - http://samurai-mysql.blogspot.com/2009/03/ settingup-dbt-2.html 51
Additional Resources https://edelivery.oracle.com/ - Download Enterprise Monitor, Enterprise Backup, other tools - Download MySQL database https://mysql.com - Info on MySQL Products, Editions, Licensing options - TCO calculator https://dev.mysql.com - Documentation - Developer Zone Articles, How to s 52
53