SlideShare a Scribd company logo
1 of 37
Download to read offline
Replicating PostgreSQL
Databases Using Slony-I

          Christopher Browne
            Afilias Canada

An introduction to the use of Slony-I, an
 asynchronous single-master to multiple
  slaves replication system for use with
                PostgreSQL
What is Slony-I?
Slony-I is an asynchronous single master
  to multiple slave replication system for
  PostgreSQL supporting multiple
  database releases, cascaded
  replication, and slave promotion.
What is Slony-I?
Slony-I is a replication system for PostgreSQL
Replication: Updates applied to one database
 are applied to another database
  INSERT, DELETE, UPDATE
Some replication systems intercept
 transaction logs; Slony-I uses triggers on
 tables to collect changes
Why Replicate?
●   Redundancy – allowing rapid
    recovery from some hardware failures
●   Separate reporting from on-line
    activity: Performance
●   Separate reporting from on-line
    system: Security
What is Slony-I?
Slony-I is an asynchronous replication system
Asynchronous: Updates are COMMITted to one
 database, and are applied to others later
 (possibly much later)
Contrast with synchronous, where updates
 must commit on multiple hosts at the same
 time
What is Slony-I?
Slony-I is an asynchronous single master to
  multiple slave replication system
Updates are applied at the origin, and are
 replicated to a set of subscribers
Slony-I allows each table to have a different
  origin – but only one origin!
Alternative: multimaster – more complex,
  heavy locking costs and/or conflict
  resolution problems
What is Slony-I?
Slony-I supports multiple PostgreSQL
  releases
Supports PostgreSQL versions 7.3.3 and
 higher
Earlier versions not supported – no
 namespaces
Preparing version upgrade
●    Prepare upgrade...

       Master                Slave
                                S
        7.3.9    Replicate    8.0.3



    Slony-I may take 48h to populate the replica, but
    that requires no outage on the master system
Database version upgrade (2)

●    Once “in sync,” MOVE SET takes
     seconds
       Slave                Master
                              S

        7.3.9   move set
                             8.0.3



    The former master can become slave; this provides a
    fall back strategy “Just in Case”
What is Slony-I?
Slony-I supports cascaded replication

 NYC Data Center
                              LA Data Center
  NY1
             NY2     WAN
  Master                     LA1       LA2

Several LA servers feeding from just   LA3
one source
What is Slony-I?
Slony-I supports slave promotion

 NYC Data Center               LA Data Center

   NY1         NY2             LA1
                                           LA2
                               Master


MOVE SET shifts origin to LA               LA3
Uses for Slave Promotion
●   Upgrades: Set up subscriber running
    new PG version, then promote it to
    “master”
●   Maintenance: Shift origin to a new
    server allowing extended maintenance
●   Avoid failure: Shift origin from a
    failing server to one that is “less
    ailing.”
Fail Over
●   For extreme cases of problems with
    master, Slony-I supports full scale fail-
    over
●   Since Slony-I is asynchronous, some
    transactions committed on the master
    won't have made it to other nodes
●   As a result, FAIL OVER must lead to
    dropping the failed node
Slony-I Components
●   Databases – one for each node
●   Slon daemon – one for each node
●   Slonik – configuration controller
●   Virtual: Network configuration
Components: Databases

Each node is a PostgreSQL database with:
●   C libraries to implement trigger functions
●   pl/pgsql functions for non-time-critical code
●   Database namespace/schema for
    configuration
●   On origin nodes – triggers to capture updates
●   On subscriber nodes – triggers to protect data
●   Slony-I processes connect as a superuser, e.g.
    slony
Components: slon daemons

Each node has a slon instance.
This is a C program that propagates
 events between nodes
●   Most event types are for configuring
    Slony-I
●   SYNC events are where data
    “providers” tell subscribers that they
    have new data to replicate
Components: slonik
The slonik command processor takes
 configuration scripts in an SQL-like language
 and submits them to the cluster
●   STORE NODE, STORE PATH, STORE LISTEN
●   CREATE SET, SET (ADD|DROP|MOVE) TABLE, SET (ADD|
    DROP|MOVE) SEQUENCE
●   SUBSCRIBE SET, LOCK SET, MOVE SET, FAIL OVER,
    EXECUTE SCRIPT

Slonik is only used when modifying
  configuration; when system is stable, it
  remains unused
Components: Network
            Configuration
●   Configuration paths from “admin
    workstation” to all nodes – connections
    may be temporary and/or slow but
    must be comprehensive
●   Communications paths between slon
    daemons and Slony-I nodes – need to
    be fast and reliable; create only the
    links you need
Administrative Connections
●   slonik needs to communicate with
    every node
