SlideShare une entreprise Scribd logo
1  sur  17
Télécharger pour lire hors ligne
Agnostic Database
        Replication...
             ...with Binary Logs




www.mor.ph
Methodology
    • Constant Binary Log Replication
      • Phase I - Logging
      • Phase II - Archiving
      • Phase III - Recovery
    • Failover - What to do when disaster
      strikes!


www.mor.ph
Methodology
      • Agnosticism?
        • The methodology described herein is not
             bound to one vendor’s DB

        • With proper scripting your code should
             be reusable for many vendors DB
             solutions

      • Non-Invasive
      • Drastically reduced downtime compared to
        traditional restore from backup methods

www.mor.ph
Phase I - Logging




www.mor.ph
Phase I - Logging


    • Set your DB server to create binary
      logs

    • Make logs a manageable size (<50MB)
    • To timeout or not to timeout?
    • Ensure time based sort-ability

www.mor.ph
Phase I - Logging
               PostgreSQL Example

    ‣ postgresql.conf
      # allows archiving to be done
      archive_mode = on
      # command to use to archive a logfile segment
      archive_command = '/path/to/your/archiving/script %p'
      # force a logfile segment switch after this time
      archive_timeout = 60

    ‣ Log naming
       000000010000000000000000
       000000010000000000000001
       ...
       00000001000000000000000f


www.mor.ph
Phase I - Logging
                    MySQL Example

    ‣ my.cnf
      # Where to store your binary logs
      log-bin=/var/log/mysql/bin/mysql-bin-log

      #Max size for each log segment
      max_binlog_size = 50MB


    ‣ Log naming
      mysql-bin-log.0001
      mysql-bin-log.0002
      ...



www.mor.ph
Phase II - Archiving




www.mor.ph
Phase II - Archiving

    • Ship logs to a reliable location
    • Ship logs regularly & often
    • Ensure file integrity
    • Do regular full dumps


www.mor.ph
Phase III - Recovery




www.mor.ph
Phase III - Recovery

    • Ship logs from your backup server
    • Ensure log ordering
    • Constant incremental recovery
    • Incremental Recovery is Replication


www.mor.ph
Phase III - Recovery
              PostgreSQL Example

    ‣ recovery.conf
        restore_command = '/var/pgsql/bin/warm-standby-s3 
        /var/pgsql/tripfile /var/pgsql/backups/WAL/%f quot;%pquot;'




www.mor.ph
Phase III - Recovery
                  MySQL Example

    ‣ No built-in mechanism
        sudo -u mysql ./latest-dump-s3.pl | mysql -h localhost




www.mor.ph
Failover - When disaster
            strikes!
    • “When” NOT “If”
      • Always assume your DB will go down
      • Have a failover plan A
      • Have a failover plan B
      • Best laid plan will fall to waste if you do
        not test/validate regularly


www.mor.ph
Failover - When disaster
            strikes!

      • Ensure final log segment recovery
      • Make your standby DB ‘active’
      • Update client apps
      • Start the replication chain again!


www.mor.ph
Warm Standby vs.
            Clustering

    • When to Cluster
    • Draw backs to clustering
    • The search for the holy 100%
      transparent clustering...



www.mor.ph
Additional Resources
    • http://www.postgresql.org/docs/8.3/
      interactive/wal.html

    • http://dev.mysql.com/doc/refman/6.0/en/
      backup-and-recovery.html

    • http://dev.mysql.com/doc/refman/6.0/en/
      point-in-time-recovery.html

    • http://dev.mysql.com/doc/refman/6.0/en/
      backup.html


www.mor.ph

Contenu connexe

Dernier

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Dernier (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

En vedette

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Agnostic DB Replication With Binary Logs

  • 1. Agnostic Database Replication... ...with Binary Logs www.mor.ph
  • 2. Methodology • Constant Binary Log Replication • Phase I - Logging • Phase II - Archiving • Phase III - Recovery • Failover - What to do when disaster strikes! www.mor.ph
  • 3. Methodology • Agnosticism? • The methodology described herein is not bound to one vendor’s DB • With proper scripting your code should be reusable for many vendors DB solutions • Non-Invasive • Drastically reduced downtime compared to traditional restore from backup methods www.mor.ph
  • 4. Phase I - Logging www.mor.ph
  • 5. Phase I - Logging • Set your DB server to create binary logs • Make logs a manageable size (<50MB) • To timeout or not to timeout? • Ensure time based sort-ability www.mor.ph
  • 6. Phase I - Logging PostgreSQL Example ‣ postgresql.conf # allows archiving to be done archive_mode = on # command to use to archive a logfile segment archive_command = '/path/to/your/archiving/script %p' # force a logfile segment switch after this time archive_timeout = 60 ‣ Log naming 000000010000000000000000 000000010000000000000001 ... 00000001000000000000000f www.mor.ph
  • 7. Phase I - Logging MySQL Example ‣ my.cnf # Where to store your binary logs log-bin=/var/log/mysql/bin/mysql-bin-log #Max size for each log segment max_binlog_size = 50MB ‣ Log naming mysql-bin-log.0001 mysql-bin-log.0002 ... www.mor.ph
  • 8. Phase II - Archiving www.mor.ph
  • 9. Phase II - Archiving • Ship logs to a reliable location • Ship logs regularly & often • Ensure file integrity • Do regular full dumps www.mor.ph
  • 10. Phase III - Recovery www.mor.ph
  • 11. Phase III - Recovery • Ship logs from your backup server • Ensure log ordering • Constant incremental recovery • Incremental Recovery is Replication www.mor.ph
  • 12. Phase III - Recovery PostgreSQL Example ‣ recovery.conf restore_command = '/var/pgsql/bin/warm-standby-s3 /var/pgsql/tripfile /var/pgsql/backups/WAL/%f quot;%pquot;' www.mor.ph
  • 13. Phase III - Recovery MySQL Example ‣ No built-in mechanism sudo -u mysql ./latest-dump-s3.pl | mysql -h localhost www.mor.ph
  • 14. Failover - When disaster strikes! • “When” NOT “If” • Always assume your DB will go down • Have a failover plan A • Have a failover plan B • Best laid plan will fall to waste if you do not test/validate regularly www.mor.ph
  • 15. Failover - When disaster strikes! • Ensure final log segment recovery • Make your standby DB ‘active’ • Update client apps • Start the replication chain again! www.mor.ph
  • 16. Warm Standby vs. Clustering • When to Cluster • Draw backs to clustering • The search for the holy 100% transparent clustering... www.mor.ph
  • 17. Additional Resources • http://www.postgresql.org/docs/8.3/ interactive/wal.html • http://dev.mysql.com/doc/refman/6.0/en/ backup-and-recovery.html • http://dev.mysql.com/doc/refman/6.0/en/ point-in-time-recovery.html • http://dev.mysql.com/doc/refman/6.0/en/ backup.html www.mor.ph