1 - System
2 vCPU
2 Go RAM
3 0go disque
2 - Système d'exploitation
A désactiver sur un serveur dédié
nano /etc/sysctl.d/S99-postgresql
vm.overcommit_memory = 2
vm.dirty_background_bytes = 0
vm.dirty_background_ratio = 10
vm.dirty_bytes = 0
vm.dirty_ratio = 20
vm.nr_hugepages = 0
vm.nr_overcommit_hugepages = 0
vm.overcommit_ratio = 0
vm.swappiness = 0
vm.zone_reclaim_mode = 0
3 - Installation du dépôt
dnf install https://download.postgresql.org/pub/...est.noarch.rpm -y
dnf -qy module disable postgresql
4 - Installation du paquet
dnf install postgresql15-server postgresql15-contrib -yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest
5 - Configuration Service
mkdir -p /etc/systemd/system/postgresql-15.service.d
cat /etc/systemd/system/postgresql-15.service.d/override.conf <<_EOF_
[Service]
Environnement=PGDATA=/data
_EOF_
6 - installation répertoire des données
install -d -o postgres -g postgres -m 700 /data
rm -rf /wal/lost+found/
chown -R postgres
ostgres /walPGSETUP_INITDB_OPTIONS="--data-checksums --waldir /wal" /usr/pgsql-15/bin/postgresql-15-setup initdb
--data-checksums : active les sommes de contrôle sur les fichiers de données
--waldir : indique un autre répertoire de stockage pour le journaux
initdb : créer les répertoires et fichier nécessaires
7 - Activation et démarrage
systemctl enable postgresql-15
systemctl start postgresql-15
8 - Configuration utilisateur
Dans les fichiers
.profile
.bash_profile
PGDATA
export PGDATA=/data
PATH
export PATH/usr/pgsql-15/bin:$PATH
9 - Ajouter une autre instance
ln -s /usr/lib/systemd/system/postgresql-15.service /etc/systemd/system/pg2.service
mkdir -p /etc/systemd/system/postgresql-15-2.service.d
cat /etc/systemd/system/postgresql-15-2.service.d/override.conf <<_EOF_
[Service]
Environnement=PGDATA=/data2
_EOF_
systemctl daemon-reload
install -d -o postgres -g postgres -m 700 /data2
PGSETUP_INITDB_OPTIONS="--data-checksums --waldir /wal" /usr/pgsql-15/bin/postgresql-15-setup initdb postgresql-15-2
systemctl enable postgresql-15-2
systemctl start postgresql-15-2