Replication Connections
●   Persistent, reliable, fast 2-way connections
    between some nodes



       Redundancy
       wanted!
Configuration Terminology
●   Cluster – the set of databases
●   Node – each database in the cluster
●   Replication set – a set of tables and
    sequences replicated from a single origin
●   Origin, subscribers, providers – the
    shape of the replication “network”
●   Paths – routes slon uses to talk to DBs
●   Listen paths – determine path usage
Cluster
A Slony-I cluster is the set of database
  instances where replication takes place.
Give the thing being replicated a name:
●   ORG, Payroll, PriceDB, STorm
The name identifies the schema used to store
 Slony-I data, thus _ORG, _Payroll, _PriceDB, ...
Slonik scripts specify: cluster name=ORG;
Slon daemons are passed the cluster name:
slon -d4 -g80 STorm 'host=db1 db=nws_storm'
Node
Each PostgreSQL database being used for
 replication is a Slony-I “node”
Each has a schema containing Slony-I-specific
 tables, sequences, functions
Cluster T1 has the following tables:
_T1.sl_config_lock _T1.sl_confirm _T1.sl_event _T1.sl_listen
_T1.sl_log_1 _T1.sl_log_2 _T1.sl_log_status _T1.sl_node _T1.sl_path
_T1.sl_seqlastvalue _T1.sl_seqlog _T1.sl_sequence _T1.sl_set
_T1.sl_setsync _T1.sl_status _T1.sl_subscribe _T1.sl_table
_T1.sl_trigger

Slonik commands:                    store node, drop node,
  uninstall node
Replication Sets
●   Replication sets are the “container” for each
    set of tables and sequences being replicated
●   Each set's data originates on one node and
    is published to other nodes
●   By having multiple sets with multiple origins,
    you can get a sort of multimaster replication
Slonik commands: create      set, drop set,
    subscribe set, merge set, set add table, set
    add sequence, ...
Weak Form of Multimaster Replication

●   DB1 is origin for table tab1 in set 1
●   DB2 is origin for table tab2 in set 2
●   DB3 is origin for table tab3 in set 3
               tab1          tab2
         DB1   tab2   DB2    tab3   DB3
                      tab3

Three replication sets can have different propagation
networks
Origin, Provider, Subscriber
The terms “master” and “slave” become
  inaccurate if there are more than 2 nodes
Nodes are not themselves either master or
  slave
For each replication set, and hence for each
  table, there is exactly one “origin”
All the other nodes can be “subscribers”
Each subscriber draws data from a “provider”
  which may either be the origin, or a
  subscriber downstream from the origin.
Admin Paths
●   One variety of “communications path” is the
    one used by slonik from “admin server” to
    all nodes
●   These are encoded in a preamble to each
    slonik script
●   There needs to be one 'admin conninfo' path
    to each Slony-I node
●   These are used sporadically, just to do
    configuration, so they could be temporary
    (e.g. - SSH tunnels)
Paths Between Nodes
●   The store path command stores the paths
    used so the slon for node X knows how to
    access the database for node Y
●   If there are n nodes, there could be as many
    as n(n-1) paths in sl_path; no less than 2n
●   Multiple sites with complex firewall policies
    may mean nonuniform communications
    paths
●   But there still must be some form of 2-way
    communications between sites
Complex Path Scenario
    network #1                     network #2
    db       db                    db       db
    1        2                     4        5
            db                          db   Tightly interconnected
            3                           6    in network #2

Tightly interconnected
in network #1

                  But between the networks, only
                  db2 and db4 talk to one another
Security Considerations
●   slonik and slon must connect as PostgreSQL
    superuser because they do DB alterations
●   In practice, events propagate so any action
    could come from anywhere
●   Connection issues and mechanisms are the
    same as for any software using libpq
●   Slony-I doesn't mess around with users or
    roles; you manage security your way
.pgpass for Password Storage

Use .pgpass for storing passwords
● Removes passwords from command lines


● Removes passwords from environment

  variables
● Removes passwords from sl_path


All of those are vulnerable to capture
SSH Connections
Consider using ssh connections across
 untrusted networks
●   Slony-I opens connections infrequently –
    costs are amortized over much usage
●   Presently, PostgreSQL has decent support
    for server certificates but client certificates
    not usable for authentication
●   Use of client certificates for authentication
    would provide a more “opaque” token than
    .pgpass – future PostgreSQL enhancement
Slony-I User
Use of “slony” PG user to run Slony-I
 processes is highly recommended
●   Makes replication connections highly
    identifiable
●   Makes it easy to lock out all but the slony
    user when running COPY_SET
●   Separating maintenance roles to multiple
    users (molly, dumpy, slony) has proven
    useful.
Security – Log Shipping
●   Conventional nodes require 2-way
    communications between participating
    servers
