View on slave postgres database - postgresql

In postgres streaming replication master-slave setup, can we create views only on slave/standby server?
Can I have more than one standby slaves?
I am using postgresql 9.3.

re 1): this is not possible. The slave is always a 100% identical copy of the master.
re 2): yes this is possible. Quote from the manual:
You can have any number of standby servers

Related

Can we do streaming and logical replication in postgresql Slave at same time?

We have PostgresSQL cluster with 1 master and 2 slave configuration , we want to enable logical replication from Slave , as the master a pretty work heavy database , we don’t want to put more load on DB , Is it possible if we can start both type of replication from any slave currently replicating through streaming replication
we have setup with master it worked , not sure with slave , we did few test run in older vesrion which failed
No, the logical replication primary cannot be a streaming replication standby server.

Postgres master / slave based on table

Currently I have 1 postgres instance which is starting to receive too much load and want create a cluster of 2 postgres nodes.
From reading the documentation for postgres and pgpool, it seems like I can only write to a master and read from a slave or run parallel queries.
What I'm looking for is a simple replication of a database but with master/slave based on which table is being updated. Is this possible? Am i missing it somewhere in the documentation?
e.g.
update users will be executed on server1 and replicated to server2
update big_table will be executed on server2 and replicated back to server1
What you are looking for is called MASTER/MASTER replication. This is supported natively (without PgPool) since 9.5. Note, that it's an "eventually consistent" architecture, so your application should be aware of possible temporary differences between the two servers.
See PG documentation for more details and setup instructions.

How to create or alter database in slave in Postgresql 9.3?

I tried replication in postgres 9.3, and successfully implemented it.
After that i am unable to create new database in slave. It says "cannot execute CREATE TABLE in a read-only transaction." Does this mean i cannot create or alter database in slave?
That is correct. The slave is in read-only mode and all changes you want to make should be done on the master server that propagates it to its slaves. Making the slave read-write would defeat the purpose of the replication (if we are not considering master-master or multi-master replication)

How to introduce delay in POSTGRESQL 9.3 replication?

I have master slave replication setup. How I can force some delay in replication ?
Is there a setting that I can use ?
Thanks !
Not in 9.3.
In 9.4 you can use min_recovery_apply_delay. See this blog post.
In 9.3, if you have WAL-archive based replication (no streaming) you could archive the WAL to one location, and only move it to a location readable by the standby after a delay. You can't do it with streaming in 9.3.

Postgres Replication Tools for DDL

Is there any tools for replication in postgres which can doing the following :
automatic DDL replication?
when master DB down, then slave will become the master DB immediately.
my company database is +- 5GB size
i have search some tools for replication which is slony and bucardo (and all trigger based replication system cannot doing the DDL replication)(source). and for 9.0 Streaming Replication (built in on postgres),Gabriel Weinberg (DuckDuckGo)said "Steve Signer wrote up some cases where you wouldn't want to/be able to use the built-in replication"
so 3 tools i found (slony,bucardo and 9.0 SR) , doesnt meet my criteria to do the postgres. is there any suggestion?
thanks
automatic DDL replication?
=> Use streaming replication, replicates everything.
when master DB down, then slave will become the master DB immediately.
=> pgPool does it's job over here, works fine.
my company database is +- 5GB size
=> That's very small, don't worry.
You can use debezium for replication transactions (insert, delete and update)... for ddl you can use kafka connect ;)