防止每次重新启动时删除 postgresql 文件?

防止每次重新启动时删除 postgresql 文件?

每次我重新启动 Kali 机器时,我的 postgresql 服务都无法正常启动。有一段时间我不知道它是什么,但很快我发现这个目录和文件不断被删除。

/var/run/postgresql/10-main.pg_stat_tmp/global.stat

跑完之后,

mkdir /var/run/postgresql/10-main.pg_stat_tmp
touch global.stat

我现在可以成功启动服务了。

然而,这是我的 postgresql.log 的输出。

2018-01-29 16:46:03.278 UTC [1890] WARNING:  corrupted statistics file 
"/var/run/postgresql/10-main.pg_stat_tmp/global.stat"
2018-01-29 16:46:03.289 UTC [1890] WARNING:  corrupted statistics file 
"/var/run/postgresql/10-main.pg_stat_tmp/global.stat"
2018-01-29 16:46:03.299 UTC [1890] WARNING:  corrupted statistics file 
"/var/run/postgresql/10-main.pg_stat_tmp/global.stat"
2018-01-29 16:46:03.310 UTC [1890] WARNING:  corrupted statistics file 
"/var/run/postgresql/10-main.pg_stat_tmp/global.stat"
2018-01-29 16:46:03.322 UTC [1890] WARNING:  corrupted statistics file 
"/var/run/postgresql/10-main.pg_stat_tmp/global.stat"
2018-01-29 16:46:03.333 UTC [1890] WARNING:  corrupted statistics file 
"/var/run/postgresql/10-main.pg_stat_tmp/global.stat"
2018-01-29 16:46:03.343 UTC [1890] LOG:  using stale statistics instead of 
current ones because stats collector is not responding
2018-01-29 16:46:03.343 UTC [1890] WARNING:  corrupted statistics file 
"/var/run/postgresql/10-main.pg_stat_tmp/global.stat"
2018-01-29 16:46:35.896 UTC [1885] LOG:  received smart shutdown request
2018-01-29 16:46:38.988 UTC [1885] LOG:  worker process: logical replication 
launcher (PID 1892) exited with exit code 1
2018-01-29 16:46:38.990 UTC [1887] LOG:  shutting down
2018-01-29 16:46:39.125 UTC [1885] LOG:  database system is shut down

这是 postgresql.conf 里面的内容

# The default values of these variables are driven from the -D command-line
# option or PGDATA environment variable, represented here as ConfigDir.

data_directory = '/var/lib/postgresql/10/main'      # use data in another 
directory
                # (change requires restart)
hba_file = '/etc/postgresql/10/main/pg_hba.conf'    # host-based 
authentication file
                # (change requires restart)
ident_file = '/etc/postgresql/10/main/pg_ident.conf'    # ident 
configuration file
                # (change requires restart)

这是 Postgres 版本 10。

Linux Kali 4.14.0-kali3-686-pae (2018-01-25) 在 VMware 上运行的 i686 GNU/Linux

答案1

/var/run是到 的符号链接/run。您可以通过运行来看到这一点ls -l

您还可以将 Postgresql 服务设置为依赖于另一个目录,您可以在其中存储它所依赖的文件。

答案2

这是我想出的解决方案。

crontab -e

其次是

@reboot mkdir /var/run/postgresql/10-main.pg_stat_tmp
@reboot touch /var/run/postgresql/10-main.pg_stat_tmp/global.stat

当我重新启动电脑时,一切都很好并且准备就绪!

答案3

您似乎已经下载了 2018-01-25,这是潜在不稳定用于测试发行版本身的 Kali 版本。

扔掉该版本并从官方发布的下载页面获取副本:https://www.kali.org/downloads/

相关内容