●   Log shipping allows serializing updates
    to files
●   Transmit (1-way!) via FTP, scp, rsync,
    DVD-ROM, USB Key, RFC 1149, 2549
Sometimes Slony-I isn't the
            Answer
●   If you truly, honest to goodness,
    need multimaster, watch for Slony-II...
●   If you need DDL to be handled
    automagically, look at PG 8.0 PITR
●   If you have a loosely run environment,
    Slony-I will not go well
●   No answer yet for async multimaster!
More Cases Not to Use Slony-I
●   Slony-I needs to define a node (and
    spawn a slon + connections) for each
    database – replicating 80 databases
    on one cluster may not turn out
●   If you have 300 sequences, all 300
    are propagated with each sync – this
    may not turn out well
Summary
●   What is Slony-I and what does it do?
●   What are the components of Slony-I?
●   What are some security issues
    surrounding the use of Slony-I?

More Related Content

What's hot

Share File easily between computers using sftp
Share File easily between computers using sftpShare File easily between computers using sftp
Share File easily between computers using sftpTushar B Kute
 
Redis cluster
Redis clusterRedis cluster
Redis clusteriammutex
 
OpenStack Networking
OpenStack NetworkingOpenStack Networking
OpenStack NetworkingIlya Shakhat
 
Built in physical and logical replication in postgresql-Firat Gulec
Built in physical and logical replication in postgresql-Firat GulecBuilt in physical and logical replication in postgresql-Firat Gulec
Built in physical and logical replication in postgresql-Firat GulecFIRAT GULEC
 
Nginx cheat sheet
Nginx cheat sheetNginx cheat sheet
Nginx cheat sheetLam Hoang
 
An introduction to SSH
An introduction to SSHAn introduction to SSH
An introduction to SSHnussbauml
 
제3회난공불락 오픈소스 인프라세미나 - Pacemaker
제3회난공불락 오픈소스 인프라세미나 - Pacemaker제3회난공불락 오픈소스 인프라세미나 - Pacemaker
제3회난공불락 오픈소스 인프라세미나 - PacemakerTommy Lee
 
Capa de Aplicacion - Redes de Computadoras
Capa de Aplicacion - Redes de ComputadorasCapa de Aplicacion - Redes de Computadoras
Capa de Aplicacion - Redes de ComputadorasJesus Jimenez
 
Tcp vs udp difference and comparison diffen
Tcp vs udp   difference and comparison   diffenTcp vs udp   difference and comparison   diffen
Tcp vs udp difference and comparison diffenHarikiran Raju
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2Ido Flatow
 
BGP Weight Manipulation with Route Map
BGP Weight Manipulation with Route MapBGP Weight Manipulation with Route Map
BGP Weight Manipulation with Route MapNetProtocol Xpert
 
Ceph data services in a multi- and hybrid cloud world
Ceph data services in a multi- and hybrid cloud worldCeph data services in a multi- and hybrid cloud world
Ceph data services in a multi- and hybrid cloud worldSage Weil
 
Architecture for building scalable and highly available Postgres Cluster
Architecture for building scalable and highly available Postgres ClusterArchitecture for building scalable and highly available Postgres Cluster
Architecture for building scalable and highly available Postgres ClusterAshnikbiz
 
TELNET and SSH by MUSTAFA SAKHAI
TELNET and SSH by MUSTAFA SAKHAITELNET and SSH by MUSTAFA SAKHAI
TELNET and SSH by MUSTAFA SAKHAIMUSTAFA SAKHAI
 
PostgreSQL- An Introduction
PostgreSQL- An IntroductionPostgreSQL- An Introduction
PostgreSQL- An IntroductionSmita Prasad
 
The Google Chubby lock service for loosely-coupled distributed systems
The Google Chubby lock service for loosely-coupled distributed systemsThe Google Chubby lock service for loosely-coupled distributed systems
The Google Chubby lock service for loosely-coupled distributed systemsRomain Jacotin
 
Netcat 101 by-mahesh-beema
Netcat 101 by-mahesh-beemaNetcat 101 by-mahesh-beema
Netcat 101 by-mahesh-beemaRaghunath G
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PGConf APAC
 
Asterisk WebRTC frontier: make client SIP Phone with sipML5 and Janus Gateway
Asterisk WebRTC frontier: make client SIP Phone with sipML5 and Janus GatewayAsterisk WebRTC frontier: make client SIP Phone with sipML5 and Janus Gateway
Asterisk WebRTC frontier: make client SIP Phone with sipML5 and Janus GatewayAlessandro Polidori
 
Fluentd with MySQL
Fluentd with MySQLFluentd with MySQL
Fluentd with MySQLI Goo Lee
 

What's hot (20)

