-1

I have created a ec2 instance and attached 3 ebs volumes to it, I have created a lvm on the 3 ebs volumes and mounted it to /var/lib/pgsql and then installed postgresql source 8.4 and configure it to /var/lib/pgsql/data/data1 and i have created a sample table on it and the data is been store in lvm volumes( /dev/mapper/vg_ebs-lv_ebs) . I want check on which ebs volumes the data is been stored, so that I can remove the rest unused volumes in such that way that it does not affect the postgresql database.

I have attached the photos of the work. enter image description here

  1. enter image description here

  2. enter image description here

  3. enter image description here

  4. Picture

Tried to check the details by pvdisplay, lvdisplay vgdisplay, and tried to make the volume full to 100% still not able to identify which ebs volumes the data is been stored.

Want to know if 1) the data is been stored in all the volumes, 2) in root volumes 2) or any specific volumes the data is stored.

Sam
  • 19
  • 3
  • You've asked variants of this quesiton multiple times over the past month, and quite frankly none of them make sense (which is probably why you haven't gotten any answers). The way that Postgres manages its files is _completely orthogonal_ to how the volume manager combines devices. If you are having an _actual_ problem, you might find an answer to that problem on either the DBA or SuperUser sites, provided that you can describe it clearly. If you're just trying to understand how LVM works, read its documentation and try experiments that don't involve Postgres. – kdgregory Feb 10 '23 at 15:19
  • And as a general "how to ask good questions" comment: don't use screenshots of text. Use code blocks. As you can see, the screenshots are scaled to fit the reader's screen, and in some cases are too tiny to read. This comes under the heading of "help others to help you." – kdgregory Feb 10 '23 at 15:23

1 Answers1

0

Postgres data is in /var/lib/pgsql which falls under lv_ebs logical volume in vg_ebs volume group.

To provide space for this volume group, you have three physical volumes: /dev/sdf, dev/sdg and /dev/sdh.

In general, LVM decides which data from logical volume to put on which physical volume. Allocation is done by means of extents which are non-overlapping, continuous ranges of bytes, each having a starting offset and a length (similar to partitions). You can get the information about extent allocation of LVs with

lvs -o +seg_pe_ranges

In your case all the space in PVs has been allocated to your LV, so you cannot just remove PV from VG. What you need to do is:

  1. Unmount /var/lib/pgsql
  2. Use resize2fs to shrink your filesystem by at least the size of the PV that you want to remove
  3. Use lvreduce to shrink the size of LV to the reduced size of filesystem
  4. Use pvmove to move any active physical segments off of the PV being removed
  5. Use vgreduce to remove now empty PV from VG

Don't forget to back up your data first.

jurez
  • 4,436
  • 2
  • 12
  • 20
  • Thanks for the answer, Will I know to get on which EBS volumes the data has been stored? – Sam Feb 10 '23 at 15:23
  • Yes, for that you need to find out which EBS volume maps to which disk. If you are using SCSI you can probably find them by their LUNs. Worst case, you can temporarily disconnect it (while volume group is inactive) and see which disk "disappears". – jurez Feb 10 '23 at 15:29
  • Thanks @jurez, will try the steps and update it. – Sam Feb 10 '23 at 15:38