安装最新版本的 OS X(Yosemite 或 El Capitan)后缺少“pg_tblspc" [英] `pg_tblspc` missing after installation of latest version of OS X (Yosemite or El Capitan)

查看:40
本文介绍了安装最新版本的 OS X(Yosemite 或 El Capitan)后缺少“pg_tblspc"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 OS X 中使用自制软件中的 postgres,但是当我重新启动系统时,有时重新启动后 postgres 不会启动,因此我手动尝试使用 postgres -D/usr/local 启动它/var/postgres,但随后出现错误并显示以下消息:FATAL: could not open directory "pg_tblspc": No such file or directory.

I use postgres from homebrew in my OS X, but when I reboot my system, sometimes the postgres doesn't start after the reboot, and so I manually tried to start it with postgres -D /usr/local/var/postgres, but then the error occurred with the following message: FATAL: could not open directory "pg_tblspc": No such file or directory.

上次出现的时候,无法恢复到原来的状态,所以决定卸载整个postgres系统,然后重新安装,创建用户、表、数据集等...原来是这样恶心,但它经常出现在我的系统上,比如几个月一次.

The last time it occurred, I couldn't get it to the original state, so I decided to uninstall the whole postgres system and then re-installed it and created users, tables, datasets, etc... It was so disgusting, but it frequently occurs on my system, say once in a few months.

那为什么会经常丢失pg_tblspc文件呢?我可以做些什么来避免文件丢失?

So why does it lose the pg_tblspc file frequently? And is there anything that I can do to avoid the loss of the file?

我还没有将我的自制软件和 postgres 升级到最新版本(即我一直在使用相同的版本).此外,我在 postgres 数据库上所做的所有事情都是每天删除表并填充新数据.我没有更改用户、密码等...

I haven't upgraded my homebrew and postgres to the latest version (i.e. I've been using the same version). Also, all the things that I did on the postgres database is delete the table and populate the new data every day. I haven't changed the user, password, etc...

编辑(mbannert):我觉得有必要添加这个,因为该线程是 google 上这个问题的热门话题,而且对于许多人来说,症状是不同的.家庭酿酒师可能会遇到此错误消息:

EDIT (mbannert): I felt the need to add this, since the thread is the top hit on google for this issue and for many the symptom is different. Homebrewers likely will encounter this error message:

No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

因此,如果您在优胜美地升级后刚刚经历过这种情况,那么您现在可以阅读此主题.

So, if you just experienced this after the Yosemite upgrade you now you're covered for now reading this thread.

推荐答案

已部分解决.

显然,安装最新版本的 OS X(例如 Yosemite 或 El Capitan)会删除 /usr/local/var/postgres 中的一些目录.

Apparently, Installing the latest versions of OS X (e.g. Yosemite or El Capitan) removes some directories in /usr/local/var/postgres.

要解决此问题,您只需重新创建丢失的目录:

To fix this you simply recreate the missing directories:

mkdir -p /usr/local/var/postgres/pg_commit_ts
mkdir -p /usr/local/var/postgres/pg_dynshmem
mkdir -p /usr/local/var/postgres/pg_logical/mappings
mkdir -p /usr/local/var/postgres/pg_logical/snapshots
mkdir -p /usr/local/var/postgres/pg_replslot
mkdir -p /usr/local/var/postgres/pg_serial
mkdir -p /usr/local/var/postgres/pg_snapshots
mkdir -p /usr/local/var/postgres/pg_stat
mkdir -p /usr/local/var/postgres/pg_stat_tmp
mkdir -p /usr/local/var/postgres/pg_tblspc
mkdir -p /usr/local/var/postgres/pg_twophase

或者,更简洁(感谢 Nate):

Or, more concisely (thanks to Nate):

mkdir -p /usr/local/var/postgres/{{pg_commit_ts,pg_dynshmem,pg_replslot,pg_serial,pg_snapshots,pg_stat,pg_stat_tmp,pg_tblspc,pg_twophase},pg_logical/{mappings,snapshots}}

重新运行 pg_ctl start -D/usr/local/var/postgres 现在可以正常启动服务器,至少对我来说,没有任何数据丢失.

Rerunning pg_ctl start -D /usr/local/var/postgres now starts the server normally and, at least for me, without any data loss.

更新

在我的系统上,即使 Postgres 正在运行,其中一些目录也是空的.也许,作为一些清洁"的一部分操作,优胜美地删除任何空目录?无论如何,我继续在每个目录中创建了一个.keep"文件,以防止将来被删除.

On my system, some of those directories are empty even when Postgres is running. Maybe, as part of some "cleaning" operation, Yosemite removes any empty directories? In any case, I went ahead and created a '.keep' file in each directory to prevent future deletion.

touch /usr/local/var/postgres/{{pg_commit_ts,pg_dynshmem,pg_replslot,pg_serial,pg_snapshots,pg_stat,pg_stat_tmp,pg_tblspc,pg_twophase},pg_logical/{mappings,snapshots}}/.keep

注意:在这些目录中创建 .keep 文件会在您的日志文件中产生一些干扰,但似乎不会对其他任何内容产生负面影响.

Note: Creating the .keep file in those directories will create some noise in your logfile, but doesn't appear to negatively affect anything else.

这篇关于安装最新版本的 OS X(Yosemite 或 El Capitan)后缺少“pg_tblspc"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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