0

I am new to Postgres and the database field. My question is that how many copies of each table are stored in physical storage device (memory, disk and so on)? I assume we need more than one copies for each table. If we only have one copy for each table, then it will result in one point failure if that storage device is broken. Is my understanding correct?

Thanks, Zack

2
  • Don't run disk-based databases on non-RAID storage, unless it's a distributed database from the ground up on multiple servers which guarantees N replicas (Cassandra with a replication factor > 1 for instance). But think about it: it can write 100's of copies to your single disk, that does not help you if that disk fails, all 100's of them instantly lost.
    – Wrikken
    Sep 20, 2014 at 23:12
  • Thanks. I understand that distributed databases needs multiple copies to handle one point failure. From there, I thought about traditional DB and have this question. I am just curious about current implementation.
    – Zack Li
    Sep 20, 2014 at 23:17

1 Answer 1

3

It sounds like you might be coming from an Oracle background, where the Oracle database generally manages the storage system directly.

That's not how PostgreSQL works. It uses the file systems, RAID support, etc provided by the operating system.

To get redundant storage with PostgreSQL you need to set up redundant stoage - in the form of RAID, or whatever - in the underlying operating system. Then simply put the PostgreSQL data directory and tablespace(s) on file systems that are stored on the redundant storage array(s).

A common configuration for small installs is:

  SATA disk 1           SATA disk 2
       |                     |
       -----------------------
                   |
                   v
  [Linux 'md' software RAID driver, RAID 1]
                   |
                   v
  [ext4 file system mounted on /var/lib/pgsql]
                   |
                   v
 [PostgreSQL datadir in /var/lib/pgsql/9.3/data]

Of course, that does you no good at all if the machine is destroyed by fire/lightning surge/etc, or someone does an rm -rf /var/lib/pgsql. Which is why you should also have replication to another machine, preferably off-site.

Replication won't help you if someone does a DROP TABLE precious_data; ... which is why you should additionally have frequent logical backups (pg_dump) and/or point in time recovery with WAL archiving.

0

Your Answer

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