Share File easily between computers using sftp
Share File easily between computers using sftpShare File easily between computers using sftp
Share File easily between computers using sftp
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 
OpenStack Networking
OpenStack NetworkingOpenStack Networking
OpenStack Networking
 
Built in physical and logical replication in postgresql-Firat Gulec
Built in physical and logical replication in postgresql-Firat GulecBuilt in physical and logical replication in postgresql-Firat Gulec
Built in physical and logical replication in postgresql-Firat Gulec
 
Nginx cheat sheet
Nginx cheat sheetNginx cheat sheet
Nginx cheat sheet
 
An introduction to SSH
An introduction to SSHAn introduction to SSH
An introduction to SSH
 
제3회난공불락 오픈소스 인프라세미나 - Pacemaker
제3회난공불락 오픈소스 인프라세미나 - Pacemaker제3회난공불락 오픈소스 인프라세미나 - Pacemaker
제3회난공불락 오픈소스 인프라세미나 - Pacemaker
 
Capa de Aplicacion - Redes de Computadoras
Capa de Aplicacion - Redes de ComputadorasCapa de Aplicacion - Redes de Computadoras
Capa de Aplicacion - Redes de Computadoras
 
Tcp vs udp difference and comparison diffen
Tcp vs udp   difference and comparison   diffenTcp vs udp   difference and comparison   diffen
Tcp vs udp difference and comparison diffen
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2
 
BGP Weight Manipulation with Route Map
BGP Weight Manipulation with Route MapBGP Weight Manipulation with Route Map
BGP Weight Manipulation with Route Map
 
Ceph data services in a multi- and hybrid cloud world
Ceph data services in a multi- and hybrid cloud worldCeph data services in a multi- and hybrid cloud world
Ceph data services in a multi- and hybrid cloud world
 
Architecture for building scalable and highly available Postgres Cluster
Architecture for building scalable and highly available Postgres ClusterArchitecture for building scalable and highly available Postgres Cluster
Architecture for building scalable and highly available Postgres Cluster
 
TELNET and SSH by MUSTAFA SAKHAI
TELNET and SSH by MUSTAFA SAKHAITELNET and SSH by MUSTAFA SAKHAI
TELNET and SSH by MUSTAFA SAKHAI
 
PostgreSQL- An Introduction
PostgreSQL- An IntroductionPostgreSQL- An Introduction
PostgreSQL- An Introduction
 
The Google Chubby lock service for loosely-coupled distributed systems
The Google Chubby lock service for loosely-coupled distributed systemsThe Google Chubby lock service for loosely-coupled distributed systems
The Google Chubby lock service for loosely-coupled distributed systems
 
Netcat 101 by-mahesh-beema
Netcat 101 by-mahesh-beemaNetcat 101 by-mahesh-beema
Netcat 101 by-mahesh-beema
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs
 
Asterisk WebRTC frontier: make client SIP Phone with sipML5 and Janus Gateway
Asterisk WebRTC frontier: make client SIP Phone with sipML5 and Janus GatewayAsterisk WebRTC frontier: make client SIP Phone with sipML5 and Janus Gateway
Asterisk WebRTC frontier: make client SIP Phone with sipML5 and Janus Gateway
 
Fluentd with MySQL
Fluentd with MySQLFluentd with MySQL
Fluentd with MySQL
 

Viewers also liked

Multi-Master Replication with Slony
Multi-Master Replication with SlonyMulti-Master Replication with Slony
Multi-Master Replication with SlonyJim Mlodgenski
 
Scaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQLScaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQLJim Mlodgenski
 
PostgreSQL High Availability via SLONY and PG POOL II
PostgreSQL High Availability via SLONY and PG POOL IIPostgreSQL High Availability via SLONY and PG POOL II
PostgreSQL High Availability via SLONY and PG POOL IICommand Prompt., Inc
 
Replicating PostgreSQL Databases Using Slony-I
Replicating PostgreSQL Databases Using Slony-IReplicating PostgreSQL Databases Using Slony-I
Replicating PostgreSQL Databases Using Slony-Ielliando dias
 
Postgre sql y_replicacion_slony_p
Postgre sql y_replicacion_slony_pPostgre sql y_replicacion_slony_p
Postgre sql y_replicacion_slony_pedvin_marcelo
 

Viewers also liked (6)

Multi-Master Replication with Slony
Multi-Master Replication with SlonyMulti-Master Replication with Slony
Multi-Master Replication with Slony
 
Scaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQLScaling PostgreSQL With GridSQL
Scaling PostgreSQL With GridSQL
 
PostgreSQL High Availability via SLONY and PG POOL II
PostgreSQL High Availability via SLONY and PG POOL IIPostgreSQL High Availability via SLONY and PG POOL II
PostgreSQL High Availability via SLONY and PG POOL II
 
