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.
CodePudding user response:
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
CodePudding user response:
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.