Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing Postgres data on a separate AWS EBS volume. [closed]

I have an Amazon EC2 instance running postgres. I would like to connect another EBS volume to this that is used ONLY for postgres data. I can add the volume, but how do configure postgres so it uses the mounted ebs drive for it's data storage?

like image 547
jamesonthecrow Avatar asked Oct 12 '13 17:10

jamesonthecrow


People also ask

What happens when you detach an EBS volume?

After you detach a volume, you are still charged for volume storage as long as the storage amount exceeds the limit of the AWS Free Tier. You must delete a volume to avoid incurring further charges. For more information, see Delete an Amazon EBS volume.

Will an Amazon EBS root volumes persist independently?

EBS volumes persist independently from the running life of an EC2 instance. You can attach multiple EBS volumes to a single instance. The volume and instance must be in the same Availability Zone.

What happens to data on ephemeral volume of an EBS backed instance?

EC2 EBS-backed (EBS root) instance is stopped, what happens to the data on any ephemeral store volumes? Data is automatically saved in an EBS volume. Data is unavailable until the instance is restarted. Data will be deleted and will no longer be accessible.


2 Answers

  1. Create a file system on the EBS and then mount it. See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html
  2. Set ownership of your filesystem to postgres.
  3. Use the initdb command to initialize your new space.
  4. Tell postgres to use your new file system, by using the -D option to the postgres binary, setting the PGDATA environment variable, or by setting the value of data_directory in postgresql.conf
like image 192
lreeder Avatar answered Sep 22 '22 02:09

lreeder


You would edit the postgres pgdata and point it to the directory mapped to your EBS volume, as described in the thread here -

http://www.linuxquestions.org/questions/linux-server-73/change-postgresql-data-directory-649911/

like image 31
kgu87 Avatar answered Sep 20 '22 02:09

kgu87