Replicating PostgreSQL Databases Using Slony-I
Replicating PostgreSQL Databases Using Slony-IReplicating PostgreSQL Databases Using Slony-I
Replicating PostgreSQL Databases Using Slony-I
 
Postgre sql y_replicacion_slony_p
Postgre sql y_replicacion_slony_pPostgre sql y_replicacion_slony_p
Postgre sql y_replicacion_slony_p
 
PostgreSQLレプリケーション徹底紹介
PostgreSQLレプリケーション徹底紹介PostgreSQLレプリケーション徹底紹介
PostgreSQLレプリケーション徹底紹介
 

Similar to Asynchronous Replication for PostgreSQL Slony

MySQL 5.7 clustering: The developer perspective
MySQL 5.7 clustering: The developer perspectiveMySQL 5.7 clustering: The developer perspective
MySQL 5.7 clustering: The developer perspectiveUlf Wendel
 
Mysql replication @ gnugroup
Mysql replication @ gnugroupMysql replication @ gnugroup
Mysql replication @ gnugroupJayant Chutke
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerkuchinskaya
 
Bharath Ram Chandrasekar_Tele 6603_SDN &NFV
Bharath Ram Chandrasekar_Tele 6603_SDN &NFVBharath Ram Chandrasekar_Tele 6603_SDN &NFV
Bharath Ram Chandrasekar_Tele 6603_SDN &NFVBharath Ram Chandrasekar
 
Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...
Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...
Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...Continuent
 
Using Galera Cluster to Power Geo-distributed Applications on the WAN
Using Galera Cluster to Power Geo-distributed Applications on the WANUsing Galera Cluster to Power Geo-distributed Applications on the WAN
Using Galera Cluster to Power Geo-distributed Applications on the WANphilip_stoev
 
MySQL HA with PaceMaker
MySQL HA with  PaceMakerMySQL HA with  PaceMaker
MySQL HA with PaceMakerKris Buytaert
 
The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!Boris Hristov
 
Open stack HA - Theory to Reality
Open stack HA -  Theory to RealityOpen stack HA -  Theory to Reality
Open stack HA - Theory to RealitySriram Subramanian
 
Replication tutorial presentation
Replication tutorial presentationReplication tutorial presentation
Replication tutorial presentationcolderboy17
 
The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!Boris Hristov
 
Welcome to the nightmare of locking, blocking and isolation levels!
Welcome to the nightmare of locking, blocking and isolation levels!Welcome to the nightmare of locking, blocking and isolation levels!
Welcome to the nightmare of locking, blocking and isolation levels!Boris Hristov
 
The nightmare of locking, blocking and isolation levels
The nightmare of locking, blocking and isolation levelsThe nightmare of locking, blocking and isolation levels
The nightmare of locking, blocking and isolation levelsBoris Hristov
 
LXC Containers and AUFs
LXC Containers and AUFsLXC Containers and AUFs
LXC Containers and AUFsDocker, Inc.
 
The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!Boris Hristov
 
Migrating to XtraDB Cluster
Migrating to XtraDB ClusterMigrating to XtraDB Cluster
Migrating to XtraDB Clusterpercona2013
 
My Sql Proxy
My Sql ProxyMy Sql Proxy
My Sql ProxyLiu Lizhi
 
Design Patterns for Distributed Non-Relational Databases
Design Patterns for Distributed Non-Relational DatabasesDesign Patterns for Distributed Non-Relational Databases
Design Patterns for Distributed Non-Relational Databasesguestdfd1ec
 

Similar to Asynchronous Replication for PostgreSQL Slony (20)

MySQL 5.7 clustering: The developer perspective
MySQL 5.7 clustering: The developer perspectiveMySQL 5.7 clustering: The developer perspective
MySQL 5.7 clustering: The developer perspective
 
Mysql replication @ gnugroup
Mysql replication @ gnugroupMysql replication @ gnugroup
Mysql replication @ gnugroup
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemaker
 
Bharath Ram Chandrasekar_Tele 6603_SDN &NFV
Bharath Ram Chandrasekar_Tele 6603_SDN &NFVBharath Ram Chandrasekar_Tele 6603_SDN &NFV
Bharath Ram Chandrasekar_Tele 6603_SDN &NFV
 
Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...
Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...
Training Slides: Intermediate 202: Performing Cluster Maintenance with Zero-D...
 
Using Galera Cluster to Power Geo-distributed Applications on the WAN
Using Galera Cluster to Power Geo-distributed Applications on the WANUsing Galera Cluster to Power Geo-distributed Applications on the WAN
Using Galera Cluster to Power Geo-distributed Applications on the WAN
 
