SlideShare a Scribd company logo
1 of 16
© 2013 EnterpriseDB Corporation - All rights reserved. 1
Streaming Replication
Switchover/Switchback
Vibhor Kumar
Principal System Engineer.
© 2013 EnterpriseDB Corporation - All rights reserved. 2
• PostgreSQL Streaming Replication
• Limitations in PG Version < 9.3
• Understanding Timelines
• New in PostgreSQL >=9.3
• Possible switchover/switchback
• Things to know about switchover/switchback
• recovery.conf
Agenda
© 2013 EnterpriseDB Corporation - All rights reserved. 3
PostgreSQL Streaming Replication (SR)
• Streaming Replication (SR) provides capability to
continuously ship and apply WAL/XLOG records to any
number of standbys.
• Introduced in PostgreSQL 9.0
• Currently two types supported:
− Synchronous SR
− Asynchronous SR
© 2013 EnterpriseDB Corporation - All rights reserved. 4
History: Streaming Replication
• 9.0: Asynchronous SR
• 9.1:
− Synchronous SR
− pg_basebackup
• 9.2:
− Cascaded Replication
− Backup from Standby
− New Sync replication mode. (remote_write, local write)
• 9.3
− Streaming only replication.
− Follow timeline changes.
© 2013 EnterpriseDB Corporation - All rights reserved. 5
Limitations before 9.3
• Timeline streaming issue
• Intentional shutdown on master can leave Standby behind
the master before 9.1.
• If Standby is behind master:
− Promote lead to new timeline.
− Difference in Master and Standby.
− Old Master can’t be standby of new master.
− Need to take fresh backup or manual copy timeline file to old master.
• Painful to take fresh backup if database size is large.
© 2013 EnterpriseDB Corporation - All rights reserved. 6
Understanding Timelines
• Introduced with Point-in-Time-Recovery in version 8.0
• Every time you do PITR, a new timeline is formed
• Timelines helps to differentiate WAL generated from
different PITR.
• When new WAL generated after PITR, PostgreSQL
shouldn’t overwrite old WAL.
© 2013 EnterpriseDB Corporation - All rights reserved. 7
More about Timelines
© 2013 EnterpriseDB Corporation - All rights reserved. 8
More about Timelines
© 2013 EnterpriseDB Corporation - All rights reserved. 9
Timeline history file
© 2013 EnterpriseDB Corporation - All rights reserved. 10
New in 9.3 SR
• Important Patches:
− commit 985bd7d49726c9f178558491d31a570d47340459
− Author: Fujii Masao
− Committed on Wed Jun 26 02:14:37 2013 +0900
− Make sures when we shutdown the master, walsender
should tries to send all outstandng WAL records
to Standby, and then to exit.
− Back patched till 9.1
− commit abfd192b1b5ba5216ac4b1f31dcd553106304b19
− Author: Heikki Linnakangas
− Committed on Thu Dec 13 19:00:00 2012 +0200
− Allow a streaming replication standby to follow a
timeline switch. (Only in 9.3)
© 2013 EnterpriseDB Corporation - All rights reserved. 11
9.3: Now switchover/Switchback is possible
• Difference between Switchover and Failover. (add points)
• New commit in PostgreSQL helps:
− Clean shutdown for maintenance operation of master server
− Old master server can be new standby for New Master.
− No more fresh backup in intentional promotion.
© 2013 EnterpriseDB Corporation - All rights reserved. 12
Things to know: switchover/switchback
• Use –m fast or –m smart shutdown on Master for clean
shutdown.
• Before promoting standby:
− Make sure all WAL sent by Master applied on elected node for New
Master.
− Use following function for when to promote:
− pg_last_xlog_receive_location
− pg_last_xlog_replay_location
− Have proper archive location accessible to old Master.
− Set proper archive_command
© 2013 EnterpriseDB Corporation - All rights reserved. 13
recovery.conf
recovery_target_timeline = 'latest'
standby_mode = 'on’
primary_conninfo = 'user=repuser
password=repuser host=172.17.0.3 port=5432
restore_command = ‘cp /location/%f %p’
© 2013 EnterpriseDB Corporation - All rights reserved. 14
EFM: Promote Steps
• When promote happens, EFM does following:
− Send prepare information to Master, Witness and Slave
− Agent on Master get promote signal and does following:
− Release VIP if any.
− create dummy recovery.conf, so that next startup master shouldn’t come
up.
− Message about Master failed.
− Standby signaled to be promoted by trigger.
• Explore EFM for possible switchover/switchback
© 2013 EnterpriseDB Corporation - All rights reserved. 15
Demo
© 2013 EnterpriseDB Corporation - All rights reserved. 16
Thanks

