使用客戶端工具連接pg,連接失敗,報錯以下錯誤:
FATAL: remaining connection slots are reserved for non-replication superuser connections
查看數據庫連接狀態和配置信息
select * from pg_stat_activity where pid<>pg_backend_pid() and state='idle';##pg_backend_pid()的結果是當前會話的pid select datname,datconnlimit from pg_database ; select current_setting('max_connections'); select current_setting('superuser_reserved_connections');
發現參數max_connections設置太低。
因為是測試環境,就先把idle狀態的連接先殺掉:
##把數據庫中的所有的空閑會話全部kill掉 select pg_terminate_backend(pid) from pg_stat_activity where pid<>pg_backend_pid() and state='idle';
然后修改參數max_connections的值。