2012 ohiolinuxfest replication

  • 346 views
Uploaded on

 

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
346
On Slideshare
0
From Embeds
0
Number of Embeds
5

Actions

Shares
Downloads
2
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. http://hiconsumption.com/2012/07/star-wars-recreations-of-iconic-photographs-by-david-eger/
  • 2. <Insert Picture Here>MySQL: ReplicationKeith Larsonkeith.larson@oracle.comMySQL Community Managersqlhjalp.blogspot.comsqlhjalp.com/pdf/ for presentations
  • 3. The following is intended to outline our general productdirection. It is intended for information purposes only, and maynot be incorporated into any contract. It is not a commitmentto deliver any material, code, or functionality, and should notbe relied upon in making purchasing decisions.The development, release, and timing of any features orfunctionality described for Oracle’s products remains at thesole discretion of Oracle.Safe Harbor StatementTM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.http://jennysung.com/wp-content/uploads/2012/03/stormtroopers1.jpg
  • 4. Who am I and who are you?Who are you?– DBAs?– Developers?• PHP• Perl• Python• .net– Admins?keith.larson@oracle.comMySQL Community Managerhttp://www.sqlhjalp.com/Started with MySQL during the dot.com days.Primary real world work was with a MySQL InnoDB replicated chain environment thateasily held over 4 billion rows of user data.Numerous other sites developed on LAMP stack over the last 13 years.Copyright Oracle Corporation 2012 4http://3.bp.blogspot.com/-IXu-9-s-8Fg/TvTs8JbgvdI/AAAAAAAAJpo/at-pjGsDlXg/s1600/Bat%2BStorm%2BTrooper%2BLego.jpg
  • 5. Session AgendaMySQL Replication OverviewReplication ConfigurationExamples of a real world set upMySQL 5.6 Replication FeaturesMonitoring – MySQL Enterprise MonitorCopyright Oracle Corporation 2012Overview Configuration Features Monitor
  • 6. Copyright Oracle Corporation 2012 6MySQL Replication OverviewTM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.http://farm3.static.flickr.com/2646/3678467304_66908d66d4.jpg
  • 7. Copyright Oracle Corporation 2012 7Duplicates database from a“master” to a “slave”Redundant copies of the dataprovide foundation for HighAvailabilityScale out by distributing queriesacross the replication clusterMySQL Replication OverviewTM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.http://thewondrous.com/wp-content/uploads/2010/04/Largest-display-of-Star-Wars-clone-troopers-built-with-interlocking-plastic-bricks.jpg
  • 8. “In my opinion, MySQL is the only databasewe would ever trust to power the Zappos.comwebsite.”"On any given day we can sell close to300,000 tickets on the Web site usingMySQL as the database to search forevents. It is amazing.""craigslist infrastructurecould not have handled theexponential growth in trafficwithout MySQL.”“We are one of the largest MySQLweb sites in productionWho Uses Replication ?“As a leader in our field, we are committedto providing the best service to our users,and a web experience that meets membersexpectations and that starts with IT”“They have a master server for all writes and slaveservers for most Reads. The secret truth they claimbehind configuring the master and slave machinesis to make sure the slave machines are faster thanthe masters”Copyright Oracle Corporation 2012 8
  • 9. Copyright Oracle Corporation 2012 9Who Uses Replication ?
  • 10. MySQL Replication OverviewCopyright Oracle Corporation 2012 10Native in MySQLReplicate within and across data centersFailover is either scripted or provided by additional middlewareSupports Asynchronous (standard) and Semi-Synchronous replicationEach slave adds minimal load on masterhttp://www.betabeat.com/2011/09/02/clone-wars-rise-of-the-fast-follower-startups/TM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.
  • 11. Copyright Oracle Corporation 2012 11Replication TopologiesMySQL Replication Overview
  • 12. Copyright Oracle Corporation 2012 12Used for Scalability and HAAsynchronous as standardSemi-Synchronous support added in MySQL 5.5Each slave adds minimal load on masterReplication ThreadsBinlog dump threadSlave I/O threadSlave SQL threadReplication Filesrelay logmaster info logrelay log info logMySQL Replication Overview
  • 13. Copyright Oracle Corporation 2012 13MySQL Replication Overview
  • 14. Copyright Oracle Corporation 2012 14MySQL Replication Overviewhttp://technabob.com/blog/2011/12/16/lego-stormtroope-american-beauty/TM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.
  • 15. Copyright Oracle Corporation 2012 15http://technabob.com/blog/2011/12/16/lego-stormtroope-american-beauty/TM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.MySQL Replication Overview
  • 16. Copyright Oracle Corporation 2012 16Used for Scalability and HAAsynchronous as standardSemi-Synchronous support added in MySQL 5.5Each slave adds minimal load on masterReplication ThreadsBinlog dump threadSlave I/O threadSlave SQL threadReplication Filesrelay logmaster info logrelay log info logThe master creates a thread to send the binary log contents to aslave when the slave connects. This thread can be identified in theoutput of SHOW PROCESSLIST on the master as the Binlog Dumpthread.The binlog dump thread acquires a lock on the masters binarylog for reading each event that is to be sent to the slave. As soonas the event has been read, the lock is released, even before theevent is sent to the slave.*************************** 2. row ***************************Id: 27User: replicationHost: 192.168.0.11:47129db: NULLCommand: Binlog DumpTime: 499State: Master has sent all binlog to slave; waiting for binlog tobe updatedInfo: NULLMySQL Replication Overview
  • 17. Copyright Oracle Corporation 2012 17Used for Scalability and HAAsynchronous as standardSemi-Synchronous support added in MySQL 5.5Each slave adds minimal load on masterReplication ThreadsBinlog dump threadSlave I/O threadSlave SQL threadReplication Filesrelay logmaster info logrelay log info logMySQL Replication OverviewWhen a START SLAVE statement is issued on a slave server, theslave creates an I/O thread, which connects to the master andasks it to send the updates recorded in its binary logs.The slave I/O thread reads the updates that the masters BinlogDump thread sends and copies them to local files that comprisethe slaves relay log.The state of this thread is shown as Slave_IO_running in theoutput of SHOW SLAVE STATUS or as Slave_running in theoutput of SHOW STATUS.Slave_IO_Running: Yes| Slave_running | ON |
  • 18. Copyright Oracle Corporation 2012 18Used for Scalability and HAAsynchronous as standardSemi-Synchronous support added in MySQL 5.5Each slave adds minimal load on masterReplication ThreadsBinlog dump threadSlave I/O threadSlave SQL threadReplication Filesrelay logmaster info logrelay log info logMySQL Replication OverviewThe slave creates an SQL thread to read the relay logthat is written by the slave I/O thread and execute theevents contained therein.Slave_SQL_Running: Yes
  • 19. Copyright Oracle Corporation 2012 19Used for Scalability and HAAsynchronous as standardSemi-Synchronous support added in MySQL 5.5Each slave adds minimal load on masterReplication ThreadsBinlog dump threadSlave I/O threadSlave SQL threadReplication Filesrelay logmaster info logrelay log info logMySQL Replication OverviewThe relay log consists of the events read from the binarylog of the master and written by the slave I/O thread.Events in the relay log are executed on the slave as partof the SQL thread. caption text here.
  • 20. Copyright Oracle Corporation 2012 20Used for Scalability and HAAsynchronous as standardSemi-Synchronous support added in MySQL 5.5Each slave adds minimal load on masterReplication ThreadsBinlog dump threadSlave I/O threadSlave SQL threadReplication Filesrelay logmaster info logrelay log info logMySQL Replication OverviewThe master info log contains status and currentconfiguration information for the slaves connection tothe master. This log holds information on the masterhost name, login credentials, and coordinates indicatinghow far the slave has read from the masters binary log.
  • 21. Copyright Oracle Corporation 2012 21Used for Scalability and HAAsynchronous as standardSemi-Synchronous support added in MySQL 5.5Each slave adds minimal load on masterReplication ThreadsBinlog dump threadSlave I/O threadSlave SQL threadReplication Filesrelay logmaster info logrelay log info logMySQL Replication OverviewThe master info log contains status and currentconfiguration information for the slaves connection tothe master. This log holds information on the masterhost name, login credentials, and coordinates indicatinghow far the slave has read from the masters binary log.
  • 22. Copyright Oracle Corporation 2012 22Used for Scalability and HAAsynchronous as standardSemi-Synchronous support added in MySQL 5.5Each slave adds minimal load on masterReplication ThreadsBinlog dump threadSlave I/O threadSlave SQL threadReplication Filesrelay logmaster info logrelay log info logMySQL Replication OverviewThe relay log info log holds status information about theexecution point within the slaves relay log
  • 23. Copyright Oracle Corporation 2012 23Replication FormatsStatement-based replication (SBR)– Advantages• Less data written to log files• taking and restoring from backups are faster– Disadvantages• Some functions or queries arenondeterministic and hard to replicateRow-based replication (RBR)– Advantages• safest form of replication• Fewer row locks are required on the slave– Disadvantages• generate more data that must be logged*• Blob values take longer to replicateMixed-format– statement-based logging is used by default– automatically switches to row-based logging inparticular casesMySQL Replication Overviewhttp://dev.mysql.com/doc/refman/5.5/en/replication-formats.htmlhttp://dev.mysql.com/doc/refman/5.1/en/binary-log-setting.html
  • 24. Copyright Oracle Corporation 2012 24Asynchronous is standardevents are occurring independentlyThe master writes events to its binary log but does not know whetheror when a slave has retrieved and processed themif the master crashes, transactions that it has committed might nothave been transmitted to any slaveSemi-Synchronous support added in MySQL 5.5●Original patch: Mark Callaghan and Wei Li, GoogleAdoptions: Zhenxing He, Sun Microsystems●acknowledges receipt of a transactions events only after the eventshave been written to its relay log and flushed to disk●best for close servers communicating over fast networks●timeout occurs without any slave having acknowledged thetransaction, the master reverts to asynchronous replication. When atleast one semisynchronous slave catches up, the master returns tosemisynchronous replication.MySQL Replication Overviewhttp://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html
  • 25. Copyright Oracle Corporation 2012 25http://hiconsumption.com/2012/07/star-wars-recreations-of-iconic-photographs-by-david-eger/TM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.MySQL Replication Configuration
  • 26. Copyright Oracle Corporation 2012 26Master Setup:# vi /etc/my.cnf[mysqld]server-id=1log-bin = /var/lib/mysql/yoda-binStart and Log into MySQLmaster_yoda>show master statusG*************************** 1. row ***************************File: yoda-bin.000001Position: 114Binlog_Do_DB:Binlog_Ignore_DB:1 row in set (0.00 sec)# mysqldump -p --all-databases --master-data=2 > /tmp/replication_example.sqlTHIS LOCKS THE DATABASE!http://dev.mysql.com/doc/refman/5.5/en/replication-howto-masterbaseconfig.htmlhttp://www.minifigures.co.uk/lego/star-wars/master-yoda/TM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.MySQL Replication Configuration
  • 27. Copyright Oracle Corporation 2012 27On Master :mysql_yoda>CREATE USER replication@192.168.0.% IDENTIFIED BY slavepass;mysql_yoda>GRANT REPLICATION SLAVE ON *.* TO replication@%;mysql_yoda>flush privileges;Adjust all firewall rules if required for MySQL Port. (3306)http://dev.mysql.com/doc/refman/5.5/en/replication-howto-masterbaseconfig.htmlhttp://www.minifigures.co.uk/lego/star-wars/master-yoda/http://www.minifigures.co.uk/lego/star-wars/master-yoda/TM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.MySQL Replication Configuration
  • 28. Copyright Oracle Corporation 2012 28Slave Setup:vi /etc/my.cnf[mysqld]Server-id=2relay-log=/var/lib/mysql/luke-relay-bin# optional belowlog-bin = /var/lib/mysql/luke-binluke>show master statusG*************************** 1. row ***************************File: luke-bin.000003Position: 114Binlog_Do_DB:Binlog_Ignore_DB:1 row in set (0.00 sec)LOAD DATA:# mysql --user=root -p < /tmp/replication_example.sqlhttp://www.minifigures.co.uk/lego/star-wars/luke-skywalker-on-tatooine/TM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.MySQL Replication Configuration
  • 29. Copyright Oracle Corporation 2012 29On Slave :mysql_luke> CHANGE MASTER TOMASTER_HOST=yoda,MASTER_USER=replication,MASTER_PASSWORD=slavepass,MASTER_PORT=3306,MASTER_LOG_FILE=yoda-bin.000002,MASTER_LOG_POS=83415,MASTER_CONNECT_RETRY=10;We gathered this info from the mysqldump file via the“ --master-data=2 ” flag.-- CHANGE MASTER TOMASTER_LOG_FILE=yoda-bin.000002,MASTER_LOG_POS=83415;mysql_luke > start slave;Query OK, 0 rows affected (0.00 sec)http://www.minifigures.co.uk/lego/star-wars/luke-skywalker-on-tatooine/TM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.MySQL Replication Configuration
  • 30. Copyright Oracle Corporation 2012 30On Slave :mysql_luke> show slave statusGmysql_luke> show slave statusG*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: yodaMaster_User: replicationMaster_Port: 3306Connect_Retry: 10Master_Log_File: yoda-bin.000003Read_Master_Log_Pos: 323Relay_Log_File: luke-relay-bin.000004Relay_Log_Pos: 475Relay_Master_Log_File: yoda-bin.000003Slave_IO_Running: YesSlave_SQL_Running: YesMaster_Server_Id: 1Master_UUID: 75d407df-2be4-11e1-9668-b4be9bce39b0Seconds_Behind_Master: 0SQL_Remaining_Delay: NULLhttp://www.minifigures.co.uk/lego/star-wars/luke-skywalker-on-tatooine/TM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.MySQL Replication Configuration
  • 31. Copyright Oracle Corporation 2012 31Master to Mastermysql> SET GLOBAL auto_increment_offset=2;mysql> SET GLOBAL auto_increment_increment=2;mysql_yoda>show global variables like %auto_increment%;+--------------------------+-------+| Variable_name | Value |+--------------------------+-------+| auto_increment_increment | 2 || auto_increment_offset | 1 |+--------------------------+-------+mysql_luke>show global variables like %auto_increment%;+--------------------------+-------+| Variable_name | Value |+--------------------------+-------+| auto_increment_increment | 2 || auto_increment_offset | 2 |+--------------------------+-------+mysql_luke>SHOW MASTER STATUSG*************************** 1. row ***************************File: luke-bin.000005Position: 295mysql_yoda>CHANGE MASTER TOMASTER_HOST=luke,MASTER_USER=replication2,MASTER_PASSWORD=slavepass,MASTER_PORT=3306,MASTER_LOG_FILE=luke-bin.000005,MASTER_LOG_POS=295,MASTER_CONNECT_RETRY=10;mysql_yoda> start slave;http://www.minifigures.co.uk/lego/star-wars/master-yoda/http://legostarwars.wikia.com/wiki/Luke_Skywalker_%28Jedi%29TM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.MySQL Replication Configuration
  • 32. Copyright Oracle Corporation 2012 32Setting up replication with utilitiesmysqlreplicate --master=root@master.example.com --slave=root@slave.example.com --rpl-user=repl:xyzzyhttp://mysqlworkbench.org/utilities/man/mysqlreplicate.htmlRequire master and slave to be off-line!https://github.com/greyrl/generaltools/blob/master/mysqlreplicate.pyhttp://www.minifigures.co.uk/lego/star-wars/master-yoda/http://www.minifigures.co.uk/lego/star-wars/luke-skywalker-on-tatooine/TM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.MySQL 5.6: Replication Utilities (Python)
  • 33. Copyright Oracle Corporation 2012 33http://www.flickr.com/photos/kalexanderson/7719347704/in/set-72157628651430439/TM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.MySQL 5.6: ReplicationNew!
  • 34. Copyright Oracle Corporation 2012 34Global Transaction IDsMySQL UtilitiesMulti-Threaded SlavesBinary Log Group CommitOptimized Row Based ReplicationCrash Safe SlavesReplication Event ChecksumsTime Delayed Replicationhttp://dev.mysql.com/doc/refman/5.6/en/replication-features.htmlhttp://dev.mysql.com/downloads/mysql/#downloads Under Development ReleasesMySQL 5.6: ReplicationNew!
  • 35. Copyright Oracle Corporation 2012 35MySQL 5.6: ReplicationNew! Global Transaction Ids Simple to track & compare replication across the cluster- Unique identifier for each transaction written to the Binlog Automatically identify the most up-to-date slave for failover Deploy n-tier replication hierarchiesMasterGTID=123456GTID=123456GTID=123456 GTID=123456
  • 36. MasterGTID=123456GTID=123456GTID=123456 GTID=123456CHANGE MASTER TO??Slave(s) can start from same GTID●reference a global transactionidentifier and not have to convertbinary log filenames and offsetsbetween different serversCopyright Oracle Corporation 2012 36MySQL 5.6: ReplicationNew! Global Transaction Ids
  • 37. MySQL 5.6: Replication HA Utilities (Python) Enabling self-healing replication topologies Automated failover & recovery- mysqlfailover Utility Switchover & administration- mysqlrpladmin Utility Delivers HA within the core MySQLdistribution- Eliminates the need for 3rd party solutions- Allows extensibility to support variety ofHA mechanismshttps://launchpad.net/mysql-utilities/FailedMasterPromotedMasterSlavesMonitoring HA Utilities
  • 38. • Database Operations• mysqldbcompare – compare databases• mysqldbcopy – copy databases between servers• mysqldbexport – export metadata and data• mysqldbimport – import metadata and data• mysqldiff – compare object definitions• General Utilities• mysqldiskusage – show disk usage for databases• mysqlindexcheck – check for redundant indexes• mysqlmetagrep – search metadata• mysqlprocgrep – search process information• mysqluserclone – clone a user accountMySQL 5.6: Replication HA Utilities (Python)
  • 39. • High Availability• mysqlfailover – automatic failover for MySQL 5.6.5+• mysqlreplicate – setup replication• mysqlrpladmin – general replication administration• switchover• failover for MySQL 5.6.5 • mysqlrplcheck – check replication configuration• mysqlrplshow – display map of replication topology• Server Operations• mysqlserverclone – start a scratch server• mysqlserverinfo – show server informationMySQL 5.6: Replication HA Utilities (Python)
  • 40. How do I access the utilities?
  • 41. Copyright Oracle Corporation 2012 41MySQL 5.6: ReplicationMulti-Threaded Slaves Increases slave throughput,reducing lag All transactions received intoslave’s relay log Implements multiple SQL threads,based on database Applies events to differentdatabases in parallel Great for systems which isolateapplication data using databases– e.g. multi-tenant 5x performance gain SysBench, running across 10 x schemas Oracle Linux 6.1, Oracle Sun Fire x4150 m2 Server0 5 10050100150200250300Multi-Threaded Slave PerformanceWorker ThreadsQueriesperSecond
  • 42. Copyright Oracle Corporation 2012 42Throughput of slave increased by allowing multiple slave threads:●0 - functionality disabled●0 to 1024Exec_Master_Log_Posn in SHOW SLAVE STATUS represents a“low-water” mark, before which no uncommitted transactions remain.Configure using:●slave-parallel-workers=4On a per-database basis●can process successive transactions on a given databasewithout waiting for updates on other databases to completehttp://dev.mysql.com/doc/refman/5.6/en/replication-options-slave.html#sysvar_slave_parallel_workersMySQL 5.6: ReplicationMulti-Threaded Slaves
  • 43. Copyright Oracle Corporation 2012 43mysql_luke> show slave statusG*************************** 1. row ***************************....Exec_Master_Log_Pos: 114mysql> show global variables like %workers%;+------------------------+-------+| Variable_name | Value |+------------------------+-------+| slave_parallel_workers | 0 |+------------------------+-------+1 row in set (0.00 sec)mysql> SET GLOBAL slave_parallel_workers=4;Query OK, 0 rows affected (0.00 sec)mysql> show global variables like %workers%;+------------------------+-------+| Variable_name | Value |+------------------------+-------+| slave_parallel_workers | 4 |+------------------------+-------+1 row in set (0.00 sec)http://dev.mysql.com/doc/refman/5.6/en/replication-options-slave.html#sysvar_slave_parallel_workersMySQL 5.6: ReplicationMulti-Threaded Slaves
  • 44. Copyright Oracle Corporation 2012 44MySQL 5.6: ReplicationBinary Log Group Commit Increases replication throughput byincreasing performance of themaster Commits multiple transactions as agroup to Binlog on disk Finer grained locking; reducing lockwait timesBinaryLogT4SessionT1 T2T3GroupcommitT4MasterDatabase155% Performance Gain
  • 45. Copyright Oracle Corporation 2012 45MySQL 5.6: ReplicationOptimized Row Base ReplicationPrimary Key Changed Columns New option: binlog-row-image=minimal Increases throughput for master and slave- Reduces Binlog size, memory & network bandwidth Only replicates elements of the Row image that have changed
  • 46. Copyright Oracle Corporation 2012 46Problem: Slave thread commits and then updatesslave data.what if it crashes in-between?●recovery issues - where to restart replication from?●file corruption vulnerability●administration hassleSolution: store data in (transactional) tables:●slaves data is updated transactionally●engine agnostic●crash-safeness (requires transactional tables) freesthe DBA to manually recover transactions after acrashhttp://farm6.static.flickr.com/5024/5554971120_df447dd31c.jpgTM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.MySQL 5.6: Crash safe Slaves, BinLog
  • 47. Copyright Oracle Corporation 2012 47MySQL 5.6: Crash safe Slaves, BinLog• Automatic recovery of a slave andBinlog after a failure• Binlog and table data are transactionallyconsistent• Resumes replication without Dev/Opintervention• Automatically rolling back replication tolast committed event• Eliminates risk of data loss orcorruptionDataPosition InfoCRASH!DataPosition InfoAtomicAtomicBefore:– Transaction Data: in tables– Replication Info: in filesMySQL 5.6– Transaction Data: in tables– Replication Info: in tablesTimeTime
  • 48. Copyright Oracle Corporation 2012 48●System tables:slave_master_info (mysql.slave_master_info)--master-info-repository=TABLEslave_relay_log_info (mysql.slave_relay_log_info)--relay-log-info-repository=TABLEmysql_slave> stop slave;mysql_slave> SET GLOBAL master_info_repository = TABLE;mysql_slave> SET GLOBAL relay_log_info_repository = TABLE;mysql_slave> start slave;Make sure you add to my.cnf– master-info-repository =TABLE●relay-log-info-repository =TABLE●Transactional tables enables transactional slave positions●Automatic conversion between files and tables on startup●Long time awaited featurehttp://dev.mysql.com/doc/refman/5.6/en/replication-options-binary-log.htmlMySQL 5.6: Crash safe Slaves, BinLog
  • 49. Copyright Oracle Corporation 2012 49mysql_slave> select * from slave_master_info G*************************** 1. row ***************************Master_id: 2Number_of_lines: 22Master_log_name: yoda-bin.000003Master_log_pos: 323Host: yodaUser_name: replicationUser_password: slavepassPort: 3306Connect_retry: 10Enabled_ssl: 0Ssl_ca:Ssl_capath:Ssl_cert:Ssl_cipher:Ssl_key:Ssl_verify_server_cert: 0Heartbeat: 1800Bind:Ignored_server_ids: 0Uuid: 75d407df-2be4-11e1-9668-b4be9bce39b0Retry_count: 86400Ssl_crl:Ssl_crlpath:1 row in set (0.00 sec)MySQL 5.6: Crash safe Slaves, BinLog
  • 50. Copyright Oracle Corporation 2012 50MySQL 5.6: Replication Event Checksums Ensures replicated data is correct,consistent and accessible Detects corrupt replication eventsbefore they’re applied– Returns an error Protects entire replication path– Memory– Disk– Network– BugsMaster Slave
  • 51. Copyright Oracle Corporation 2012 51Problem: Make replication slave to lag a specified amount of time behindthe master to:●To protect against user mistakes on the master.●To test how the system behaves when there is a lag.●To inspect what the database looked like long ago, without havingto reload a backup.Solution: The slave waits until a given number of seconds elapses beforeapplying the changes:●Delays configured per slave: flexible deployment;●Are implemented in the SQL thread layer.●Rolling Database Backups with Relayed ReplicationMySQL 5.6: ReplicationTime Delayed Replication
  • 52. Copyright Oracle Corporation 2012 52User interface:●CHANGE MASTER TO MASTER_DELAY = <NUM_SECONDS>;●mysql> stop slave;●mysql> CHANGE MASTER TO MASTER_DELAY=86400; start slave;●SHOW SLAVE STATUS:●SQL_Delay: 86400●SQL_Remaining_Delay: 86395●Slave_SQL_Running_State: Waiting until MASTER_DELAY seconds after masterexecuted event●RESET SLAVE clears the configured delay;Rolling forward delayed slaves until bad event:START SLAVE [SQL_THREAD] UNTIL MASTER_LOG_FILE = log_name,MASTER_LOG_POS = log_poshttp://dev.mysql.com/doc/refman/5.6/en/replication-delayed.htmlhttp://dev.mysql.com/doc/refman/5.6/en/start-slave.htmlMySQL 5.6: ReplicationTime Delayed Replication
  • 53. Copyright Oracle Corporation 2012 53slave2> CHANGE MASTER TO-> MASTER_HOST = localhost,-> MASTER_PORT = 3306,-> MASTER_USER = repl_user,-> MASTER_PASSWORD = pw,-> MASTER_DELAY = 86400;slave2> START SLAVE;MySQL 5.6: ReplicationTime Delayed Replication
  • 54. Copyright Oracle Corporation 2012 54mysql_luke> STOP SLAVE;mysql_luke>SHOW RELAYLOG EVENTS FROM 2337G*************************** 4. row ***************************Log_name: luke-relay-bin.000005Pos: 2674Event_type: QueryServer_id: 1End_log_pos: 2623Info: drop database tatooinemysql_luke> START SLAVE UNTIL-> MASTER_LOG_FILE=luke-relay-bin.000005,-> MASTER_LOG_POS=2674;http://www.minifigures.co.uk/lego/star-wars/darth-vader-minifig/TM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.MySQL 5.6: ReplicationTime Delayed Replication
  • 55. Copyright Oracle Corporation 2012 55●Do you know when a slave is behind?●What type of topology do you have?●Alerted on Errors?●Slow Queries?MySQL Enterprise MonitorAll the slaves paying attention?http://www.stormgrounds.com/fullwallpaper/320/Storm-Trooper-LegosTM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.
  • 56. Copyright Oracle Corporation 2012 56●Global view of MySQL environment●Automated, rules-based monitoring andalerts (SMTP, SNMP enabled)●Query capture, monitoring, analysisand tuning, correlated with Monitorgraphs●Visual monitoring of “hot” applicationsand servers●Real-time Replication Monitor withauto-discovery of master-slavetopologies●Integrated with MySQL SupportMySQL Enterprise Monitor
  • 57. Copyright Oracle Corporation 2012 57MySQL Enterprise MonitorMySQL Replication Monitoring
  • 58. Copyright Oracle Corporation 2012 58MySQL User GroupsNorth America●Atlanta, GA●Austin, TX●Boise, ID●Boston, MA●Cleveland, OH●Denver, CO●Dallas, TX●Huntsville, AL●Los Angeles, CAJapan and APAC●Taiwan●IndonesiaEurope●Helsinki●London●FranceMiddle East●Dubai●TurkeyComplete list of MySQL user groupshttps://wikis.oracle.com/display/mysql/List+of+MySQL+User+GroupsMySQL Community ManagersDave Stokes (david.stokes@oracle.com)Keith Larson (keith.larson@oracle.com)South America●Brazil●IndonesiaOceania●Sydney AustraliaMiddle East●Dubai●Turkey●Montreal, CAN●Minneapolis, MN●New York, NY●New Jersey, NJ●Philadelphia, PA●Raleigh, NC●San Francisco, CA●Seattle, WA●Toronto, CANTop Active MySQL User Groups
  • 59. Copyright Oracle Corporation 2012 59MySQL Available NowDevelopment Releases:●http://dev.mysql.com/downloads/mysql/#downloadsEvaluate the new features●Questions & Feedback: forums.mysql.com/list.php?26●Bugs: bugs.mysql.com/Replication in MySQL 5.5●mysql.com/why-mysql/white-papers/mysql-wp-replication.phpReplication 5.6 documentation●dev.mysql.com/doc/refman/5.6/en/replication.htmlPlanet●Planet.mysql.comMySQL High Availability●http://shop.oreilly.com/product/9780596807290.doLearn more about HA Solutions for MySQL●mysql.com/why-mysql/white-papers/mysql_wp_ha_strategy_guide.phphttp://www.stormgrounds.com/wallpaper/Miscellaneous/Stormtrooper-under-KeyboardTM & © 2012 Lucasfilm Ltd. All rights reserved. ©2012 The LEGO Group. All rights reserved.
  • 60. Copyright Oracle Corporation 2012 60keith.larson@oracle.com@larsonkeithhttp://www.flickr.com/photos/kalexanderson/7964300088/sizes/l/in/photostream/
  • 61. <Insert Picture Here>Thanks for attending!keith.larson@oracle.comsqlhjalp.blogspot.comsqlhjalp.com/pdf/