SlideShare a Scribd company logo
Yet Another Replication Tool
                          RubyRep




                           /               Denish Patel
                                         Database Architect



Friday, March 26, 2010                                        1
Who am I?




                     •   With OmniTi for more than 3 years

                     •   Manage high traffic database systems

                     •   Replication database system deployments

                     •   Not a core hacker of RubyRep

                     •   “Oh, We are hiring!!”

                     •   Contact : denish@omniti.com




Friday, March 26, 2010                                             2
Next 30 minutes ..



                     •   Replication

                     •   Various Tools

                     •   Slony? Why another tool ?

                     •   RubyRep

                         •   Install

                         •   Features

                         •   Examples

                         •   Tweaking replication policies




Friday, March 26, 2010                                       3
Replication

                     •   Types

                         •   Synchronous

                             •   Semi-synchronous (O My!)

                         •   Asynchronous

                     •   Methods

                         •   Master - Slave

                         •   Master - Master

                     •   Needs

                         •   Horizontal Scaling

                         •   Standby Database

                         •   Backup Database




Friday, March 26, 2010                                      4
Tools

                     Program           Type        Method     Based on

                   PgCluster -II Synchronous         M-M      Shared Disk

                          Slony-I   Asynchronous     M-S        Trigger

                         Bucardo    Asynchronous   M-M, M-S     Trigger

                         Londiste   Asynchronous     M-S        Trigger

                         Mammoth    Asynchronous     M-S         Log

                         RubyRep    Asynchronous   M-M, M-S     Trigger


Friday, March 26, 2010                                                      5
Why not Slony?




                     •   Replicated tables MUST need PK or UK

                     •   Doesn’t support large objects

                     •   Doesn’t support synchronizing tables outside of replication

                     •   Limitations of version compatibility

                     •   Difficult to setup

                     •   Doesn’t support Master - Master

                     •   Difficult to monitor and manage




Friday, March 26, 2010                                                                 6
RubyRep Toolset




                     •   Scan

                     •   Sync

                     •   Replicate




Friday, March 26, 2010               7
RubyRep Key Features

                     •   Easy to install, setup, configure and monitor

                     •   Platform independent

                     •   Table design independent

                         •   Simple PK

                         •   Combined PK

                         •   No PK

                     •   Supports large objects i.e bytea, tsvector

                     •   Database Version Independent

                     •   Database independent

                         •   PostgreSQL

                         •   MySQL




Friday, March 26, 2010                                                   8
Install



                     •   Standard Ruby Version

                         •   Install Ruby Environment , Install DB drivers , Install RubyRep

                         •   Difficult to install

                         •   Slower performance

                     •   JRuby Version

                         •   Install JVM, Download and Extract gzip file

                         •   Easy to install

                         •   Faster performance




Friday, March 26, 2010                                                                         9
Scan

                     •   Features

                         •   Compare “Left” and “Right” Databases/Tables

                         •   Customize batch size

                         •   Load on client server

                     •   Steps:

                         •   Generate config file

                             •    ./rubyrep generate omniti.conf

                         •   Configure

                         •   Run the Scan

                             •    ./rubyrep scan -c omniti.conf

                     •   Production Results

                             •    Users table with 60M rows and 45 columns

                             •    3 hours

                             •    Running from monitor server




Friday, March 26, 2010                                                       10
Scan

                     •   To scan all tables starting with ‘c’:

                         •   rubyrep scan -c omniti.conf /^c/

                     •   Scan with default options will produce output like this:

                         •   clients 100% ......................... 0

                         •   clients_details 100% ......................... 5

                     •   Options

                         •   -s, --summary[=detailed]

                         •   -d, --detailed[=mode]

                             •   full , keys, diff

                         •   -b, --progress-bar[=length]

                         •   -c, --config=CONFIG_FILE

                         •   --help




