Postgresql
在啟動時啟動 pgbouncer
我安裝了 pgbouncer 並對其進行了配置,它只能通過使用此命令啟動
pgbouncer /etc/pgbouncer/pgbouncer.ini
但是使用 service pgbouncer start 它不會啟動。然後我用這個設置設置了supervior來管理它,它工作正常。
[program:pgbouncer] command=pgbouncer /etc/pgbouncer/pgbouncer.ini stdout_logfile=/var/log/supervisor/pg_bouncer.log stderr_logfile=/var/log/supervisor/pg_bouncer_error.log autostart=true stopsignal=QUIT redirect_stderr=true directory=/etc/pgbouncer/ user=postgres group=postgres preload_app = True
當我重新啟動系統時,pgbouncer 不起作用,查看 pgbouncer 日誌這裡是錯誤的內容
WARNING Cannot listen on ::/6432: bind(): Address already in use WARNING Cannot listen on unix:/var/run/postgresql/.s.PGSQL.6432: bind(): No such file or directory FATAL @src/main.c:553 in function write_pidfile(): /var/run/pgbouncer/pgbouncer.pid: No such file
並查看主管日誌,這就是它所說的
LOG File descriptor limit: 1024 (H:4096), max_client_conn: 100, max fds possible: 130 LOG listening on 0.0.0.0:6432 WARNING Cannot listen on ::/6432: bind(): Address already in use WARNING Cannot listen on unix:/var/run/postgresql/.s.PGSQL.6432: bind(): No such file or directory FATAL @src/main.c:553 in function write_pidfile(): /var/run/pgbouncer/pgbouncer.pid: No such file or directory
任何人都可以幫忙嗎?
事實證明,我將 pidfile 放在 /var/run 中,這可以很好地執行它,但是當伺服器重新啟動時,文件被刪除並且 pgbouncer 找不到該文件,它給出了這個錯誤
FATAL @src/main.c:553 in function write_pidfile(): /var/run/pgbouncer/pgbouncer.pid: No such file or directory
因此,只需將文件移動到另一個位置並 chown 目錄即可
$ sudo mkdir ~/pgbouncer $ sudo chown -R postgres:postgres ~/pgbouncer
如果您的埠被佔用,您可以隨時檢查佔用您的埠的內容
sudo lsof -i -P -n | grep 6432
就我而言,我已經執行了 pboucner,發現了這個
pgrep pbouncer