如何重新加载 PostgreSQL 配置

发布于 2025-01-11 07:31:30 字数 519 浏览 0 评论 0原文

我试图通过设置此标志来启用 PostgreSQL 中的事务日志,其中查询运行时间超过 3 秒

log_min_duration_statement = 3000

如何在不重新启动 Postgres 的情况下重新加载配置文件?

我已尝试以下选项并收到这些错误

1) postgres=# select pg_reload_config();
**ERROR:  function pg_reload_config() does not exist**
LINE 1: select pg_reload_config();
2) postgres@ospostgresql:/$ /usr/lib/postgresql/11/bin/pg_ctl reload
pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information.

I am trying to enable the transaction logs in PostgreSQL, where query run time is more than 3 seconds, by setting this flag

log_min_duration_statement = 3000

How to reload the configuration file without restarting the Postgres?

I've tried the below options and got these errors

1) postgres=# select pg_reload_config();
**ERROR:  function pg_reload_config() does not exist**
LINE 1: select pg_reload_config();
2) postgres@ospostgresql:/$ /usr/lib/postgresql/11/bin/pg_ctl reload
pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

调妓 2025-01-18 07:31:30

感谢 a_horse_with_no_name 帮助识别导致问题 1 的拼写错误

1) postgres=# select pg_reload_config();
**ERROR:  function pg_reload_config() does not exist**
**-->** This is resolved by giving correct function name i.e. 
    select pg_reload_conf();

2) postgres@ospostgresql:/$ /usr/lib/postgresql/11/bin/pg_ctl reload
pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information.
**-->** This error is resolved by changing the user to postgres
    1) su postgres
    2) /usr/lib/postgresql/11/bin/pg_ctl -D /var/lib/postgresql/11/main reload

Thank you a_horse_with_no_name in helping to identify the typo which causes issue-1

1) postgres=# select pg_reload_config();
**ERROR:  function pg_reload_config() does not exist**
**-->** This is resolved by giving correct function name i.e. 
    select pg_reload_conf();

2) postgres@ospostgresql:/$ /usr/lib/postgresql/11/bin/pg_ctl reload
pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information.
**-->** This error is resolved by changing the user to postgres
    1) su postgres
    2) /usr/lib/postgresql/11/bin/pg_ctl -D /var/lib/postgresql/11/main reload
治碍 2025-01-18 07:31:30

上面的答案显示了 2 种方法来执行此操作,但我发现有 3 种不同的方法来加载 Postgresql 配置。显然 systemctl reload postgresql 也可以工作。

参考: https://www.heatware.net/postgresql/postgresql -reload-config-without-restarting/

The above answer shows 2 ways to do this, but I found that there are 3 different ways to load Postgresql configuration. Apparently systemctl reload postgresql will also work.

Reference: https://www.heatware.net/postgresql/postgresql-reload-config-without-restarting/

栀子花开つ 2025-01-18 07:31:30

请使用:

SELECT pg_reload_conf();

或简单地:

postgres@server:$ psql -c "SELECT pg_reload_conf()"

Please use:

SELECT pg_reload_conf();

Or simply:

postgres@server:$ psql -c "SELECT pg_reload_conf()"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文