More Related Content

What's hot

PostgreSQL - C言語によるユーザ定義関数の作り方
PostgreSQL - C言語によるユーザ定義関数の作り方PostgreSQL - C言語によるユーザ定義関数の作り方
PostgreSQL - C言語によるユーザ定義関数の作り方
Satoshi Nagayasu
 
PostgreSQL Performance Tuning
PostgreSQL Performance TuningPostgreSQL Performance Tuning
PostgreSQL Performance Tuning
elliando dias
 

What's hot (20)

5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance5 Steps to PostgreSQL Performance
5 Steps to PostgreSQL Performance
 
PostgreSQL - C言語によるユーザ定義関数の作り方
PostgreSQL - C言語によるユーザ定義関数の作り方PostgreSQL - C言語によるユーザ定義関数の作り方
PostgreSQL - C言語によるユーザ定義関数の作り方
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 
PostgreSQL Performance Tuning
PostgreSQL Performance TuningPostgreSQL Performance Tuning
PostgreSQL Performance Tuning
 
pg_hint_planを知る(第37回PostgreSQLアンカンファレンス@オンライン 発表資料)
pg_hint_planを知る(第37回PostgreSQLアンカンファレンス@オンライン 発表資料)pg_hint_planを知る(第37回PostgreSQLアンカンファレンス@オンライン 発表資料)
pg_hint_planを知る(第37回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
Mastering PostgreSQL Administration
Mastering PostgreSQL AdministrationMastering PostgreSQL Administration
Mastering PostgreSQL Administration
 
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오
[Pgday.Seoul 2017] 3. PostgreSQL WAL Buffers, Clog Buffers Deep Dive - 이근오
 
What is new in PostgreSQL 14?
What is new in PostgreSQL 14?What is new in PostgreSQL 14?
What is new in PostgreSQL 14?
 
Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.Deep dive into PostgreSQL statistics.
Deep dive into PostgreSQL statistics.
 
PostgreSQL HA
PostgreSQL   HAPostgreSQL   HA
PostgreSQL HA
 
PostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized WorldPostgreSQL High Availability in a Containerized World
PostgreSQL High Availability in a Containerized World
 
オンライン物理バックアップの排他モードと非排他モードについて(第15回PostgreSQLアンカンファレンス@オンライン 発表資料)
オンライン物理バックアップの排他モードと非排他モードについて(第15回PostgreSQLアンカンファレンス@オンライン 発表資料)オンライン物理バックアップの排他モードと非排他モードについて(第15回PostgreSQLアンカンファレンス@オンライン 発表資料)
オンライン物理バックアップの排他モードと非排他モードについて(第15回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
PostgreSQLのgitレポジトリから見える2022年の開発状況(第38回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQLのgitレポジトリから見える2022年の開発状況(第38回PostgreSQLアンカンファレンス@オンライン 発表資料)PostgreSQLのgitレポジトリから見える2022年の開発状況(第38回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQLのgitレポジトリから見える2022年の開発状況(第38回PostgreSQLアンカンファレンス@オンライン 発表資料)
 
PostgreSQL and RAM usage
PostgreSQL and RAM usagePostgreSQL and RAM usage
PostgreSQL and RAM usage
 
PostgreSQL Deep Internal
PostgreSQL Deep InternalPostgreSQL Deep Internal
PostgreSQL Deep Internal
 
オンライン物理バックアップの排他モードと非排他モードについて ~PostgreSQLバージョン15対応版~(第34回PostgreSQLアンカンファレンス...
オンライン物理バックアップの排他モードと非排他モードについて ~PostgreSQLバージョン15対応版~(第34回PostgreSQLアンカンファレンス...オンライン物理バックアップの排他モードと非排他モードについて ~PostgreSQLバージョン15対応版~(第34回PostgreSQLアンカンファレンス...
オンライン物理バックアップの排他モードと非排他モードについて ~PostgreSQLバージョン15対応版~(第34回PostgreSQLアンカンファレンス...
 
祝!PostgreSQLレプリケーション10周年!徹底紹介!!
祝!PostgreSQLレプリケーション10周年!徹底紹介!!祝!PostgreSQLレプリケーション10周年!徹底紹介!!
祝!PostgreSQLレプリケーション10周年!徹底紹介!!
 
PostgreSQL13でのpg_basebackupの改善について(第13回PostgreSQLアンカンファレンス@オンライン)
PostgreSQL13でのpg_basebackupの改善について(第13回PostgreSQLアンカンファレンス@オンライン)PostgreSQL13でのpg_basebackupの改善について(第13回PostgreSQLアンカンファレンス@オンライン)
PostgreSQL13でのpg_basebackupの改善について(第13回PostgreSQLアンカンファレンス@オンライン)
 
PostgreSQL16新機能紹介 - libpq接続ロード・バランシング(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQL16新機能紹介 - libpq接続ロード・バランシング(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)PostgreSQL16新機能紹介 - libpq接続ロード・バランシング(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQL16新機能紹介 - libpq接続ロード・バランシング(第41回PostgreSQLアンカンファレンス@オンライン 発表資料)
 

Similar to PostgreSQL9.3 Switchover/Switchback

Solaris 11 Consolidation Tools
Solaris 11 Consolidation ToolsSolaris 11 Consolidation Tools
Solaris 11 Consolidation Tools
Roman Ivanov
 
Mitigating Kafka Broker ‘Gray’ Failures For Key Based Partitioners With Parti...
Mitigating Kafka Broker ‘Gray’ Failures For Key Based Partitioners With Parti...Mitigating Kafka Broker ‘Gray’ Failures For Key Based Partitioners With Parti...
Mitigating Kafka Broker ‘Gray’ Failures For Key Based Partitioners With Parti...
HostedbyConfluent
 
NoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
NoCOUG_201411_Patel_Managing_a_Large_OLTP_DatabaseNoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
NoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
Paresh Patel
 

Similar to PostgreSQL9.3 Switchover/Switchback (20)

PostgreSQL replication
PostgreSQL replicationPostgreSQL replication
PostgreSQL replication
 
Postgres Point-in-Time Recovery
Postgres Point-in-Time RecoveryPostgres Point-in-Time Recovery
Postgres Point-in-Time Recovery
 
Upgrade to MySQL 5.6 without downtime
Upgrade to MySQL 5.6 without downtimeUpgrade to MySQL 5.6 without downtime
Upgrade to MySQL 5.6 without downtime
 
PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...
PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...
PuppetConf 2016: An Introduction to Measuring and Tuning PE Performance – Cha...
 
Solaris 11 Consolidation Tools
Solaris 11 Consolidation ToolsSolaris 11 Consolidation Tools
Solaris 11 Consolidation Tools
 
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
MySQL 5.7 New Features to Exploit -- PHPTek/Chicago MySQL User Group May 2014
 
Galera webinar migration to galera cluster from my sql async replication
Galera webinar migration to galera cluster from my sql async replicationGalera webinar migration to galera cluster from my sql async replication
Galera webinar migration to galera cluster from my sql async replication
 
Postgres on OpenStack
Postgres on OpenStackPostgres on OpenStack
Postgres on OpenStack
 
PostgreSQL on Kubernetes: Realizing High Availability with PGO (Postgres Ibiz...
PostgreSQL on Kubernetes: Realizing High Availability with PGO (Postgres Ibiz...PostgreSQL on Kubernetes: Realizing High Availability with PGO (Postgres Ibiz...
PostgreSQL on Kubernetes: Realizing High Availability with PGO (Postgres Ibiz...
 
Mitigating Kafka Broker ‘Gray’ Failures For Key Based Partitioners With Parti...
Mitigating Kafka Broker ‘Gray’ Failures For Key Based Partitioners With Parti...Mitigating Kafka Broker ‘Gray’ Failures For Key Based Partitioners With Parti...
Mitigating Kafka Broker ‘Gray’ Failures For Key Based Partitioners With Parti...
 
RAC-Installing your First Cluster and Database
RAC-Installing your First Cluster and DatabaseRAC-Installing your First Cluster and Database
RAC-Installing your First Cluster and Database
 
Backing up Wikipedia Databases
Backing up Wikipedia DatabasesBacking up Wikipedia Databases
Backing up Wikipedia Databases
 
Apache Kudu: Technical Deep Dive


Apache Kudu: Technical Deep Dive

Apache Kudu: Technical Deep Dive


Apache Kudu: Technical Deep Dive


 
Meb Backup & Recovery Performance
Meb Backup & Recovery PerformanceMeb Backup & Recovery Performance
Meb Backup & Recovery Performance
 
MySql's NoSQL -- best of both worlds on the same disks
MySql's NoSQL -- best of both worlds on the same disksMySql's NoSQL -- best of both worlds on the same disks
MySql's NoSQL -- best of both worlds on the same disks
 
Deploying PostgreSQL on Kubernetes
Deploying PostgreSQL on KubernetesDeploying PostgreSQL on Kubernetes
Deploying PostgreSQL on Kubernetes
 
LVOUG meetup #4 - Case Study 10g to 11g
LVOUG meetup #4 - Case Study 10g to 11gLVOUG meetup #4 - Case Study 10g to 11g
LVOUG meetup #4 - Case Study 10g to 11g
 
Start Counting: How We Unlocked Platform Efficiency and Reliability While Sav...
Start Counting: How We Unlocked Platform Efficiency and Reliability While Sav...Start Counting: How We Unlocked Platform Efficiency and Reliability While Sav...
Start Counting: How We Unlocked Platform Efficiency and Reliability While Sav...
 
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
 
NoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
NoCOUG_201411_Patel_Managing_a_Large_OLTP_DatabaseNoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
NoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
 

Recently uploaded

If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
Kayode Fayemi
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
raffaeleoman
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
Kayode Fayemi
 
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
Sheetaleventcompany
 

Recently uploaded (20)

BDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort Service
 
SaaStr Workshop Wednesday w/ Lucas Price, Yardstick
SaaStr Workshop Wednesday w/ Lucas Price, YardstickSaaStr Workshop Wednesday w/ Lucas Price, Yardstick
SaaStr Workshop Wednesday w/ Lucas Price, Yardstick
 
Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.
 
VVIP Call Girls Nalasopara : 9892124323, Call Girls in Nalasopara Services
VVIP Call Girls Nalasopara : 9892124323, Call Girls in Nalasopara ServicesVVIP Call Girls Nalasopara : 9892124323, Call Girls in Nalasopara Services
VVIP Call Girls Nalasopara : 9892124323, Call Girls in Nalasopara Services
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
 
Air breathing and respiratory adaptations in diver animals
Air breathing and respiratory adaptations in diver animalsAir breathing and respiratory adaptations in diver animals
Air breathing and respiratory adaptations in diver animals
 
ANCHORING SCRIPT FOR A CULTURAL EVENT.docx
ANCHORING SCRIPT FOR A CULTURAL EVENT.docxANCHORING SCRIPT FOR A CULTURAL EVENT.docx
ANCHORING SCRIPT FOR A CULTURAL EVENT.docx
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
 
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...
 
Introduction to Prompt Engineering (Focusing on ChatGPT)
Introduction to Prompt Engineering (Focusing on ChatGPT)Introduction to Prompt Engineering (Focusing on ChatGPT)
Introduction to Prompt Engineering (Focusing on ChatGPT)
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
 
Causes of poverty in France presentation.pptx
Causes of poverty in France presentation.pptxCauses of poverty in France presentation.pptx
Causes of poverty in France presentation.pptx
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
 
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
 

PostgreSQL9.3 Switchover/Switchback

  • 1. © 2013 EnterpriseDB Corporation - All rights reserved. 1 Streaming Replication Switchover/Switchback Vibhor Kumar Principal System Engineer.
  • 2. © 2013 EnterpriseDB Corporation - All rights reserved. 2 • PostgreSQL Streaming Replication • Limitations in PG Version < 9.3 • Understanding Timelines • New in PostgreSQL >=9.3 • Possible switchover/switchback • Things to know about switchover/switchback • recovery.conf Agenda
  • 3. © 2013 EnterpriseDB Corporation - All rights reserved. 3 PostgreSQL Streaming Replication (SR) • Streaming Replication (SR) provides capability to continuously ship and apply WAL/XLOG records to any number of standbys. • Introduced in PostgreSQL 9.0 • Currently two types supported: − Synchronous SR − Asynchronous SR
  • 4. © 2013 EnterpriseDB Corporation - All rights reserved. 4 History: Streaming Replication • 9.0: Asynchronous SR • 9.1: − Synchronous SR − pg_basebackup • 9.2: − Cascaded Replication − Backup from Standby − New Sync replication mode. (remote_write, local write) • 9.3 − Streaming only replication. − Follow timeline changes.
  • 5. © 2013 EnterpriseDB Corporation - All rights reserved. 5 Limitations before 9.3 • Timeline streaming issue • Intentional shutdown on master can leave Standby behind the master before 9.1. • If Standby is behind master: − Promote lead to new timeline. − Difference in Master and Standby. − Old Master can’t be standby of new master. − Need to take fresh backup or manual copy timeline file to old master. • Painful to take fresh backup if database size is large.
  • 6. © 2013 EnterpriseDB Corporation - All rights reserved. 6 Understanding Timelines • Introduced with Point-in-Time-Recovery in version 8.0 • Every time you do PITR, a new timeline is formed • Timelines helps to differentiate WAL generated from different PITR. • When new WAL generated after PITR, PostgreSQL shouldn’t overwrite old WAL.
  • 7. © 2013 EnterpriseDB Corporation - All rights reserved. 7 More about Timelines
  • 8. © 2013 EnterpriseDB Corporation - All rights reserved. 8 More about Timelines
  • 9. © 2013 EnterpriseDB Corporation - All rights reserved. 9 Timeline history file
  • 10. © 2013 EnterpriseDB Corporation - All rights reserved. 10 New in 9.3 SR • Important Patches: − commit 985bd7d49726c9f178558491d31a570d47340459 − Author: Fujii Masao − Committed on Wed Jun 26 02:14:37 2013 +0900 − Make sures when we shutdown the master, walsender should tries to send all outstandng WAL records to Standby, and then to exit. − Back patched till 9.1 − commit abfd192b1b5ba5216ac4b1f31dcd553106304b19 − Author: Heikki Linnakangas − Committed on Thu Dec 13 19:00:00 2012 +0200 − Allow a streaming replication standby to follow a timeline switch. (Only in 9.3)
  • 11. © 2013 EnterpriseDB Corporation - All rights reserved. 11 9.3: Now switchover/Switchback is possible • Difference between Switchover and Failover. (add points) • New commit in PostgreSQL helps: − Clean shutdown for maintenance operation of master server − Old master server can be new standby for New Master. − No more fresh backup in intentional promotion.
  • 12. © 2013 EnterpriseDB Corporation - All rights reserved. 12 Things to know: switchover/switchback • Use –m fast or –m smart shutdown on Master for clean shutdown. • Before promoting standby: − Make sure all WAL sent by Master applied on elected node for New Master. − Use following function for when to promote: − pg_last_xlog_receive_location − pg_last_xlog_replay_location − Have proper archive location accessible to old Master. − Set proper archive_command
  • 13. © 2013 EnterpriseDB Corporation - All rights reserved. 13 recovery.conf recovery_target_timeline = 'latest' standby_mode = 'on’ primary_conninfo = 'user=repuser password=repuser host=172.17.0.3 port=5432 restore_command = ‘cp /location/%f %p’
  • 14. © 2013 EnterpriseDB Corporation - All rights reserved. 14 EFM: Promote Steps • When promote happens, EFM does following: − Send prepare information to Master, Witness and Slave − Agent on Master get promote signal and does following: − Release VIP if any. − create dummy recovery.conf, so that next startup master shouldn’t come up. − Message about Master failed. − Standby signaled to be promoted by trigger. • Explore EFM for possible switchover/switchback
  • 15. © 2013 EnterpriseDB Corporation - All rights reserved. 15 Demo
  • 16. © 2013 EnterpriseDB Corporation - All rights reserved. 16 Thanks