我在OS X中使用自制程序中的postgres,但是当我重新启动系统时,有时postgres在重新启动后没有启动,所以我手动尝试启动它postgres -D /usr/local/var/postgres,但随后发生了以下消息的错误:FATAL: could not open directory "pg_tblspc": No such file or directory.
它最后一次发生时,我无法将其恢复到原始状态,所以我决定卸载整个postgres系统,然后重新安装它并创建用户,表格,数据集等等......真是太恶心了,但是它经常发生在我的系统上,比如几个月就会发生一次.
那为什么它pg_tblspc经常丢失文件?我有什么办法可以避免丢失文件吗?
我没有将我的自制软件和postgres升级到最新版本(即我一直在使用相同的版本).另外,我在postgres数据库上做的所有事情都是删除表并每天填充新数据.我没有更改用户,密码等...
编辑(mbannert):我觉得有必要添加这个,因为这个问题对谷歌来说是最受欢迎的,而且很多症状都不同.Homebrewers可能会遇到此错误消息:
No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
所以,如果你刚刚在优胜美地升级之后经历过这个,那么现在你已经开始阅读这个帖子了.
重启我的Mac后,我遇到了可怕的Postgres错误:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
发生这种情况的原因是因为我的macbook完全因为一个无关的问题而冻结,我不得不使用电源按钮进行硬重启.重新启动后,由于此错误,我无法启动Postgres.
我设法让我的本地开发环境变得笨拙.
我所有的本地Rails应用程序现在都给出错误:
PGError
could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
我不知道是什么造成的.
在搜索解决方案时,我更新了所有捆绑的宝石,更新的系统宝石,更新的MacPorts.没有快乐.
其他人在从OSX Leopard升级到Lion时报告了这个问题,因为混淆应该使用哪个版本的Postgres(即OSX版本或MacPorts版本).我已经在Lion运行了几个月,所以现在这应该发生似乎很奇怪.
如果不先了解问题是什么,我就不愿意过多地捣乱.如何有条不紊地调试?
如何确定我的系统中有多少版本的PostgreSQL,正在访问哪一个版本以及它所在的位置?如果使用错误的PostgreSQL,我该如何解决这个问题?
抱歉没有问题.我还在学习它是如何工作的!谢谢你的任何指示.
编辑
一些更新基于以下建议和评论.
我试图运行pg_lsclusters哪个返回command not found错误.
然后我尝试本地化我的pg_hba.conf文件并找到这三个示例文件:
/opt/local/share/postgresql84/pg_hba.conf.sample
/opt/local/var/macports/software/postgresql84/8.4.7_0/opt/local/share/postgresql84/pg_hba.conf.sample
/usr/share/postgresql/pg_hba.conf.sample
Run Code Online (Sandbox Code Playgroud)
所以我假设安装了3个版本的PSQL?Macports,OSX默认和???.
然后我搜索了ps -ef | grep postgres返回的launchctl启动脚本
0 56 1 0 11:41AM ?? 0:00.02 /opt/local/bin/daemondo --label=postgresql84-server --start-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper restart ; --pid=none
500 372 1 0 11:42AM ?? 0:00.17 …Run Code Online (Sandbox Code Playgroud) 最近升级到OSX Mavericks已经破坏了我的Rails应用程序的数据库连接.
当我尝试从数据库中提取时,服务器返回以下错误:
PG::ConnectionBad (could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused
Is the server running on host "localhost" (fe80::1) and accepting
TCP/IP connections on port 5432?
Run Code Online (Sandbox Code Playgroud)
当psql我试着跑步时,我得到:
psql: could not connect to server: No …Run Code Online (Sandbox Code Playgroud) 通过homebrew安装后我遇到了postgresql的困难.我在Mac OS X 10.9.5上(今天刚刚更新并重启).
注意我没有故意通过自制软件从默认的postgresql安装中更改任何内容
问题
任何这些都是成功的
我花了近10个小时对此进行故障排除,并且做得很短.
我已经看了很多答案(包括SO问题24132418和14510237)虽然由于没有声望点我不能包含所有链接
任何指针都会非常感激!
下面似乎很长,因为我已经粘贴了所有日志,如果我错过了一些重要信息,请告诉我
谢谢,-Mark
细节
我一直在研究Heroku的介绍,他们说安装postgresql是一个要求,所以我用自制程序做了
brew install postgresql
Run Code Online (Sandbox Code Playgroud)
我没有检查它,我继续构建我的应用程序,但第二天我在本地运行webapp并得到错误,
Request URL: http://localhost:5000/admin/
Django Version: 1.6.5
Exception Type: OperationalError
Exception Value:
FATAL: could not open relation mapping file "global/pg_filenode.map": No such file or directory
Exception Location: /Users/macuser/Dropbox/code/heroku/awe01/lib/python2.7/site-packages/psycopg2/__init__.py in connect, line 164
Run Code Online (Sandbox Code Playgroud)
所以我想调查一下.现在我以前从未使用过postgresql,所以我想为postgresql"到达命令行"
请注意,我是一个完整的新手,之前从未使用过postgresql.
在mysql中,我知道这将是
mysql -u root -p
Run Code Online (Sandbox Code Playgroud)
(然后输入密码)
我无法在postgresql中做相同的操作
moriartymacbookair13:~ macuser$ postgres
postgres does not know where to find the server configuration file.
You …Run Code Online (Sandbox Code Playgroud)