AlwaysON Basics
AlwaysON BasicsAlwaysON Basics
AlwaysON Basics
 
MySQL HA with PaceMaker
MySQL HA with  PaceMakerMySQL HA with  PaceMaker
MySQL HA with PaceMaker
 
The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
 
Open stack HA - Theory to Reality
Open stack HA -  Theory to RealityOpen stack HA -  Theory to Reality
Open stack HA - Theory to Reality
 
Replication tutorial presentation
Replication tutorial presentationReplication tutorial presentation
Replication tutorial presentation
 
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
 
The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
 
Welcome to the nightmare of locking, blocking and isolation levels!
Welcome to the nightmare of locking, blocking and isolation levels!Welcome to the nightmare of locking, blocking and isolation levels!
Welcome to the nightmare of locking, blocking and isolation levels!
 
The nightmare of locking, blocking and isolation levels
The nightmare of locking, blocking and isolation levelsThe nightmare of locking, blocking and isolation levels
The nightmare of locking, blocking and isolation levels
 
LXC Containers and AUFs
LXC Containers and AUFsLXC Containers and AUFs
LXC Containers and AUFs
 
The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!
 
Migrating to XtraDB Cluster
Migrating to XtraDB ClusterMigrating to XtraDB Cluster
Migrating to XtraDB Cluster
 
My Sql Proxy
My Sql ProxyMy Sql Proxy
My Sql Proxy
 
Design Patterns for Distributed Non-Relational Databases
Design Patterns for Distributed Non-Relational DatabasesDesign Patterns for Distributed Non-Relational Databases
Design Patterns for Distributed Non-Relational Databases
 

More from elliando dias

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slideselliando dias
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScriptelliando dias
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structureselliando dias
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de containerelliando dias
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agilityelliando dias
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Librarieselliando dias
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!elliando dias
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Webelliando dias
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduinoelliando dias
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorceryelliando dias
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Designelliando dias
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makeselliando dias
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.elliando dias
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebookelliando dias
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Studyelliando dias
 

More from elliando dias (20)

Clojurescript slides
Clojurescript slidesClojurescript slides
Clojurescript slides
 
Why you should be excited about ClojureScript
Why you should be excited about ClojureScriptWhy you should be excited about ClojureScript
Why you should be excited about ClojureScript
 
Functional Programming with Immutable Data Structures
Functional Programming with Immutable Data StructuresFunctional Programming with Immutable Data Structures
Functional Programming with Immutable Data Structures
 
Nomenclatura e peças de container
Nomenclatura  e peças de containerNomenclatura  e peças de container
Nomenclatura e peças de container
 
Geometria Projetiva
Geometria ProjetivaGeometria Projetiva
Geometria Projetiva
 
Polyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better AgilityPolyglot and Poly-paradigm Programming for Better Agility
Polyglot and Poly-paradigm Programming for Better Agility
 
Javascript Libraries
Javascript LibrariesJavascript Libraries
Javascript Libraries
 
How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!How to Make an Eight Bit Computer and Save the World!
How to Make an Eight Bit Computer and Save the World!
 
Ragel talk
Ragel talkRagel talk
Ragel talk
 
A Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the WebA Practical Guide to Connecting Hardware to the Web
A Practical Guide to Connecting Hardware to the Web
 
Introdução ao Arduino
Introdução ao ArduinoIntrodução ao Arduino
Introdução ao Arduino
 
Minicurso arduino
Minicurso arduinoMinicurso arduino
Minicurso arduino
 
Incanter Data Sorcery
Incanter Data SorceryIncanter Data Sorcery
Incanter Data Sorcery
 
Rango
RangoRango
Rango
 
Fab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine DesignFab.in.a.box - Fab Academy: Machine Design
Fab.in.a.box - Fab Academy: Machine Design
 
The Digital Revolution: Machines that makes
The Digital Revolution: Machines that makesThe Digital Revolution: Machines that makes
The Digital Revolution: Machines that makes
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.Hadoop - Simple. Scalable.
Hadoop - Simple. Scalable.
 
Hadoop and Hive Development at Facebook
Hadoop and Hive Development at FacebookHadoop and Hive Development at Facebook
Hadoop and Hive Development at Facebook
 
Multi-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case StudyMulti-core Parallelization in Clojure - a Case Study
Multi-core Parallelization in Clojure - a Case Study
 

