Exclude Database from Streaming Replication - postgresql

Is it possible to exclude a specific database from streaming replication in Pg 9.1?
Say I have two databases A and B defined, the goal is to ignore everything concerning database B on the backup server.
Thanks for your hints!

No, it's not possible. The replication always works for the complete cluster.
With Postgres 9.5 or later you can use the extension pglogical to do that.

Use Slony-I http://slony.info/ or other replication solutions to replicate partially.

Related

Validating the postgres upgrade using logical replication

Currently I am trying to upgrade my postgres 9.1 to 10 using logical replication. As 9.1 does not support native logical_replication, I tried slony and made a replica successfully.
P.S. The above replica I created is using a sample dump from an year ago which is only of 800mb.
Now I have few questions.
How can I validate whether the replica has all the data replicated successfully. Few suggested to put the master on maintenance mode(few downtime) and do a last N items comparison with both the database on all the tables.
I tried with 800mb. Will there be any problem when I go and try with 100+ GB?
Please share your personal experience here. I have been trying to document what are the things that could go wrong so I can always try to anticipate the next course of action.
You may use the Data Validator that is shipped with trial version of EDB Postgres Replication server for validating the data between old and new PostgreSQL databases.
You may read the details of Data Validator at Data Validator Document
To download the EDB Replication Server please follow this link: EDB Replication Server
Disclosure: I work for EnterpriseDB (EDB)

Is it possible to do Postgresql writable slave?

Is it possible to do writable slave in postgresql master-slave replication model?
Db contains just one unindexed table.
I managed to achieve it with BDR master-master replication, but it eventually tables become locked to writes, both master and slave, for some reason, so I was forced to remove it and try something else.
Im looking to Slony and burcado now, but not sure from docs that I can get writable slave.
Yes, you can have a writable replica using Slony; I'm doing that now at work.
However: the tables that are being replicated can't be modified. You can have other tables in the same database and schema that are writable, just not the ones being replicated.

Migrate database from Heroku to AWS

I want to migrate our postgres db from heroku to our own postgres on AWS.
I have tried using pg_dump and pg_restore to do the migration and it works; but it takes a really long time to do this. Our database size is around 20GB.
What's the best way to do the migration with minimal downtime?
If you mean AWS RDS PostgreSQL:
pg_dump and pg_restore
I know you don't like it, but you don't really have other options. With a lot of hoop jumping you might be able to do it with Londiste or Slony-I on a nearby EC2 instance, but it'd be ... interesting. That's not the most friendly way to do an upgrade, to say the least.
What you should be able to do is ship WAL into RDS PostgreSQL, and/or stream replication logs. However Amazon don't support this.
Hopefully Amazon will adopt some part of 9.4's logical replication and logical changeset extraction features, or better yet the BDR project - but I wouldn't hold my breath.
If you mean AWS EC2
If you're running your own EC2 instance with Pg, use replication then promote the standby into the new master.

is it possible to make replication between versions 9.1 and 9.3

all instructions lead to synchronize data folders from master server to slave. But it can not be done between major releases.
ps: general task is update master and slave server from 9.1 to 9.3
It is not entirely clear what you are talking about.
If you're talking about slony replication, it is designed to replicate data across versions. I've replicated databases from 8.4 to 9.1. You must have running the same schema (regarding the replicated objects) on both servers already. Slony replicates tables and sequences very well, it has some stuff for replicating schema changes, but I prefer doing this out-of-band.
If you're talking about in-place upgrading your db server, I'd suggest reading the fine documentation and going from 9.1 to 9.2, then to 9.3 (just to be cautious)

Mirror one database to another in PostgreSQL

I know the way to set up a Master/Slave DB in Postgres is having 2 DB servers, but unfortunately i have only one server for now.
How can i mirror my production db into another "backup db" in "real_time"? I want to give access to another user to the mirrored db, so even if he does something there it will not affect production.
Nothing stops you setting up hot standby streaming replication, or another replication option like Londiste, between two PostgreSQL instances on the same computer.
The two copies of PostgreSQL must use different ports, but that's the only real restriction.
How to set up the second PostgreSQL instance depends on your operating system and how you installed PostgreSQL, which you have not mentioned.
You'll want to use streaming replication with hot standby if you want a read-only replica. If you want it to be read/write, then you can do a one-off copy of the database with pg_basebackup and not keep them in sync after that. Or you can use a tool like Londiste to replicate changes selectively.
You can run multiple instances of PostgreSQL on the same computer, by using different ports.