Friday, March 26, 2010                                                              11
Config
                         RR::Initializer::run do |config|config.left = {

                         :adapter => 'postgresql', # or 'mysql'

                         :database => 'omniti',

                         :username => 'dba',

                         :password => 'securepasswd',

                         :host   => '127.0.0.1',

                         :schema_search_path         => 'omniti’ }

                         config.right = {

                         :adapter => 'postgresql',

                         :database => 'omniti',

                         :username => 'dba',

                         :password => 'securepasswd',

                         :host   => '127.0.0.1',

                         :port   => '5484'

                         }

                         config.include_tables 'users,users_backup'

                         config.include_tables /^o/ # regexp matches all tables starting with o

                         end
Friday, March 26, 2010                                                                            12
Sync


                         •   Compare and Sync

                         •   :sync_conflict_handling - :ignore (default), :left_wins, :right_wins

                         •   :sync_record_handling

                                 •    :left_record_handling , :right_record_handling

                                 •    :ignore,   :delete,     :insert(default)

                         •   Logging

                                 •    :ignored_changes , :all_changes ,

                                 •    :ignored_conflicts , :all_conflicts

                         •   Others

                             •   :row_buffer_size , :commit_frequency

                             •   http://www.rubyrep.org/configuration.html




Friday, March 26, 2010                                                                              13
Sync
                         RR::Initializer::run do |config|config.left = {

                         :adapter => 'postgresql', # or 'mysql'

                         :database => 'omniti',

                         :username => 'dba',

                         :password => 'securepasswd',

                         :host   => '127.0.0.1',

                         :schema_search_path         => 'omniti’ }

                         config.right = {

                         :adapter => 'postgresql',

                         :database => 'omniti',

                         :username => 'dba',

                         :password => 'securepasswd',

                         :host   => '127.0.0.1',

                         :port   => '5484' }

                         # To match all tables except those ending with ‘backup’:

                         config.include_tables /./

                         config.exclude_tables /backup$/ #exclude tables ending with backup

                         end




Friday, March 26, 2010                                                                        14
Replicate

                     •   Replicate Database/Tables

                     •   Global vs Table specific settings

                     •   rubyrep replicate -c omniti.conf

                         •   Setup necessary infrastructure tables

                         •   Setup necessary triggers for the replicated tables

                         •   Initial scan is executed and synched

                     •   Tweak sequences

                         •    Left -Odd , Right -Even for M-M replication

                     •   Default M-M replication setting

                         •   :replicate_record _handling = :replicate

                     •   Replication Conflict handling

                         •   :later_wins, :earlier_wins

                         •   Automatically Sync newly created table(Restart required)

                     •   Uninstall

                         •   rubyrep uninstall -c omniti.conf




Friday, March 26, 2010                                                                  15
Replicate
                         RR::Initializer::run do |config|config.left = {

                         :adapter => 'postgresql', # or 'mysql'

                         :database => 'omniti',

                         :username => 'dba',

                         :password => 'securepasswd',

                         :host   => '127.0.0.1',

                         :schema_search_path         => 'omniti‘ }

                         config.right = {

                         :adapter => 'postgresql',

                         :database => 'omniti',

                         :username => 'dba',

                         :password => 'securepasswd',

                         :host   => '127.0.0.1',

                         :port   => '5484' }

                         config.options[:sync_conflict_handling] = :left_wins

                         config.options[:replication_conflict_handling] = :left_wins

                         config.add_table_options 'admin',

                                   :sync_conflict_handling => :right_wins,

                                   :replication_conflict_handling => :right_wins

                         config.include_tables /./

                         end




Friday, March 26, 2010                                                                 16
Master-Slave Config


                         config.include_tables /./ # regexp matching all tables in the database

                          config.options[:auto_key_limit] = 40

                          config.options[:adjust_sequences] = false

                          config.options[:sequence_increment] = 1

                          config.options[:replication_conflict_handling] = :left_wins

                          config.options[:logged_replication_events] = [

                                               :ignored_changes,

                                               :ignored_conflicts

                                                   ]

                         end




Friday, March 26, 2010                                                                            17
Customize as needed ...

                     •   Tables without PK

                         •   config.options[:auto_key_limit] = 2

                         •   config.add_table_options /_/, :auto_key_limit => 2

                         •   config.include_tables 'articles_tags', :key => ['article_id', 'tag_id']

                     •   Checks before and after

                         •   :before_table_sync => "SET foreign_key_checks = 0"

                         •   :after_table_sync => "SET foreign_key_checks = 1"

                     •   Low bandwidth with RubyRep Proxy

                         •   Benefits only Scan and Compare ; only difference is transferred

                         •   :proxy_host => '172.16.1.5', , :proxy_port => '9876'

                     •   Cascading replication

                         •   :rep_prefix to use separate triggers and tables




Friday, March 26, 2010                                                                                 18
References

                     •   Installation Notes

                         •   http://rubyforge.org/frs/?group_id=7932

                     •   User Guide

                         •   http://www.rubyrep.org/documentation.html

                     •   API Documentation

                         •   http://rubyrep.rubyforge.org/

                     •   Tutorials

                         •   http://www.rubyrep.org/tutorial.html

                     •   Blogs

                         •   http://denishjpatel.blogspot.com/2009/08/yet-another-
                             postgresql-replication-tool.html




Friday, March 26, 2010                                                               19
Thanks




                     •   Arndt Lehmann

                     •   Thank you!!




Friday, March 26, 2010                   20
Questions ?




Friday, March 26, 2010                 21

More Related Content

PDF
All The Little Pieces
PDF
No sql findings
PDF
MongoDB开发应用实践
PDF
A beginners guide to MariaDB
PDF
视觉中国的MongoDB应用实践(QConBeijing2011)
KEY
Modern Java Concurrency (Devoxx Nov/2011)
PDF
MariaDB: in-depth (hands on training in Seoul)
KEY
Deployment Strategies (Mongo Austin)
All The Little Pieces
No sql findings
MongoDB开发应用实践
A beginners guide to MariaDB
视觉中国的MongoDB应用实践(QConBeijing2011)
Modern Java Concurrency (Devoxx Nov/2011)
MariaDB: in-depth (hands on training in Seoul)
Deployment Strategies (Mongo Austin)

Similar to Yet Another Replication Tool: RubyRep (20)

PPTX
Clustrix Database Percona Ruby on Rails benchmark
PDF
Scaling Social Games
KEY
Andy Parsons Pivotal June 2011
PDF
My Sql And Search At Craigslist
PDF
My sql 5.6_replwebinar_may12
PPTX
Key-value databases in practice Redis @ DotNetToscana
PDF
Choosing a MySQL High Availability solution - Percona Live UK 2011
PDF
MySQL高可用
PDF
Buytaert kris my_sql-pacemaker
PDF
Drupal Con My Sql Ha 2008 08 29
PPT
MySQL 5.6 Updates
PDF
Keith Larson Replication
PDF
Developing polyglot persistence applications #javaone 2012
PDF
Deployment
PDF
MySQL High Availability Solutions
PDF
Mysqlhacodebits20091203 1260184765-phpapp02
PDF
MySQL High Availability Solutions
ZIP
mtl_rubykaigi
PPTX
No sql solutions - 공개용
PDF
Galera Multi Master Synchronous My S Q L Replication Clusters
Clustrix Database Percona Ruby on Rails benchmark
Scaling Social Games
Andy Parsons Pivotal June 2011
My Sql And Search At Craigslist
My sql 5.6_replwebinar_may12
Key-value databases in practice Redis @ DotNetToscana
Choosing a MySQL High Availability solution - Percona Live UK 2011
MySQL高可用
Buytaert kris my_sql-pacemaker
Drupal Con My Sql Ha 2008 08 29
MySQL 5.6 Updates
Keith Larson Replication
Developing polyglot persistence applications #javaone 2012
Deployment
MySQL High Availability Solutions
Mysqlhacodebits20091203 1260184765-phpapp02
MySQL High Availability Solutions
mtl_rubykaigi
No sql solutions - 공개용
Galera Multi Master Synchronous My S Q L Replication Clusters
Ad

More from Denish Patel (18)

PDF
Advanced Postgres Monitoring
PDF
Out of the Box Replication in Postgres 9.4(PgConfUS)
PDF
Out of the box replication in postgres 9.4(pg confus)
PDF
Out of the Box Replication in Postgres 9.4(pgconfsf)
PDF
Out of the Box Replication in Postgres 9.4(PgCon)
PDF
Out of the Box Replication in Postgres 9.4(PgCon)
PDF
Out of the box replication in postgres 9.4
PDF
Postgres in Amazon RDS
PDF
Choosing the "D" , Lightning talk
PDF
Scaling postgres
PDF
Deploying postgre sql on amazon ec2
PDF
Two Elephants Inthe Room
PPTX
Deploying Maximum HA Architecture With PostgreSQL
PPT
Deploying Maximum HA Architecture With PostgreSQL
PDF
P90 X Your Database!!
PDF
Achieving Pci Compliace
PDF
Using SQL Standards? Database SQL comparition
PDF
Oracle10g New Features I
Advanced Postgres Monitoring
Out of the Box Replication in Postgres 9.4(PgConfUS)
Out of the box replication in postgres 9.4(pg confus)
Out of the Box Replication in Postgres 9.4(pgconfsf)
Out of the Box Replication in Postgres 9.4(PgCon)
Out of the Box Replication in Postgres 9.4(PgCon)
Out of the box replication in postgres 9.4
Postgres in Amazon RDS
Choosing the "D" , Lightning talk
Scaling postgres
Deploying postgre sql on amazon ec2
Two Elephants Inthe Room
Deploying Maximum HA Architecture With PostgreSQL
Deploying Maximum HA Architecture With PostgreSQL
P90 X Your Database!!
Achieving Pci Compliace
Using SQL Standards? Database SQL comparition
Oracle10g New Features I
Ad

Recently uploaded (20)

PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Microbial diseases, their pathogenesis and prophylaxis
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
01-Introduction-to-Information-Management.pdf
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PDF
RMMM.pdf make it easy to upload and study
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Yogi Goddess Pres Conference Studio Updates
Paper A Mock Exam 9_ Attempt review.pdf.
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
What if we spent less time fighting change, and more time building what’s rig...
Microbial disease of the cardiovascular and lymphatic systems
A systematic review of self-coping strategies used by university students to ...
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Microbial diseases, their pathogenesis and prophylaxis
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Chinmaya Tiranga quiz Grand Finale.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
01-Introduction-to-Information-Management.pdf
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
Orientation - ARALprogram of Deped to the Parents.pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
UNIT III MENTAL HEALTH NURSING ASSESSMENT
RMMM.pdf make it easy to upload and study
Final Presentation General Medicine 03-08-2024.pptx
Anesthesia in Laparoscopic Surgery in India
Yogi Goddess Pres Conference Studio Updates

Yet Another Replication Tool: RubyRep

  • 1. Yet Another Replication Tool RubyRep / Denish Patel Database Architect Friday, March 26, 2010 1
  • 2. Who am I? • With OmniTi for more than 3 years • Manage high traffic database systems • Replication database system deployments • Not a core hacker of RubyRep • “Oh, We are hiring!!” • Contact : [email protected] Friday, March 26, 2010 2
  • 3. Next 30 minutes .. • Replication • Various Tools • Slony? Why another tool ? • RubyRep • Install • Features • Examples • Tweaking replication policies Friday, March 26, 2010 3
  • 4. Replication • Types • Synchronous • Semi-synchronous (O My!) • Asynchronous • Methods • Master - Slave • Master - Master • Needs • Horizontal Scaling • Standby Database • Backup Database Friday, March 26, 2010 4
  • 5. Tools Program Type Method Based on PgCluster -II Synchronous M-M Shared Disk Slony-I Asynchronous M-S Trigger Bucardo Asynchronous M-M, M-S Trigger Londiste Asynchronous M-S Trigger Mammoth Asynchronous M-S Log RubyRep Asynchronous M-M, M-S Trigger Friday, March 26, 2010 5
  • 6. Why not Slony? • Replicated tables MUST need PK or UK • Doesn’t support large objects • Doesn’t support synchronizing tables outside of replication • Limitations of version compatibility • Difficult to setup • Doesn’t support Master - Master • Difficult to monitor and manage Friday, March 26, 2010 6
  • 7. RubyRep Toolset • Scan • Sync • Replicate Friday, March 26, 2010 7
  • 8. RubyRep Key Features • Easy to install, setup, configure and monitor • Platform independent • Table design independent • Simple PK • Combined PK • No PK • Supports large objects i.e bytea, tsvector • Database Version Independent • Database independent • PostgreSQL • MySQL Friday, March 26, 2010 8
  • 9. Install • Standard Ruby Version • Install Ruby Environment , Install DB drivers , Install RubyRep • Difficult to install • Slower performance • JRuby Version • Install JVM, Download and Extract gzip file • Easy to install • Faster performance Friday, March 26, 2010 9
  • 10. Scan • Features • Compare “Left” and “Right” Databases/Tables • Customize batch size • Load on client server • Steps: • Generate config file • ./rubyrep generate omniti.conf • Configure • Run the Scan • ./rubyrep scan -c omniti.conf • Production Results • Users table with 60M rows and 45 columns • 3 hours • Running from monitor server Friday, March 26, 2010 10
  • 11. Scan • To scan all tables starting with ‘c’: • rubyrep scan -c omniti.conf /^c/ • Scan with default options will produce output like this: • clients 100% ......................... 0 • clients_details 100% ......................... 5 • Options • -s, --summary[=detailed] • -d, --detailed[=mode] • full , keys, diff • -b, --progress-bar[=length] • -c, --config=CONFIG_FILE • --help Friday, March 26, 2010 11
  • 12. Config RR::Initializer::run do |config|config.left = { :adapter => 'postgresql', # or 'mysql' :database => 'omniti', :username => 'dba', :password => 'securepasswd', :host => '127.0.0.1', :schema_search_path => 'omniti’ } config.right = { :adapter => 'postgresql', :database => 'omniti', :username => 'dba', :password => 'securepasswd', :host => '127.0.0.1', :port => '5484' } config.include_tables 'users,users_backup' config.include_tables /^o/ # regexp matches all tables starting with o end Friday, March 26, 2010 12
  • 13. Sync • Compare and Sync • :sync_conflict_handling - :ignore (default), :left_wins, :right_wins • :sync_record_handling • :left_record_handling , :right_record_handling • :ignore, :delete, :insert(default) • Logging • :ignored_changes , :all_changes , • :ignored_conflicts , :all_conflicts • Others • :row_buffer_size , :commit_frequency • http://www.rubyrep.org/configuration.html Friday, March 26, 2010 13
  • 14. Sync RR::Initializer::run do |config|config.left = { :adapter => 'postgresql', # or 'mysql' :database => 'omniti', :username => 'dba', :password => 'securepasswd', :host => '127.0.0.1', :schema_search_path => 'omniti’ } config.right = { :adapter => 'postgresql', :database => 'omniti', :username => 'dba', :password => 'securepasswd', :host => '127.0.0.1', :port => '5484' } # To match all tables except those ending with ‘backup’: config.include_tables /./ config.exclude_tables /backup$/ #exclude tables ending with backup end Friday, March 26, 2010 14
  • 15. Replicate • Replicate Database/Tables • Global vs Table specific settings • rubyrep replicate -c omniti.conf • Setup necessary infrastructure tables • Setup necessary triggers for the replicated tables • Initial scan is executed and synched • Tweak sequences • Left -Odd , Right -Even for M-M replication • Default M-M replication setting • :replicate_record _handling = :replicate • Replication Conflict handling • :later_wins, :earlier_wins • Automatically Sync newly created table(Restart required) • Uninstall • rubyrep uninstall -c omniti.conf Friday, March 26, 2010 15
  • 16. Replicate RR::Initializer::run do |config|config.left = { :adapter => 'postgresql', # or 'mysql' :database => 'omniti', :username => 'dba', :password => 'securepasswd', :host => '127.0.0.1', :schema_search_path => 'omniti‘ } config.right = { :adapter => 'postgresql', :database => 'omniti', :username => 'dba', :password => 'securepasswd', :host => '127.0.0.1', :port => '5484' } config.options[:sync_conflict_handling] = :left_wins config.options[:replication_conflict_handling] = :left_wins config.add_table_options 'admin', :sync_conflict_handling => :right_wins, :replication_conflict_handling => :right_wins config.include_tables /./ end Friday, March 26, 2010 16
  • 17. Master-Slave Config config.include_tables /./ # regexp matching all tables in the database config.options[:auto_key_limit] = 40 config.options[:adjust_sequences] = false config.options[:sequence_increment] = 1 config.options[:replication_conflict_handling] = :left_wins config.options[:logged_replication_events] = [ :ignored_changes, :ignored_conflicts ] end Friday, March 26, 2010 17
  • 18. Customize as needed ... • Tables without PK • config.options[:auto_key_limit] = 2 • config.add_table_options /_/, :auto_key_limit => 2 • config.include_tables 'articles_tags', :key => ['article_id', 'tag_id'] • Checks before and after • :before_table_sync => "SET foreign_key_checks = 0" • :after_table_sync => "SET foreign_key_checks = 1" • Low bandwidth with RubyRep Proxy • Benefits only Scan and Compare ; only difference is transferred • :proxy_host => '172.16.1.5', , :proxy_port => '9876' • Cascading replication • :rep_prefix to use separate triggers and tables Friday, March 26, 2010 18
  • 19. References • Installation Notes • http://rubyforge.org/frs/?group_id=7932 • User Guide • http://www.rubyrep.org/documentation.html • API Documentation • http://rubyrep.rubyforge.org/ • Tutorials • http://www.rubyrep.org/tutorial.html • Blogs • http://denishjpatel.blogspot.com/2009/08/yet-another- postgresql-replication-tool.html Friday, March 26, 2010 19
  • 20. Thanks • Arndt Lehmann • Thank you!! Friday, March 26, 2010 20