Introduction to Tungsten Replicator

  • 704 views
Uploaded on

An Introduction to Continuent Tungsten's replicator product from Percona Live 2013

An Introduction to Continuent Tungsten's replicator product from Percona Live 2013

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
704
On Slideshare
0
From Embeds
0
Number of Embeds
6

Actions

Shares
Downloads
16
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. ©Continuent 2012.Introduction to TungstenReplicatorNeil Armitage, Cluster implementation Engineer, Continuent1Monday, 22 April 13
  • 2. ©Continuent 2012.What is Tungsten replicator?2• Drop in replacement for native MySQLreplication.• Fully OpenSource under GPL v2• Heterogeneous Replication• Flexible topologies• Parallel replicationMonday, 22 April 13
  • 3. ©Continuent 2012.Tungsten replicator• Global transaction ID• Multiple masters• Multiple sources (Fan In)3Monday, 22 April 13
  • 4. ©Continuent 2012.Tungsten Replicator in a nutshellbinlog THLslavemasterhost1host2THLtrep_commit_seqnotrep_commit_seqnotrep_commit_seqnoorigin seqno eventidtrep_commit_seqnotrep_commit_seqnotrep_commit_seqnoorigin seqno eventidglobaltransaction ID4Monday, 22 April 13
  • 5. ©Continuent 2012.star-schemamaster-slave Heterogeneousfan-in slave all-mastersMySQLOracleOracleMySQL OracleOracleMySQL MySQLMonday, 22 April 13
  • 6. ©Continuent 2012.Why UseTungsten Replicator?6Monday, 22 April 13
  • 7. ©Continuent 2012.A failover scenario1: MySQL native replication7Monday, 22 April 13
  • 8. ©Continuent 2012.1. one Master, two slaves• Loading the “employees” test database8Monday, 22 April 13
  • 9. ©Continuent 2012.2. Master goes away* Stop replication* Slaves are updated at di!erent levels# 2select count(*) from titles333,145# 3select count(*) from titles443,3089Monday, 22 April 13
  • 10. ©Continuent 2012.3. Look into Slave #2 binary logs• "nd the last transaction10Monday, 22 April 13
  • 11. ©Continuent 2012.4. Look into Slave #3 binary logs1. "nd the transaction that was last in slave #22. Recognize that last transaction in the log ofslave #3 (This can actually take you aLOOOONG TIME)3. Get the position immediately after thistransaction4. (e.g. 134000 in "le mysql-bin.000018)11Monday, 22 April 13
  • 12. ©Continuent 2012.5. promote Slave #3 to master* in slave #2CHANGE MASTER TOmaster_host=‘slave_3_IP’,master_user=‘slavename’,master_password=‘slavepassword’,master_log_file=‘mysql-bin.000018’,master_log_pos=134000;12Monday, 22 April 13
  • 13. ©Continuent 2012.A failover scenario1I:Tungsten Replicator13Monday, 22 April 13
  • 14. ©Continuent 2012.1. one master, two slaves• loading the ‘employees’ test database14Monday, 22 April 13
  • 15. ©Continuent 2012.2. Master goes away* Stop replication* Slaves are updated at di!erent levels# 2select count(*) from titles333,145# 3select count(*) from titles443,30815Monday, 22 April 13
  • 16. ©Continuent 2012.3. no need to !nd the last transaction# simply change rolestrepctl -host slave3 setrole -role mastertrepctl -host slave2 setrole -role slave -uri thl://slave3trepctl -host slave3 onlineState: ONLINEtrepctl -host slave2 onlineState: GOING-ONLINE:SYNCHRONIZING16Monday, 22 April 13
  • 17. ©Continuent 2012.4. Check that the slave hassynchronized# new masterselect seqno from tungsten.trep_commit_seqno;78# new slaveselect seqno from tungsten.trep_commit_seqno;6417Monday, 22 April 13
  • 18. ©Continuent 2012.4. ... and we’re done# new masterselect count(*) from employees.titlescount(*)443308# new slave:count(*)44330818Monday, 22 April 13
  • 19. ©Continuent 2012.Filters19Monday, 22 April 13
  • 20. Replicator Pipeline ArchitectureTHL SlaveDBMSTransactionHistory LogMySQLBinlogApplyExtract ExtractPipelineTungsten Replicator ProcessStageApplyExtractAssignShardIDApplyStageStageMonday, 22 April 13
  • 21. Replicator Pipeline ArchitectureTHL SlaveDBMSTransactionHistory LogMySQLBinlogApplyExtract ExtractPipelineTungsten Replicator ProcessStageApplyExtractAssignShardIDApplyStageStagefilter filterMonday, 22 April 13
  • 22. ©Continuent 2012.Restrict replication to some schemasand tables21./tools/tungsten-installer --master-slave -a   ...  --svc-extractor-filters=replicate   "--property=replicator.filter.replicate.do=test,*.foo"   ...  --start-and-report# test="test.*" -> same drawback as binlog-do-db in MySQL# *.foo = table foo in any database# employees.dept_codes,employees.salaries => safest wayMonday, 22 April 13
  • 23. ©Continuent 2012.Exclude some schemas and tablesfrom replication22./tools/tungsten-installer --master-slave -a   ...  --svc-extractor-filters=replicate   "--property=replicator.filter.replicate.ignore=test,*.foo"   ...  --start-and-report# test="test.*" -> same drawback as binlog-ignore-db in MySQL# *.foo = table foo in any database# employees.dept_codes,employees.salaries => safest way# DO NOT MIX .do and .ignore!# (you can do it, but it may not do what you mean)Monday, 22 April 13
  • 24. ©Continuent 2012.Change name of replicated schema23-a --svc-applier-filters=dbtransform   --property=replicator.filter.dbtransform.from_regex1=stores   --property=replicator.filter.dbtransform.to_regex1=playground# from_regex1=stores -> name of the schema in the master# to_regex1=playground -> name of the schema in the slave# WARNING: requires "USE schema_name" to work properly.Monday, 22 April 13
  • 25. ©Continuent 2012.parallel replication24Monday, 22 April 13
  • 26. Replicator Pipeline ArchitectureTHL SlaveDBMSTransactionHistory LogMySQLBinlogshard.listfileApplyExtract ExtractPipelineTungsten Replicator ProcessStageApplyExtractApplyExtractApplyExtractParallelQueueAssignShardIDApplyStageStage“channels”Monday, 22 April 13
  • 27. ©Continuent 2012.Parallel replication facts✓Sharded by database✓Good choice for slave lag problems❖Bad choice for single database projects26Monday, 22 April 13
  • 28. Parallel Replication testbinary logsMySQL slaveTungsten slaveOFFLINESTOPPEDreplicator alphadirect:alpha(slave)Concurrent sysbenchon 30 databasesrunning for 1 hourTOTAL DATA: 130 GBRAM per server: 20GBSlaves will have 1 hour lagMonday, 22 April 13
  • 29. measuring resultsbinary logsMySQL slaveTungsten slaveONLINESTARTreplicator alphadirect:alpha(slave)Recordingcatch-up timeMonday, 22 April 13
  • 30. MySQL nativereplicationslave catch up in 04:29:30Monday, 22 April 13
  • 31. Tungsten parallelreplicationslave catch up in 00:55:40Monday, 22 April 13
  • 32. Parallel replication made simplerFROM HERE ....Monday, 22 April 13
  • 33. Parallel replication made simplerTO HEREMonday, 22 April 13
  • 34. Parallel replication made simplerMonday, 22 April 13
  • 35. ©Continuent 2012.parallel replicationdirect slave facts34Monday, 22 April 13
  • 36. ©Continuent 2012.parallel replicationdirect slave facts✓No need to install Tungsten on the master34Monday, 22 April 13
  • 37. ©Continuent 2012.parallel replicationdirect slave facts✓No need to install Tungsten on the master✓Tungsten runs only on the slave34Monday, 22 April 13
  • 38. ©Continuent 2012.parallel replicationdirect slave facts✓No need to install Tungsten on the master✓Tungsten runs only on the slave✓Replication can revert to native slave with twocommands (trepctl offline; start slave)34Monday, 22 April 13
  • 39. ©Continuent 2012.parallel replicationdirect slave facts✓No need to install Tungsten on the master✓Tungsten runs only on the slave✓Replication can revert to native slave with twocommands (trepctl offline; start slave)✓Native replication can continue on other slaves34Monday, 22 April 13
  • 40. ©Continuent 2012.parallel replicationdirect slave facts✓No need to install Tungsten on the master✓Tungsten runs only on the slave✓Replication can revert to native slave with twocommands (trepctl offline; start slave)✓Native replication can continue on other slaves❖Failover (either native or Tungsten) becomes a manualtask34Monday, 22 April 13
  • 41. ©Continuent 2012.Checking parallel replicationtrepctl statustrepctl status -name taskstrepctl status -name shardstrepctl status -name stores35Monday, 22 April 13
  • 42. ©Continuent 2012.Tungsten GTID vs MySQL 5.6 GTID• What is GTID• How it works in Tungsten• How it works (or not) in MySQL 5.636Monday, 22 April 13
  • 43. ©Continuent 2012.without global transaction ID37slavemasterslaveAB CcommitcommitcommitcommitbinlogpositionbinlogpositionpositionbinlogMonday, 22 April 13
  • 44. ©Continuent 2012.with global transaction ID38slavemasterslaveAB Ccommitcommitcommitcommitid#200id#200id#200Monday, 22 April 13
  • 45. ©Continuent 2012.Tungsten and global transaction ID:activation(none)active by default39Monday, 22 April 13
  • 46. ©Continuent 2012.Tungsten and global transaction ID:statustrepctl statusProcessing status command...NAME VALUE---- -----appliedLastEventId : mysql-bin.000002:0000000000001442;0appliedLastSeqno : 6appliedLatency : 0.862clusterName : defaultcurrentEventId : NONEcurrentTimeMillis : 1354304680923dataServerHost : qa.r4.continuent.com40Monday, 22 April 13
  • 47. ©Continuent 2012.Tungsten and global transaction ID:seeing transactionsthl list -seqno 6SEQ# = 6 / FRAG# = 0 (last frag)- TIME = 2012-11-30 20:44:35.0- EPOCH# = 0- EVENTID = mysql-bin.000002:0000000000001442;0- SOURCEID = qa.r1.continuent.com- SQL(0) = insert into test.v1 values (1, insertedby node #1) /* ___SERVICE___ = [cookbook] */41Monday, 22 April 13
  • 48. ©Continuent 2012.Tungsten and global transaction ID:changing master connectiontrepctl offlinetrepctl online -seqno 10542Monday, 22 April 13
  • 49. ©Continuent 2012.Tungsten and Global transaction ID:crash-safe slave tablesmysql -e select * from tungsten_cookbook.trep_commit_seqnoG*************************** 1. row ***************************task_id: 0seqno: 6fragno: 0last_frag: 1source_id: qa.r1.continuent.comepoch_number: 0eventid: mysql-bin.000002:0000000000001442;0applied_latency: 0update_timestamp: 2012-11-30 20:44:35shard_id: testextract_timestamp: 2012-11-30 20:44:3543Monday, 22 April 13
  • 50. ©Continuent 2012.Tungsten and Global transaction ID:crash-safe tables and parallel replicationmysql -e select seqno, source_id, shard_id,update_timestamp fromtungsten_cookbook.trep_commit_seqno+-------+----------------------+----------+---------------------+| seqno | source_id | shard_id | update_timestamp |+-------+----------------------+----------+---------------------+| 7 | qa.r1.continuent.com | db1 | 2012-11-30 20:54:14 || 8 | qa.r1.continuent.com | db2 | 2012-11-30 20:54:14 || 9 | qa.r1.continuent.com | db3 | 2012-11-30 20:54:14 || 10 | qa.r1.continuent.com | db4 | 2012-11-30 20:54:14 || 11 | qa.r1.continuent.com | db5 | 2012-11-30 20:54:14 || 12 | qa.r1.continuent.com | db6 | 2012-11-30 20:54:14 || 13 | qa.r1.continuent.com | db7 | 2012-11-30 20:54:14 || 14 | qa.r1.continuent.com | db8 | 2012-11-30 20:54:14 || 15 | qa.r1.continuent.com | db9 | 2012-11-30 20:54:14 || 16 | qa.r1.continuent.com | db10 | 2012-11-30 20:54:14 |+-------+----------------------+----------+---------------------+44Monday, 22 April 13
  • 51. ©Continuent 2012.MySQL 5.6 and global transaction IDactivationmysqld --log-slave-updates --gtid-mode=on --enforce-gtid-consistency45Monday, 22 April 13
  • 52. ©Continuent 2012.MySQL 5.6 and global transaction IDseeing transactions#121203 11:15:49 server id 1 end_log_pos 344 CRC32 0x45b25c8fGTID [commit=yes]SET @@SESSION.GTID_NEXT= 7A77A490-3D3A-11E2-8CC9-7DCF9991097B:2/*!*/;# at 344#121203 11:15:49 server id 1 end_log_pos 423 CRC32 0x873c8facQuery thread_id=3 exec_time=0 error_code=0SET TIMESTAMP=1354533349/*!*/;BEGIN/*!*/;# at 423#121203 11:15:49 server id 1 end_log_pos 522 CRC32 0xb4bf4372Query thread_id=3 exec_time=0 error_code=0SET TIMESTAMP=1354533349/*!*/;insert into t1 values (1)46Monday, 22 April 13
  • 53. ©Continuent 2012.MySQL 5.6 and global transaction IDstatusshow slave statusG*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 127.0.0.1Master_User: rsandboxMaster_Port: 13233Connect_Retry: 60Master_Log_File: mysql-bin.000002Read_Master_Log_Pos: 1837Relay_Log_File: mysql_sandbox13234-relay-bin.000005Relay_Log_Pos: 2047Relay_Master_Log_File: mysql-bin.000002...Retrieved_Gtid_Set: 46E13434-3B28-11E2-BF47-6C626DA07446:1-7Executed_Gtid_Set: 46E13434-3B28-11E2-BF47-6C626DA07446:1-747Monday, 22 April 13
  • 54. ©Continuent 2012.MySQL 5.6 and global transaction IDchanging master connectionCHANGE MASTER TO master_log_file=mysql-bin-000003,master_log_pos=1234# No global transaction ID is used48Monday, 22 April 13
  • 55. ©Continuent 2012.MySQL 5.6 and global transaction IDcrash-safe slave tableselect * from slave_relay_log_infoG********************* 1. row ********************Number_of_lines: 7Relay_log_name: ./mysql_sandbox13234-relay-bin.000005Relay_log_pos: 2047Master_log_name: mysql-bin.000002Master_log_pos: 1837Sql_delay: 0Number_of_workers: 5Id: 1# NO Global transaction ID is used!49Monday, 22 April 13
  • 56. ©Continuent 2012.MySQL 5.6 and global transaction IDcrash-safe slave table + parallelselect * from mysql.slave_worker_infoGId: 12Relay_log_name: ./mysql_sandbox13234-relay-bin.000007Relay_log_pos: 4299Master_log_name: mysql-bin.000002Master_log_pos: 7155Checkpoint_relay_log_name: ./mysql_sandbox13234-relay-bin.000007Checkpoint_relay_log_pos: 1786Checkpoint_master_log_name: mysql-bin.000002Checkpoint_master_log_pos: 4642Checkpoint_seqno: 9Checkpoint_group_size: 64Checkpoint_group_bitmap: ?# NO Global transaction ID is used!50Monday, 22 April 13
  • 57. ©Continuent 2012.Installation51Monday, 22 April 13
  • 58. ©Continuent 2012.Installation• System Requirements• Validate "rst• Deploying from a single location52Monday, 22 April 13
  • 59. ©Continuent 2012.Installation - tools• tools/ tungsten-installer• tools/ con"gure-service• tools/update• (Using the cookbook recipes, you hardly seethem)53Monday, 22 April 13
  • 60. ©Continuent 2012.Tungsten in practiceInstallation54Monday, 22 April 13
  • 61. ©Continuent 2012.Installation• Check the requirements• Get the binaries• Expand the tarball• Run cookbook55Monday, 22 April 13
  • 62. ©Continuent 2012.REQUIREMENTS• Java JRE or JDK (Sun/Oracle or Open-jdk)• Ruby 1.8 (only during installation)• ssh access to the same user in all nodes• MySQL user with all privileges56Monday, 22 April 13
  • 63. ©Continuent 2012.binlogTHLTHLslaveslavemasterhost1host2host3THL57master-slaveMonday, 22 April 13
  • 64. ©Continuent 2012.binlogTHLslavemasterrelay loghost1host2host3THLslaverelay log58directMonday, 22 April 13
  • 65. ©Continuent 2012.Demo• Install Master Slave using the Cookbook59Monday, 22 April 13
  • 66. ©Continuent 2012.Overview of Tungstencookbook60Monday, 22 April 13
  • 67. ©Continuent 2012.tungsten cookbooktungsten-replicator-2.0.7-xx|+--/cluster-home+--/cookbook+--/tools+--/tungsten-replicator61Monday, 22 April 13
  • 68. ©Continuent 2012.tungsten cookbooktungsten-replicator-2.0.7-xx|+--/cookbook|+--COMMON_NODES.sh+--USER_VALUES.sh+--NODES_MASTER_SLAVE.sh+--show_master_slave.sh+--test_master_slave.sh+--clear_cluster_master_slave.sh...62Monday, 22 April 13
  • 69. ©Continuent 2012.tungsten cookbooktungsten-replicator-2.0.7-xx|+--/cookbook|+--COMMON_NODES.sh+--USER_VALUES.sh+--NODES_STAR.sh+--show_star.sh+--test_star.sh+--clear_cluster_star.sh...63Monday, 22 April 13
  • 70. ©Continuent 2012.Master - to - master• Bi-directional installation• Operational steps:• install a master service in both servers• install the corresponding slave service in theother server64master-alphaslave-bravomaster-bravoslave-alphaMonday, 22 April 13
  • 71. ©Continuent 2012.BI-DIR: the painless way• edit cookbook/COMMON_NODES.sh• edit cookbook/USER_VALUES.sh• remove two nodes• edit the variables in cookbook/NODES_ALL_MASTERS.sh• cookbook/install_all_masters.sh65Monday, 22 April 13
  • 72. ©Continuent 2012. 66master-alphaslave-bravoslave-charlieslave-deltamaster-bravoslave-alphaslave-charlieslave-deltamaster-charlieslave-alphaslave-bravoslave-deltamaster-deltaslave-alphaslave-bravoslave-charlieall-mastersABCDDABCMonday, 22 April 13
  • 73. ©Continuent 2012.Multiple masters• fan-in• Steps:• install a master service in each node• install a slave service for each master in the fan-in node• or :• cookbook/install_fan_in.sh67Monday, 22 April 13
  • 74. ©Continuent 2012.Master - to - master• star schema• Steps:• install a master service in each server• in the hub, install a slave service for each spoke• in each spoke, install a slave service for the hub,using bypass option• cookbook/install_star.sh68Monday, 22 April 13
  • 75. ©Continuent 2012For more information download theslides from Mondays Tutorial69Monday, 22 April 13
  • 76. ©Continuent 2012 70Continuent Website:http://www.continuent.comTungsten Replicator 2.0:http://code.google.com/p/tungsten-replicatorOur Blogs:http://scale-out-blog.blogspot.comhttp://datacharmer.blogspot.comhttp://flyingclusters.blogspot.com560 S.Winchester Blvd., Suite 500San Jose, CA 95128Tel +1 (866) 998-3642Fax +1 (408) 668-1009e-mail: sales@continuent.comMonday, 22 April 13