Modifier les Paramètres de PostgreSQL
ServBay est livré avec une base de données PostgreSQL et offre des options de configuration flexibles. Cet article explique en détail comment modifier les paramètres PostgreSQL dans ServBay, y compris l'emplacement des fichiers de configuration et les options de configuration courantes. Selon la version de PostgreSQL, ces fichiers se trouvent dans le répertoire /Applications/ServBay/db/postgresql/<version>
, par exemple, les fichiers de configuration de PostgreSQL 16 se trouvent dans le répertoire /Applications/ServBay/db/postgresql/16
.
Aperçu
Dans ServBay, les fichiers de configuration PostgreSQL sont stockés dans des répertoires différents selon la version. Par exemple, les fichiers de configuration de PostgreSQL 16 se trouvent dans le répertoire /Applications/ServBay/db/postgresql/16
. Les principaux fichiers de configuration incluent postgresql.conf
et pg_hba.conf
.
Emplacement des Fichiers de Configuration
postgresql.conf
:/Applications/ServBay/db/postgresql/16/postgresql.conf
pg_hba.conf
:/Applications/ServBay/db/postgresql/16/pg_hba.conf
Options de Configuration Courantes et Comment les Modifier
postgresql.conf
postgresql.conf
est le fichier principal de configuration de PostgreSQL, utilisé pour définir les options d'exécution du serveur de bases de données.
Options de Configuration Courantes
Modifier l'adresse d'écoute :
listen_addresses = '*'
1Modifier le numéro de port :
port = 5432
1Modifier le nombre maximum de connexions :
max_connections = 100
1Modifier la taille des tampons partagés :
shared_buffers = 128MB
1Modifier le chemin des fichiers de journalisation :
log_directory = 'log' log_filename = 'postgresql-%Y-%m-%d.log'
1
2Activer les journaux de requêtes lentes :
log_min_duration_statement = 2000 # En millisecondes, enregistrer les requêtes prenant plus de 2 secondes à s'exécuter.
1
pg_hba.conf
Le fichier pg_hba.conf
est utilisé pour configurer les méthodes d'authentification des connexions client.
Options de Configuration Courantes
Permettre les connexions locales :
# "local" est pour les connexions par socket Unix uniquement local all all trust
1
2Permettre les connexions distantes pour toutes les adresses IP :
# Connexions locales IPv4 : host all all 0.0.0.0/0 md5
1
2Permettre les connexions distantes pour une adresse IP spécifique :
# Connexions locales IPv4 : host all all 192.168.1.0/24 md5
1
2
Redémarrer PostgreSQL
Après avoir modifié les fichiers de configuration de PostgreSQL, il est nécessaire de redémarrer le service PostgreSQL pour que les changements prennent effet. Vous pouvez redémarrer via l'interface de gestion de ServBay ou en utilisant l'outil de ligne de commande servbayctl
.
Redémarrer via l'Interface de Gestion de ServBay
- Ouvrez l'interface de gestion de ServBay.
- Allez dans
Services
. - Trouvez le service PostgreSQL correspondant à la version, puis cliquez sur le bouton
Redémarrer
.
Redémarrer via servbayctl
Utilisez l'outil de ligne de commande servbayctl
pour redémarrer facilement le service PostgreSQL :
servbayctl restart postgresql 16
Conclusion
Dans ServBay, les fichiers de configuration de PostgreSQL se trouvent dans le répertoire /Applications/ServBay/db/postgresql/<version>
, y compris postgresql.conf
et pg_hba.conf
. Après avoir modifié ces fichiers de configuration, vous pouvez redémarrer le service PostgreSQL via l'interface de gestion de ServBay ou en utilisant l'outil de ligne de commande servbayctl
pour que les modifications prennent effet.