Has MySQL grown up?

  • 2,326 views
Uploaded on

Much has changed in the MySQL world over the past few years with it being first bought by Sun and then gobbled by Oracle. So is it going to be sucked of oxygen or are Oracle serious about keeping …

Much has changed in the MySQL world over the past few years with it being first bought by Sun and then gobbled by Oracle. So is it going to be sucked of oxygen or are Oracle serious about keeping MySQL popular and open?

The good news is that despite going quiet for a long while (one releases in 4+ years) it looks like Oracle have shown some love and rolled out significant changes and welcome improvements that improve the MySQL's overall maturity and performance.

This talk will walk through practical examples that demonstrate how these features can be best used.

Topics include:

With InnoDB being chosen over MyISAM as the default storage engine we'll explore the pros & cons of these and other table types.

A key to high availability is redundancy, so replication is vital. This talk will walk through real-world examples ranging from simple master-slave setups to more complex multi-master and multi-slave configurations.
Now that you have multiple servers up & running the next logical step is a look at the load balancing and failover features built into the latest JDBC drivers.

To round things out we'll examine options for backing up your mysql data and check out some of the new monitoring tools Oracle are providing as enterprise (i.e. non-free) add-ons.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
2,326
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
14
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Has MySQL Grown Up? Mark Stanton grude
  • 2. A brief history
  • 3. A brief history1995 Named after Monty’s daughter (My)2000 Open sourced2001 3.232003 4.02005 5.0 Oracle buys the company behind InnoDB2006 MySQL hits 33% market share, Oracle tries to buy2008 5.1 Sun acquires MySQL for $1 billion, Monty leaves2010 5.5 Oracle buys Sun for $7.4 billion
  • 4. Where are we now?• MySQL is growing up• Oracle are showing love• Facebook, Google & others are contributing• Make sure you are running: • 5.5 • recent version of 5.1
  • 5. The wonderful world of Storage Engines
  • 6. Storage Engines• Storage engines are pluggable table types• You can have multiple storage engines within each a DB• Transparent to clients (mostly) MyISAM InnoDB
  • 7. MyISAM• Simple, light weight• File based• FULLTEXT indexes• Table level locking
  • 8. InnoDB• ACID compliant • Hot backup• Crash safe • Active development• Foreign keys • Optimised for multi-core• Row-level locking • Default from 5.5 on• Table compression • No FULLTEXT (until 5.6)
  • 9. NDB - MySQL Cluster• High Availability• Tables clustered across nodes• Auto fail & recover• Auto partitioning• No FK, limited transactions• Poor multi-table joins• Pretends to be MySQL, really whole other product
  • 10. Other Storage Engines• MERGE• MEMORY• BLACKHOLE• CSV ( ) CREATE TABLE export ENGINE=CSV SELECT foo, bar FROM table
  • 11. Storage Engines: Conclusion• InnoDB is the new default & new direction• MyISAM is the past• If you are still on MyISAM, think of moving• NDB is very interesting for special cases
  • 12. Replication
  • 13. Why Replicate?• Scale out• High availability• Geographic• Backup• Analytics / Business Intelligence
  • 14. Under the Hood: Logs IO Thread Step 2 Step 3 SQL ThreadStep 1 Step 4
  • 15. Under the Hood: Format • Statement: UPDATE table.. • Records 1100101100111
  • 16. Under the Hood: Semi-sync Step 1 Step 1Step 1 Step 2
  • 17. Configuration: Master-Slave• Master my.cnf: server-id = 10 log-bin=mysql-M1-bin• Master DB: mysql> CREATE USER repl; Name Server-Id Port mysql> GRANT REPLICATION SLAVE ON *.* TO repl; M1 10 3310• Slave my.cnf: server-id = 11 M1-S1 11 3311• Slave DB: mysql> CHANGE MASTER TO MASTER_HOST=localhost, MASTER_PORT=3310, MASTER_USER=repl;
  • 18. SHOW SLAVE STATUSmysql> show slave status G*************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Server_Id: 10 Master_Host: localhost Master_Port: 3310 Master_User: repl Master_Log_File: mysql-M1-bin.000017 Read_Master_Log_Pos: 107 Exec_Master_Log_Pos: 107 Slave_IO_Running: Yes Slave_SQL_Running: Yes Last_Errno: 0 Last_Error: Seconds_Behind_Master: 0 Master_Server_Id: 10
  • 19. In Practice
  • 20. Multi-Master M1 M2 M1#S1 M2#S1
  • 21. Why Multi-Master?• Active/Passive sites• High Availability• Geographically dispersed writes
  • 22. Multi-Master: ConsiderationsMulti-Master replication needs at least one of:• Conflict Avoidance• Conflict Resolution• Hope
  • 23. Multi-Master: Considerations• Conflict Avoidance • UUIDs • Auto increment hacks = 2 auto_increment_increment auto_increment_offset = 1 • Semi-sync • Active/Passive • Ticket server
  • 24. Multi-Master: Considerations• Conflict Resolution • Cluster/NDB • Galera • or roll your own...
  • 25. Configuration: Multi-MasterName Server-Id PortM1 10 3310M1-S1 11 3311M2 20 3320 M1 M2M2-S1 21 3321• M2 as slave of M1• M1 as slave of M2• M2-S1 as slave of M2 M1#S1 M2#S1
  • 26. Review of Topologies Master Master Master Master Master Master Slave Slave Slave Slave Master Slave Master Master Mul)* Mul)*Mul$% Slaves SlavesSlaves
  • 27. Connector/J• MySQL’s Connector/J supports: • Failover • Load Balancing • (Replication)
  • 28. JDBC Connection Syntaxjdbc:mysql://hostname:port/dbname ?property=valuejdbc:mysql://localhost:3306/test?username=root
  • 29. JDBC Failoverjdbc:mysql://host1:port1,host2:port2/dbname
  • 30. JDBC Load Balancingjdbc:mysql:loadbalance://host1:port1,host2:port2,host3:port3/dbname
  • 31. Warning• Failover doesn’t attempt to be transparent• ColdFusion doesn’t allow you full control• Check/upgrade your Connector/J version• Set connectionTimeout, socketTimeout and blacklistTimeout carefully
  • 32. MySQL Enterprise Monitor
  • 33. MySQL Enterprise Monitor• Heat maps• Charts• Query analyser• Replication status• Configurable advisors & email alerts• Event logs
  • 34. MySQL Enterprise Monitor• Server with agents for each mysqld• Query analyser can have performance hit• Non-free
  • 35. Backing Up MySQL• Several approaches: • Copy DB files • mysqldump • binlog • Backup to slave • mysqlbackup
  • 36. Backup: File copy• Enable read lock: mysql> LOCK TABLES READ; mysql> FLUSH TABLES;• Run file copy: $ cp -R ./myDB /mybackups/myDB• Unlock tables: mysql> UNLOCK TABLES;
  • 37. Backup: mysqldump• Creates an sql script containing commands to recreate database• Run from command-line: $ mysqldump --single-transaction --all-databases > backup_sunday_1_PM.sql
  • 38. Backup: binlog• The binary log: • records statements • can be replayed from arbitrary point • need to know where to replay from• Rotate binlog mysql> FLUSH LOGS;• Then copy relevant files
  • 39. Backup: Slave• Setup dedicated slave for backup purposes• Shutdown slave• Run backup• Restart slave
  • 40. Backup: mysqlbackup• Non-free enterprise backup tool• Features: • Hot • Incremental • Compressed • Verification
  • 41. Summary of Backup Options backup to copy DB files mysqldump binlog mysqlbackup slave Lock (MyISAM) Lock (MyISAM)Hot/Read-Lock Lock Hot Hot Hot* (InnoDB) Hot (InnoDB)Incremental No No Yes No YesInnoDB Support No Yes Yes Yes YesRestore Speed Fast OK ** OK Fast Fast* use --single-transaction for InnoDB** disable for autocommit/FK checks in InnoDB
  • 42. Questions?• Mark Stanton• http://blog.gruden.com• mark@gruden.com• @MarkStanto