Archivio mensile:Maggio 2023

Postgresql e la funzione vacuum

Facendo l’aggiornamento di release di postgresql dalla 13.9 alla 15.2, in ambiente AWS,bisogna rifare le statistiche delle tabelle: ho cercato in giro se fosse possibile in maniera automatica, ma alla fine ho realizzato uno script per aggiornare le info:

schemas=psql -t -A -U USER -h IP_ADD DATABASE -c "select schema_name from information_schema.schemata"

for schema in $schemas
do
psql -t -A -U USER -h IP_ADD DATABASE -c "select format('analyse verbose %I.%I;', n.nspname::varchar, t.relname::varchar) FROM pg_class t JOIN pg_namespace n ON n.oid = t.relnamespace WHERE t.relkind = 'r' and n.nspname::varchar = '$schema' order by 1" | psql -U USER -h IP_ADD DATABASE
done

Come aggiungere spazio ad un disco di una VM sotto PVE

Di seguito quello che ho fatto per ampliare da 32 a 64GB lo spazio della mia macchina repository di immagini docker

[23059.572021] sd 2:0:0:0: [sda] 134217728 512-byte logical blocks: (68.7 GB/64.0 GiB)
[23059.573015] sda: detected capacity change from 67108864 to 134217728

root@docker:~# parted /dev/sda
GNU Parted 3.4
Using /dev/sda
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) print
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 67108864
blocks) or continue with the current setting?
Fix/Ignore? f
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 68.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB bios_grub
2 2097kB 34.4GB 34.4GB ext4

(parted) resizepart 2 100%
Warning: Partition /dev/sda2 is being used. Are you sure you want to continue?
Yes/No? y
(parted) print
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 68.7GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB bios_grub
2 2097kB 68.7GB 68.7GB ext4

(parted) quit
Information: You may need to update /etc/fstab.

root@docker:~# resize2fs /dev/sda2
resize2fs 1.46.5 (30-Dec-2021)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 8
The filesystem on /dev/sda2 is now 16776699 (4k) blocks long.

root@docker:~# df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 198M 1.3M 197M 1% /run
/dev/sda2 63G 28G 33G 47% /
tmpfs 988M 0 988M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 198M 4.0K 198M 1% /run/user/1000
overlay 63G 28G 33G 47% /var/lib/docker/overlay2/c3e70e17d7f859993c39376e66c91ac89099a1336d6bd5a577c701d3f687c921/merged
shm 64M 0 64M 0% /var/lib/docker/containers/677cfe3fd4c993f9a9f0ad650370d105bcc4c3c0e2ee46d012835b0348fdde31/mounts/shm