Based on various sources
sudo dnf module list postgresql
sudo dnf install https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm -y
sudo dnf update -y
sudo dnf -qy module disable postgresql
sudo dnf install -y postgresql15-server
psql -V
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
sudo systemctl enable postgresql-15
sudo systemctl start postgresql-15
sudo systemctl status postgresql-15
Update password in SQL script below
sudo passwd postgres
su - postgres
psql -c "ALTER USER postgres WITH PASSWORD 'your-password';"
sudo dnf install epel-release -y
sudo dnf install postgresqltuner -y
BEFORE RUNNING THIS TOOL Create ~/.pgpass for postgres account so no passwords are visible in logs/console history https://www.postgresql.org/docs/current/libpq-pgpass.html OR ran under postgres user
~/.pgpass
localhost:5342:template1:postgres:your-password
- Based on https://www.enterprisedb.com/blog/improving-postgresql-performance-without-making-changes-postgresql
- https://www.centlinux.com/2021/08/disable-transparent-huge-pages-centos-rhel-8.html
- https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/virtualization_tuning_and_optimization_guide/sect-virtualization_tuning_optimization_guide-memory-huge_pages-1gb-runtime
- Test what HugePage memory sizes are supported
If first line returns pse 2MB page size is supported If second line returns pdpe1gb 1GB page size is supported - BETTER VARIANT for bigger servers
cat /proc/cpuinfo | grep -o ".\{0,0\}pse.\{0,0\}" | head -n 1
cat /proc/cpuinfo | grep -o ".\{0,0\}pdpe1gb.\{0,0\}" | head -n 1
- Disable Transparent Huge Pages, PostgreSQL doesn't like them
- Update grup configuration
/etc/default/grub
# add following configurations as last parameters in GRUB_CMDLINE_LINUX
# this line disables transparent hugepages and allocated 4 1GB blocks and 2*1024MB memory blocks
transparent_hugepage=never default_hugepagesz=1G hugepagesz=1G hugepages=4 hugepagesz=2M hugepages=1024
After that run this command to update grup settings and reboot
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
To check if the settings are valid you could run this command, but it only shows 4 1GB block allocated, if you use them
grep Huge /proc/meminfo
You can also check /sys/devices/system/node/node0/hugepages where you'll find, for example, nr_hugepages for total number of 1GB huge pages in /hugepages-1048576kB folder and number of free 1GB huge pages in free_hugepages file
System configuration
This change in /etc/sysctl.conf will disable memory overcommitment
# PostgreSQL required settings
vm.overcommit_memory=2
So far tested and seems working quite fine. New configurations as I learn them