Replication Solutions for PostgreSQL
-
Upload
peter-eisentraut -
Category
Technology
-
view
10.448 -
download
1
description
Transcript of Replication Solutions for PostgreSQL
![Page 2: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/2.jpg)
2
What's in a Term?
• Replication?
• Clustering?
• High availability?
• Failover?
• Standby?
• Putting data on more than one computer
![Page 3: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/3.jpg)
3
Space of Possibilities
• Goals• What do you want to achieve?
• Techniques• How can this be implemented?
• Solutions• What software is available to do this?
![Page 4: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/4.jpg)
4
Goals
• High availability
• Performance• Read
• Write
• Wide-area networks
• Offline peers
![Page 5: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/5.jpg)
5
Goal: High Availability
• No one wants “low availability”!
• Provisions for system failures• Software faults
• Hardware faults
• External interference
![Page 6: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/6.jpg)
6
Goal: Read Performance
• Applications with:• many readers (e.g., library information system)
• resource-intensive readers (e.g., data warehousing)
• Distribute readers on more hardware.
• Most often, one physical machine is enough.
![Page 7: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/7.jpg)
7
Goal: Write Performance
• Applications with:• Many writers
• Distribute writers on more hardware?• Constraint checking, conflict resolution?!?
• Faster writing contradicts replication.• Partition, don't replicate!
• RAID 0/striping is not replication – it makes things “worse”.
• RAID 10 is a good idea, but not the topic here.
![Page 8: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/8.jpg)
8
Goal: Wide-Area Networks
• Faster access across WANs
• Reading?• Local copies
• Writing?• Synchronization?
![Page 9: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/9.jpg)
9
Goal: Offline Peers
• Synchronize data with laptops, handhelds, ...
• “Road warriors”
• May be considered very-low-latency WANs
![Page 10: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/10.jpg)
10
Techniques
• Replication• Master/Slave
• Asynchronous
• Synchronous
• Multi-Master• Asynchronous
• Synchronous
• Proxy
• Standby system
![Page 11: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/11.jpg)
11
Technique: Replication Master/Slave Asynchronous
• High(er) availability(?)
• Read performance• Load spreading,
load balancing
• Offline peers(unidirectional sync.)
M Sasync
![Page 12: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/12.jpg)
12
Technique: Replication Master/Slave Synchronous
• High availibility
• Better readperformance
• Worse writeperformance M Ssync
![Page 13: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/13.jpg)
13
Technique: ReplicationMulti-Master Asynchronous
• Read performance
• Faster access acrossWANs
• Manage offline peers
• Requires conflictresolution mechanism
M Masync
![Page 14: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/14.jpg)
14
Technique: ReplicationMulti-Master Synchronous
• “Holy grail of replication”
• High availability
• Read performance
• Difficult to get goodwrite performance M Msync
![Page 15: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/15.jpg)
15
Technique: Proxy
• High availability
• Read performance
• Proxy instance shouldbe redundant
• Transparent to theapplication
C C
Proxy
![Page 16: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/16.jpg)
16
Technique: Standby System
• High availability
M Ssync
![Page 17: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/17.jpg)
17
Constraints
• Hardware
• Operating system
• Application
![Page 18: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/18.jpg)
18
No Built-In Solution?
• FIXME
![Page 19: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/19.jpg)
19
Solutions
• Slony-I, -II
• PGCluster
• DBMirror
• pgpool
• WAL replication
• Sequoia
• DRBD
• Shared storage
![Page 20: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/20.jpg)
20
Solution: Slony-I
(Slony ← слоны ← elephants)
• Asynchronous master/slave replication
• Multiple slaves, cascading possible
• Particularly useful for:• Read performance (load balancing with pgpool)
• Limited form of high availability
• Offline slaves via file-based log shipping
http://www.slony.info/
![Page 21: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/21.jpg)
21
Solution: Slony-II
• Synchronous master/masterreplication?
• See Gavin Sherry's session for details
![Page 22: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/22.jpg)
22
Solution: PGCluster
• Synchronous master/master replication
• Replicates the query string
• Particularly useful for:• Load balancing
• High availability
http://pgcluster.projects.postgresql.org/
![Page 23: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/23.jpg)
23
Solution: DBMirror
• Asynchronous master/slave replication
• Very simple (compared to Slony-I)
• Particularly useful for:• Read performance
• Offline peers
contrib/dbmirror/ in PostgreSQL source tree
![Page 24: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/24.jpg)
24
Solution: pgpool
• Connection pool daemon for PostgreSQL
• Supports simple proxying
• Useful as frontend for Slony-I
http://pgpool.projects.postgresql.org/
![Page 25: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/25.jpg)
25
Solution: WAL Replication
• Use the “archived” WAL logs for “recovery” on a standby system
• Disadvantages:• Only full database cluster replication
• Master and slave must be binary-compatible
• Rather slow across network
• Useful for:• High availability
![Page 26: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/26.jpg)
26
Solution: Sequoia
• Formerly C[lustered]-JDBC
• Proxy offering clustering, loadbalancing and failover services
• Particularly useful for:• High availability
• Read performance
• Currently only for Java/JDBC applications
http://sequoia.continuent.org/
![Page 27: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/27.jpg)
27
Solution: DRBD
• File system (block device) replication
• Linux kernel module
• Standby system
• Useful for:• High availability
• Secure any service, not just a database system
http://www.drbd.org/
![Page 28: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/28.jpg)
28
Solution: Shared Storage
• NAS, iSCSI, Fiberchannel, ...
• Available from many vendors
• Standby system
• Useful for:• High availability
• Secure any service, not just a database system
• Single storage system is a possible point of failure
![Page 29: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/29.jpg)
29
Summary
• Plenty of solutions for diverse applications
• Make a (project) plan.
![Page 30: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/30.jpg)
30
Suggestions
• Minimum for any production installation:• Sensible disk clustering
• RAID 10
• Tablespace management
• Separate disk(s) for WAL
• DRBD or shared storage
• Slony-I for load balancing or warehousing
• Java developers consider Sequoia
![Page 31: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/31.jpg)
31
Outlook
• Slony-II
• WAL replication management
• XA support
• More packaging efforts
![Page 32: Replication Solutions for PostgreSQL](https://reader034.fdocuments.in/reader034/viewer/2022052409/54646658b4af9f3a3f8b49c3/html5/thumbnails/32.jpg)
32
The End
Replication Solutions for PostgreSQL