How to store EBS volumes in the postgresql databaseI

0
  1. I have created a Ec2 Amazon linux 2 instance and have attached 4 extra EBS volumes ( gp2=3gb, gp3=3gb,io1=4gb, io2=4gb formatted and mounted it and I have installed postgres db (v 8.4.18) on it. ( dev/xvdf /data/db1... etc)
  2. I have created number of sample tables in the database and made my ebs root volume full to 100%. Now I am creating more table i get the error that your disk is full.
  3. I want to know how can I set the root limit or even if the root volume is 100% the further data I am creating should automatically get stored in the other EBS volumes without increasing the size of root volume. The further data should be store in any of the attached root volumes or I want to see if the data divides in all the 4 EBS volumes. 4)In the Postgres database configuration, Do I need to map the default data directory (ie, /var/lib/postgresql/) to any of the attached EBS volumes? or how can I mount those ebs volumes to one another.
Suraj
asked a year ago453 views
1 Answer
0

Hello, it's a best practice that you separate OS disk from your App files or DB binaries, so here's what I think about your design:

For setting a root limit, you can use quota command, I didn't try it except ZFS with Solaris .However, it is generally not recommended to set a root limit as this may cause issues with the system's performance and stability.

To automatically store new data on the attached EBS volumes, you can use LVM to create a logical volume that spans across all the EBS volumes and use it as PostgreSQL data directory (You will need to change your DB configuration file with new directory). Check this document https://www.redhat.com/sysadmin/lvm-vs-partitioning and https://www.digitalocean.com/community/tutorials/how-to-move-a-postgresql-data-directory-to-a-new-location-on-ubuntu-16-04

To mount the EBS volumes use the mount command to mount the EBS volumes to specific directories. For example, to mount the EBS volume at /dev/xvdf to the /data/db1 directory, you can use the following command: sudo mount /dev/xvdf /data/db1 It is important to make sure that the mount point directories

And don't forgot about permissions, newly created directory should allow PostgreSQL process access the data inside it.

profile picture
answered a year ago
  • Thanks for the answer. I tried this but data gets stores in particular directory only which I am giving the path say /dev/xvdf /data/db1. Is there a way how the data can automatically go to the next EBS volumes? Should I need to multi attach the volumes?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions