skip to Main Content

My AWS EC2 has two volumes, primary and secondary, with the secondary volume being larger. I am looking to install Postgres on this EC2. As the database gets used, I anticipate it will overrun the size of the primary volume. So,

1 – How can I install it such that the database sits on the secondary volume? I am referencing this article for installation. Particularly, the following command installs it on the primary volume:

sudo yum install postgresql postgresql-server postgresql-devel postgresql- contrib postgresql-docs

2 – Is is advisable to install it on the secondary volume? If no, why?

Thanks.

2

Answers


  1. The standard pattern I see for this is to install postres db the normal way to the normal place, and then setting the pg data directory to a mountpoint on a different volume. This differentiates the postgres application files (which would be on the same volume as the rest of the OS filesystem) from the postgres data (which would be on the secondary). It can be advisable for a few reasons – isolating db data disk usage from system disk usage is a good one. Another reason is to be able to scale throughput and size independently and see usage independently.

    Login or Signup to reply.
  2. 1 – How can I install it such that the database sits on the secondary volume?

    see the documentation, basically you can initialize a database on any folder
    https://www.postgresql.org/docs/13/app-initdb.html

    Example:

    initdb -D /mnt/data
    

    2 – Is is advisable to install it on the secondary volume? If no, why?

    Sure, it’s easier to maintain and resize a non-root volume.

    Regardless that with AWS you could consider running the AWS RDS, where a lot of maintenance tasks (e.g. storage auto-scaling) is offloaded to AWS

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search