Opened 22 months ago

Last modified 22 months ago

#12778 assigned Task/To do item

Extend /var/lib/postgresql on lucius

Reported by: https://id.mayfirst.org/jaimev Owned by: https://id.mayfirst.org/jaimev
Priority: High Component: Tech
Keywords: lucius postgres Cc: https://id.mayfirst.org/jamie
Sensitive: no

Description (last modified by https://id.mayfirst.org/jaimev)

Our owncloud service hosted on lucius uses a separate partition for the postgres database mounted from /dev/sda1 to /var/lib/postgresql within lucius.

/dev/sda is a virtual drive based on a logical volume on wiwa whose physical volume is an ssd drive on wiwa.

/dev/sda in lucius has only one partition and no lvm stack.

This partition was at 96% capacity

0 lucius:~# df -h /var/lib/postgresql
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        9.8G  8.8G  442M  96% /var/lib/postgresql

Change History (2)

comment:1 Changed 22 months ago by https://id.mayfirst.org/jaimev

  • Description modified (diff)
  • Owner set to https://id.mayfirst.org/jaimev
  • Status changed from new to assigned

comment:2 Changed 22 months ago by https://id.mayfirst.org/jaimev

On wiwa I extended the corresponding logical volume and then reboot lucius with shutdown -h now.

0 wiwa:~# lvextend --size +10G /dev/mapper/vg_wiwa1-lucius

Once lucius was up again I stopped both apache2 and postgres services

0 lucius:~# systemctl stop apache2 postgresql@9.4-main.service

I attempted to make a backup of postgres with the pg_dumpall command but realized I didn't have enough space to do so. To solve this I created a new logical volume from volume group vg_lucius0, formatted this lv, mounted in to /mnt, and created a new directory there writable by the postgres user.

0 lucius:~# lvcreate --size 20G -n postgres_backup vg_lucius0
0 lucius:~# mkfs.ext4 /dev/mapper/vg_lucius0-postgres_backup
0 lucius:~# mount /dev/mapper/vg_lucius0-postgres_backup /mnt/
0 lucius:~# mkdir /mnt/postgres_backup
0 lucius:~# chown postgres:postgres /mnt/postgres_backup

Then as the postgres user I was able to create the dump

0 lucius:~# su - postgres
postgres@lucius:~$ pg_dumpall >  /mnt/postgres_backup/postgres_dumpall_21052017

I then unmounted /var/lib/postgresql as root

0 lucius:~# umount /var/lib/postgresql

Then I ran parted in interactive mode on sda1

0 lucius:~# parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit s
(parted) p
Disk /dev/sda: 41943040s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start  End        Size       File system  Name  Flags
 1      8192s  20971486s  20963295s  ext4         main

(parted) rm 1
(parted) mkpart primary ext4 8192s -1
Warning: You requested a partition from 8192s to 41943039s (sectors 8192..41943039).
The closest location we can manage is 8192s to 41943006s (sectors 8192..41943006).
Is this still acceptable to you?
Yes/No? Yes
(parted) p
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 41943040s
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start  End        Size       File system  Name     Flags
 1      8192s  41943006s  41934815s  ext4         primary

(parted) quit

I extended the fielsystem on /dev/sa1 and mounted /var/lib/postgresql again

0 lucius:~# resize2fs /dev/sda1
0 lucius:~# mount /var/lib/postgresql

I started the services again

0 lucius:~# systemctl stop apache2 postgresql@9.4-main.service

I've unmounted /dev/mapper/vg_lucius0-postgres_backup from /mnt and can delete this logical volume as soon as we are sure that the owncloud service is functioning properly. It does appear to be up now.

Please login to add comments to this ticket.

Note: See TracTickets for help on using tickets.