Recently uploaded

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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?Antenna Manufacturer Coco
 
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 MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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...Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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)wesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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?
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Asynchronous Replication for PostgreSQL Slony

  • 1. Replicating PostgreSQL Databases Using Slony-I Christopher Browne Afilias Canada An introduction to the use of Slony-I, an asynchronous single-master to multiple slaves replication system for use with PostgreSQL
  • 2. What is Slony-I? Slony-I is an asynchronous single master to multiple slave replication system for PostgreSQL supporting multiple database releases, cascaded replication, and slave promotion.
  • 3. What is Slony-I? Slony-I is a replication system for PostgreSQL Replication: Updates applied to one database are applied to another database INSERT, DELETE, UPDATE Some replication systems intercept transaction logs; Slony-I uses triggers on tables to collect changes
  • 4. Why Replicate? ● Redundancy – allowing rapid recovery from some hardware failures ● Separate reporting from on-line activity: Performance ● Separate reporting from on-line system: Security
  • 5. What is Slony-I? Slony-I is an asynchronous replication system Asynchronous: Updates are COMMITted to one database, and are applied to others later (possibly much later) Contrast with synchronous, where updates must commit on multiple hosts at the same time
  • 6. What is Slony-I? Slony-I is an asynchronous single master to multiple slave replication system Updates are applied at the origin, and are replicated to a set of subscribers Slony-I allows each table to have a different origin – but only one origin! Alternative: multimaster – more complex, heavy locking costs and/or conflict resolution problems
  • 7. What is Slony-I? Slony-I supports multiple PostgreSQL releases Supports PostgreSQL versions 7.3.3 and higher Earlier versions not supported – no namespaces
  • 8. Preparing version upgrade ● Prepare upgrade... Master Slave S 7.3.9 Replicate 8.0.3 Slony-I may take 48h to populate the replica, but that requires no outage on the master system
  • 9. Database version upgrade (2) ● Once “in sync,” MOVE SET takes seconds Slave Master S 7.3.9 move set 8.0.3 The former master can become slave; this provides a fall back strategy “Just in Case”
  • 10. What is Slony-I? Slony-I supports cascaded replication NYC Data Center LA Data Center NY1 NY2 WAN Master LA1 LA2 Several LA servers feeding from just LA3 one source
  • 11. What is Slony-I? Slony-I supports slave promotion NYC Data Center LA Data Center NY1 NY2 LA1 LA2 Master MOVE SET shifts origin to LA LA3
  • 12. Uses for Slave Promotion ● Upgrades: Set up subscriber running new PG version, then promote it to “master” ● Maintenance: Shift origin to a new server allowing extended maintenance ● Avoid failure: Shift origin from a failing server to one that is “less ailing.”
  • 13. Fail Over ● For extreme cases of problems with master, Slony-I supports full scale fail- over ● Since Slony-I is asynchronous, some transactions committed on the master won't have made it to other nodes ● As a result, FAIL OVER must lead to dropping the failed node
  • 14. Slony-I Components ● Databases – one for each node ● Slon daemon – one for each node ● Slonik – configuration controller ● Virtual: Network configuration
  • 15. Components: Databases Each node is a PostgreSQL database with: ● C libraries to implement trigger functions ● pl/pgsql functions for non-time-critical code ● Database namespace/schema for configuration ● On origin nodes – triggers to capture updates ● On subscriber nodes – triggers to protect data ● Slony-I processes connect as a superuser, e.g. slony
  • 16. Components: slon daemons Each node has a slon instance. This is a C program that propagates events between nodes ● Most event types are for configuring Slony-I ● SYNC events are where data “providers” tell subscribers that they have new data to replicate
  • 17. Components: slonik The slonik command processor takes configuration scripts in an SQL-like language and submits them to the cluster ● STORE NODE, STORE PATH, STORE LISTEN ● CREATE SET, SET (ADD|DROP|MOVE) TABLE, SET (ADD| DROP|MOVE) SEQUENCE ● SUBSCRIBE SET, LOCK SET, MOVE SET, FAIL OVER, EXECUTE SCRIPT Slonik is only used when modifying configuration; when system is stable, it remains unused
  • 18. Components: Network Configuration ● Configuration paths from “admin workstation” to all nodes – connections may be temporary and/or slow but must be comprehensive ● Communications paths between slon daemons and Slony-I nodes – need to be fast and reliable; create only the links you need
  • 19. Administrative Connections ● slonik needs to communicate with every node
  • 20. Replication Connections ● Persistent, reliable, fast 2-way connections between some nodes Redundancy wanted!
  • 21. Configuration Terminology ● Cluster – the set of databases ● Node – each database in the cluster ● Replication set – a set of tables and sequences replicated from a single origin ● Origin, subscribers, providers – the shape of the replication “network” ● Paths – routes slon uses to talk to DBs ● Listen paths – determine path usage
  • 22. Cluster A Slony-I cluster is the set of database instances where replication takes place. Give the thing being replicated a name: ● ORG, Payroll, PriceDB, STorm The name identifies the schema used to store Slony-I data, thus _ORG, _Payroll, _PriceDB, ... Slonik scripts specify: cluster name=ORG; Slon daemons are passed the cluster name: slon -d4 -g80 STorm 'host=db1 db=nws_storm'
  • 23. Node Each PostgreSQL database being used for replication is a Slony-I “node” Each has a schema containing Slony-I-specific tables, sequences, functions Cluster T1 has the following tables: _T1.sl_config_lock _T1.sl_confirm _T1.sl_event _T1.sl_listen _T1.sl_log_1 _T1.sl_log_2 _T1.sl_log_status _T1.sl_node _T1.sl_path _T1.sl_seqlastvalue _T1.sl_seqlog _T1.sl_sequence _T1.sl_set _T1.sl_setsync _T1.sl_status _T1.sl_subscribe _T1.sl_table _T1.sl_trigger Slonik commands: store node, drop node, uninstall node
  • 24. Replication Sets ● Replication sets are the “container” for each set of tables and sequences being replicated ● Each set's data originates on one node and is published to other nodes ● By having multiple sets with multiple origins, you can get a sort of multimaster replication Slonik commands: create set, drop set, subscribe set, merge set, set add table, set add sequence, ...
  • 25. Weak Form of Multimaster Replication ● DB1 is origin for table tab1 in set 1 ● DB2 is origin for table tab2 in set 2 ● DB3 is origin for table tab3 in set 3 tab1 tab2 DB1 tab2 DB2 tab3 DB3 tab3 Three replication sets can have different propagation networks
  • 26. Origin, Provider, Subscriber The terms “master” and “slave” become inaccurate if there are more than 2 nodes Nodes are not themselves either master or slave For each replication set, and hence for each table, there is exactly one “origin” All the other nodes can be “subscribers” Each subscriber draws data from a “provider” which may either be the origin, or a subscriber downstream from the origin.
  • 27. Admin Paths ● One variety of “communications path” is the one used by slonik from “admin server” to all nodes ● These are encoded in a preamble to each slonik script ● There needs to be one 'admin conninfo' path to each Slony-I node ● These are used sporadically, just to do configuration, so they could be temporary (e.g. - SSH tunnels)
  • 28. Paths Between Nodes ● The store path command stores the paths used so the slon for node X knows how to access the database for node Y ● If there are n nodes, there could be as many as n(n-1) paths in sl_path; no less than 2n ● Multiple sites with complex firewall policies may mean nonuniform communications paths ● But there still must be some form of 2-way communications between sites
  • 29. Complex Path Scenario network #1 network #2 db db db db 1 2 4 5 db db Tightly interconnected 3 6 in network #2 Tightly interconnected in network #1 But between the networks, only db2 and db4 talk to one another
  • 30. Security Considerations ● slonik and slon must connect as PostgreSQL superuser because they do DB alterations ● In practice, events propagate so any action could come from anywhere ● Connection issues and mechanisms are the same as for any software using libpq ● Slony-I doesn't mess around with users or roles; you manage security your way
  • 31. .pgpass for Password Storage Use .pgpass for storing passwords ● Removes passwords from command lines ● Removes passwords from environment variables ● Removes passwords from sl_path All of those are vulnerable to capture
  • 32. SSH Connections Consider using ssh connections across untrusted networks ● Slony-I opens connections infrequently – costs are amortized over much usage ● Presently, PostgreSQL has decent support for server certificates but client certificates not usable for authentication ● Use of client certificates for authentication would provide a more “opaque” token than .pgpass – future PostgreSQL enhancement
  • 33. Slony-I User Use of “slony” PG user to run Slony-I processes is highly recommended ● Makes replication connections highly identifiable ● Makes it easy to lock out all but the slony user when running COPY_SET ● Separating maintenance roles to multiple users (molly, dumpy, slony) has proven useful.
  • 34. Security – Log Shipping ● Conventional nodes require 2-way communications between participating servers ● Log shipping allows serializing updates to files ● Transmit (1-way!) via FTP, scp, rsync, DVD-ROM, USB Key, RFC 1149, 2549
  • 35. Sometimes Slony-I isn't the Answer ● If you truly, honest to goodness, need multimaster, watch for Slony-II... ● If you need DDL to be handled automagically, look at PG 8.0 PITR ● If you have a loosely run environment, Slony-I will not go well ● No answer yet for async multimaster!
  • 36. More Cases Not to Use Slony-I ● Slony-I needs to define a node (and spawn a slon + connections) for each database – replicating 80 databases on one cluster may not turn out ● If you have 300 sequences, all 300 are propagated with each sync – this may not turn out well
  • 37. Summary ● What is Slony-I and what does it do? ● What are the components of Slony-I? ● What are some security issues surrounding the use of Slony-I?