Modificare le impostazioni di PostgreSQL
ServBay include un database PostgreSQL e offre opzioni di configurazione flessibili. Questo articolo descrive in dettaglio come modificare le impostazioni di PostgreSQL in ServBay, inclusa la posizione dei file di configurazione e le impostazioni comuni. A seconda della versione di PostgreSQL, questi file si trovano nella directory /Applications/ServBay/db/postgresql/<version>
, ad esempio i file di configurazione di PostgreSQL 16 si trovano nella directory /Applications/ServBay/db/postgresql/16
.
Panoramica
In ServBay, i file di configurazione di PostgreSQL sono memorizzati in diverse directory a seconda della versione. Ad esempio, i file di configurazione di PostgreSQL 16 si trovano nella directory /Applications/ServBay/db/postgresql/16
. I file di configurazione principali includono postgresql.conf
e pg_hba.conf
.
Posizione dei file di configurazione
postgresql.conf
:/Applications/ServBay/db/postgresql/16/postgresql.conf
pg_hba.conf
:/Applications/ServBay/db/postgresql/16/pg_hba.conf
Impostazioni comuni e modalità di modifica
postgresql.conf
postgresql.conf
è il file di configurazione principale di PostgreSQL, utilizzato per impostare le opzioni di runtime del server di database.
Impostazioni comuni
Modificare l'indirizzo di ascolto:
listen_addresses = '*'
1Modificare il numero di porta:
port = 5432
1Modificare il numero massimo di connessioni:
max_connections = 100
1Modificare la dimensione dei buffer condivisi:
shared_buffers = 128MB
1Modificare il percorso dei file di log:
log_directory = 'log' log_filename = 'postgresql-%Y-%m-%d.log'
1
2Abilitare il log delle query lente:
log_min_duration_statement = 2000 # In millisecondi, registra le query che impiegano più di 2 secondi per essere eseguite.
1
pg_hba.conf
Il file pg_hba.conf
viene utilizzato per configurare i metodi di autenticazione delle connessioni client.
Impostazioni comuni
Consentire le connessioni locali:
# "local" è solo per le connessioni tramite socket di dominio Unix local all all trust
1
2Consentire le connessioni remote da tutti gli indirizzi IP:
# Connessioni locali IPv4: host all all 0.0.0.0/0 md5
1
2Consentire le connessioni remote da un indirizzo IP specifico:
# Connessioni locali IPv4: host all all 192.168.1.0/24 md5
1
2
Riavviare PostgreSQL
Dopo aver modificato i file di configurazione di PostgreSQL, è necessario riavviare il servizio PostgreSQL affinché le modifiche abbiano effetto. Puoi riavviare utilizzando l'interfaccia di gestione di ServBay o utilizzando lo strumento a riga di comando servbayctl
.
Riavviare tramite l'interfaccia di gestione di ServBay
- Apri l'interfaccia di gestione di ServBay.
- Naviga a
Servizi
. - Trova il servizio PostgreSQL della versione corrispondente e clicca sul pulsante
Riavvia
.
Riavviare tramite servbayctl
Puoi comodamente riavviare il servizio PostgreSQL utilizzando lo strumento a riga di comando servbayctl
:
servbayctl restart postgresql 16
Conclusione
In ServBay, i file di configurazione di PostgreSQL si trovano nella directory /Applications/ServBay/db/postgresql/<version>
, inclusi postgresql.conf
e pg_hba.conf
. Dopo aver modificato questi file di configurazione, puoi riavviare il servizio PostgreSQL tramite l'interfaccia di gestione di ServBay o utilizzando lo strumento a riga di comando servbayctl
per rendere effettive le modifiche.