0

does anyone know how to make a PostgreSQL database replica on one raspberrypi2? Perhaps partitioning what is left of my mmcblk0p1 partition into 2, one containing the master and the other one the slave?

I am guiding myself with this quick tutorial but they don't delve deeper on how many machines they are using:

http://pgsnaga.blogspot.de/2010/05/5-steps-to-implement-postgresql.html

I am using raspbian jessie and a raspberrypi2 and have already setup a postgres database.

1 Answer 1

2

In the blog post linked, the word node pretty much means machine. They are using 2 different computers for the slave and master nodes.

A hint is in the slave node section;

primary_conninfo = 'host=10.0.2.41 port=5432 user=snaga'

Where host points to the IP address of the master machine.

These no not have to be physical machines, they could well be virtual instances running on the same box (ok for testing, pointless in production).

However, with only 1 RaPi you are going to run into significant problems trying to copy this. You really need 2.

If you are determined to try this, this post describes how to run 2 Postgre instances on 1 box but this is pointless for replication - replication is to provide a backup machine in case of hardware failure in the primary.

4
  • Hi Skrrp, thanks for your answer, I will try checking the link out. And the idea behind the replication is not only for backup but also to query a different db other than the main one connected to the website directly.
    – johan855
    Dec 30, 2015 at 12:10
  • 2
    Postgres is perfectly capable of serving more than one database per server. If you're worried about separation for security's sake, check out users and permissions. You can also limit connections per connection type per database per user in pg_hba.conf
    – Skrrp
    Dec 30, 2015 at 13:05
  • 2
    @johan855 what is going to effect performance more trying to run two instances of postgres on a single Pi or making extra database requests? You are so worried about querrying a separate DB that you are blind to the bigger issues Dec 30, 2015 at 13:43
  • 2
    Ditto Steve. You don't need two DB servers to query two DBs, and there is not much point in conquering paranoia about one server by running another one on the same machine. It will almost certainly make things worse, not better.
    – goldilocks
    Dec 30, 2015 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.