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

查看:95
本文介绍了安装最新版本的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(例如优胜美地或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 /usr/local/var/postgres/pg_tblspc
mkdir /usr/local/var/postgres/pg_twophase
mkdir /usr/local/var/postgres/pg_stat
mkdir /usr/local/var/postgres/pg_stat_tmp
mkdir /usr/local/var/postgres/pg_replslot
mkdir /usr/local/var/postgres/pg_snapshots

或更简洁地说(感谢 Nate ):

Or, more concisely (thanks to Nate):

mkdir /usr/local/var/postgres/{pg_tblspc,pg_twophase,pg_stat,pg_stat_tmp,pg_replslot,pg_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_tblspc,pg_twophase,pg_stat,pg_stat_tmp,pg_replslot,pg_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天全站免登陆