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.
3. A brief history
1995 Named after Monty’s daughter (My)
2000 Open sourced
2001 3.23
2003 4.0
2005 5.0 Oracle buys the company behind InnoDB
2006 MySQL hits 33% market share, Oracle tries to buy
2008 5.1 Sun acquires MySQL for $1 billion, Monty leaves
2010 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
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
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
24. Multi-Master:
Considerations
• Conflict Resolution
• Cluster/NDB
• Galera
• or roll your own...
25. Configuration:
Multi-Master
Name Server-Id Port
M1 10 3310
M1-S1 11 3311
M2 20 3320
M1 M2
M2-S1 21 3321
• M2 as slave of M1
• M1 as slave of M2
• M2-S1 as slave of M2
M1#S1 M2#S1
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
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
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 Yes
InnoDB Support No Yes Yes Yes Yes
Restore Speed Fast OK ** OK Fast Fast
* use --single-transaction for InnoDB
** disable for autocommit/FK checks in InnoDB