如何在 postgresql 9.4 中更改日志目录位置? [英] How to change log directory location in postgresql 9.4?

查看:106
本文介绍了如何在 postgresql 9.4 中更改日志目录位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前的 log_directory 路径是

my current log_directory path is

**/opt/demo/PostgreSQL/9.4/data/pg_log**

我正在尝试将日志目录路径更改为

I'm trying to change the log directory path to

**/logs/demo/**

当我取消对日志路径的注释时,服务器不会启动,只有在默认情况下才会启动.

The server won't start when i uncomment the log path and it starts only when its default.

postgresql.conf 文件看起来像

# ERROR REPORTING AND LOGGING
#------------------------------------------------------------------------------

# - Where to Log -

log_destination = 'stderr'         # Valid values are combinations of
                                  # stderr, csvlog, syslog, and eventlog,
# This is used when logging to stderr:
logging_collector = on
# These are only used if logging_collector is on:
#log_directory = '/logs/etbos/demo/'  #directorywherelogfiles are written
#log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'  # log file name pattern,


# These are relevant when logging to syslog:
#syslog_facility = 'LOCAL0'
#syslog_ident = 'postgres'

# This is only relevant when logging to eventlog (win32):
#event_source = 'PostgreSQL'

推荐答案

所以这就是我的想法 :) 您需要将新日志目录的权限授予 postgres 用户.

So this is what I supposed :) You need to grant permissions to the new log directory to postgres user.

您可以使用 f.e.:

You can do this using f.e.:

sudo chown postgres:postgres /your/new/log/dir/path

回答你的另一个问题:

要允许来自远程主机的 TCP/IP 连接,您需要编辑 pg_hba.conf 文件.您可以通过添加如下一行来允许 ALL TCP/IP 连接:

To allow TCP/IP connections from remote hosts you need to edit pg_hba.conf file. You can allow ALL TCP/IP connections by adding a line like this:

host  all  all   0.0.0.0/32  md5

上面有五个参数,你可以在 pg_hba.conf 文件顶部的注释中阅读它们,但简而言之,它们的意思是:

There are five parameters above, you can read about them in the pg_hba.conf file in the comments at the top of the file, but in short they mean:

[connection_type] [database_name] [user_name] [remote_ip/mask] [auth_type]

这篇关于如何在 postgresql 9.4 中更改日志目录位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