Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 自制软件的数据目录在哪里?或者对于postgresql,或者如何解决错误&引用;全局/pg_filenode.map";:没有这样的文件或目录;?_Django_Postgresql_Heroku_Homebrew - Fatal编程技术网

Django 自制软件的数据目录在哪里?或者对于postgresql,或者如何解决错误&引用;全局/pg_filenode.map";:没有这样的文件或目录;?

Django 自制软件的数据目录在哪里?或者对于postgresql,或者如何解决错误&引用;全局/pg_filenode.map";:没有这样的文件或目录;?,django,postgresql,heroku,homebrew,Django,Postgresql,Heroku,Homebrew,通过自制程序安装后,我在使用postgresql时遇到了困难。我使用的是Mac OS X 10.9.5(今天刚刚更新,并重新启动) 注意,我没有故意通过自制更改默认postgresql安装的任何内容 问题 我无法卸载postgresql 我无法登录查看表/启动postgres的“命令行” createdb返回关于pg_filenode.map的错误“没有这样的文件或目录” initdb返回一个错误,询问数据目录在哪里(我不知道) 任何一个都将是成功的 登录到psql(这样我可以像在mysq

通过自制程序安装后,我在使用postgresql时遇到了困难。我使用的是Mac OS X 10.9.5(今天刚刚更新,并重新启动)

注意,我没有故意通过自制更改默认postgresql安装的任何内容

问题

  • 我无法卸载postgresql
  • 我无法登录查看表/启动postgres的“命令行”
  • createdb返回关于pg_filenode.map的错误“没有这样的文件或目录”
  • initdb返回一个错误,询问数据目录在哪里(我不知道)
任何一个都将是成功的

  • 登录到psql(这样我可以像在mysql中一样创建数据库或表,浏览现有表)
  • 完全卸载postgres(这样我可以重新尝试postgresql.app)
我已经花了将近10个小时来解决这个问题,但还是没有解决

我已经看了大量的答案(包括SO问题24132418和14510237),但由于还没有信誉点,我无法包含所有链接

任何指点都将不胜感激

下面似乎很长,因为我已经粘贴了所有的日志,请让我知道,如果我错过了一些重要的信息虽然

谢谢,马克

细节

我一直在为Heroku做介绍,他们说安装postgresql是一项要求,所以我用自制软件完成了这项工作

brew install postgresql
我没有检查它,我继续构建我的应用程序,但第二天我在本地运行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
所以我想调查一下。 现在我以前从未使用过postgresql,所以我想为postgresql“进入命令行”

请注意,我是一个完全的新手,以前从未使用过postgresql

在mysql中,我知道这将是

mysql -u root -p
(然后输入密码)

我无法在postgresql中实现同样的功能

  moriartymacbookair13:~ macuser$ postgres
  postgres does not know where to find the server configuration file.
  You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
  moriartymacbookair13:~ macuser$ postgres -V
  postgres (PostgreSQL) 9.3.5
moriartymacbookair13:~ macuser$ brew uninstall postgres
Uninstalling /usr/local/Cellar/postgresql/9.3.5_1...
Error: Permission denied - /usr/local/bin/clusterdb
更多建议使用postgres.app安装postgresql 我没有这么做,我用的是自制软件,所以我尝试卸载postgresql

  moriartymacbookair13:~ macuser$ postgres
  postgres does not know where to find the server configuration file.
  You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
  moriartymacbookair13:~ macuser$ postgres -V
  postgres (PostgreSQL) 9.3.5
moriartymacbookair13:~ macuser$ brew uninstall postgres
Uninstalling /usr/local/Cellar/postgresql/9.3.5_1...
Error: Permission denied - /usr/local/bin/clusterdb
那没用,所以回到我原来的地方。为了找出要指定的路径,我运行了

brew info postgresql
如果你向下滚动到这篇文章的底部,你可以看到它告诉我这条路

moriartymacbookair13:~ macuser$ brew info postgres
postgresql: stable 9.3.5 (bottled), devel 9.4beta2
http://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.3.5_1 (2927 files, 38M) *
  Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/postgresql.rb
==> Dependencies
Required: openssl ✔, readline ✔
Recommended: ossp-uuid ✔
==> Options
--32-bit
    Build 32-bit only
--enable-dtrace
    Build with DTrace support
--no-perl
    Build without Perl support
--no-tcl
    Build without Tcl support
--with-python
    Build with python support
--without-ossp-uuid
    Build without ossp-uuid support
--devel
    install development version 9.4beta2
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
  https://github.com/Homebrew/homebrew/issues/issue/2510

To migrate existing data from a previous major version (pre-9.3) of PostgreSQL, see:
  http://www.postgresql.org/docs/9.3/static/upgrading.html

When installing the postgres gem, including ARCHFLAGS is recommended:
  ARCHFLAGS="-arch x86_64" gem install pg

To install gems without sudo, see the Homebrew wiki.

To reload postgresql after an upgrade:
    launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
    postgres -D /usr/local/var/postgres
注意:我忽略了顶部的评论:

Conflicts with: postgres-xc
    /usr/local/Cellar/postgresql/9.3.5_1 (2927 files, 38M) *
不管怎样,在大输出的末尾,它确认了我的路径是/usr/local/var/postgres,所以我尝试了-D

moriartymacbookair13:~ macuser$ postgres -D /usr/local/postgres
postgres cannot access the server configuration file "/usr/local/postgres/postgresql.conf": No such file or directory
所以这次我指定了配置文件:

moriartymacbookair13:~ macuser$ postgres --config-file=/usr/local/var/postgres/postgresql.conf 
postgres does not know where to find the database system data.
This can be specified as "data_directory" in "/usr/local/var/postgres/postgresql.conf", or by the -D invocation option, or by the PGDATA environment variable.
(出于绝望,我甚至尝试删除它,然后再继续)

所以我看了一下那个文件:

因为在conf文件本身中,没有定义数据变量

  moriartymacbookair13:~ macuser$ ls /usr/local/var/postgres/
  PG_VERSION       pg_ident.conf    pg_stat/         pg_xlog/
  base/            pg_multixact/    pg_stat_tmp/     postgresql.conf
  global/          pg_notify/       pg_subtrans/
  pg_clog/         pg_serial/       pg_tblspc/
  pg_hba.conf      pg_snapshots/    pg_twophase/
  moriartymacbookair13:~ macuser$ vim /usr/local/var/postgres/postgresql.conf 
显示值被注释掉(参见第41行…几乎整个文件都被注释掉)

帮助:有人知道我应该指定'ConfigDir'作为数据目录的位置吗

以防万一 下面是Cellar文件夹的内容

moriartymacbookair13:~ macuser$ ls /usr/local/Cellar/postgresql/9.3.5_1/
COPYRIGHT                       homebrew.mxcl.postgresql.plist
HISTORY                         include/
INSTALL_RECEIPT.json            lib/
README                          share/
bin/
(我不明白为什么我在Cell中有一些postgres文件,而在usr/local/var中有一些文件)

我还尝试了其他一些东西:

    moriartymacbookair13:~ macuser$ sudo -u postgres pg_ctl -D /usr/local/var/postgres -w start
    sudo: unknown user: postgres
这是基于其他问题

    moriartymacbookair13:~ macuser$ ls -ld /usr/local/var/postgres/
    drwx------  19 macuser  admin   646B 20 Sep 19:46 /usr/local/var/postgres//
    moriartymacbookair13:~ macuser$ chown -R postgres /usr/local/var/postgres
    chown: postgres: illegal user name
    moriartymacbookair13:~ macuser$ brew uninstall postgresql
    Uninstalling /usr/local/Cellar/postgresql/9.3.5_1...
    Error: Permission denied - /usr/local/bin/clusterdb
    moriartymacbookair13:~ macuser$ brew uninstall postgres
    Uninstalling /usr/local/Cellar/postgresql/9.3.5_1...
    Error: Permission denied - /usr/local/bin/clusterdb
    moriartymacbookair13:~ macuser$ 
正如我所说,我安装Postgresql只是为了试用heroku,所以当我在本地运行
foreman start
时,Chrome在代码中给了我一个错误。 (注意,“django应用程序”只是一个演示应用程序
https://devcenter.heroku.com/articles/getting-started-with-python#prepare-应用程序
) 它适用于
localhost:5000
home,但当我添加
/admin
(将与数据库交互的页面)时,会出现以下错误:

OperationalError at /admin/
FATAL:  could not open relation mapping file "global/pg_filenode.map": No such file or directory
Request Method: GET
Request URL:    http://localhost:5000/admin/
Django Version: 1.6.5
Exception Location: /Users/macuser/Dropbox/code/heroku/awe01/lib/python2.7/site-packages/psycopg2/__init__.py in connect, line 164
Python Executable:  /Users/macuser/Dropbox/code/heroku/awe01/bin/python
此处的完整错误回溯日志:
http://dpaste.com/3CREGVQ

注意这个答案
https://stackoverflow.com/a/5053003/870121
推荐createdb而不仅仅是initdb

上面的错误与我运行createdb时的错误相同:

moriartymacbookair13:~ macuser$ createdb /usr/local/var/postgres/
createdb: could not connect to database template1: FATAL:  could not open relation mapping file "global/pg_filenode.map": No such file or directory
此处建议的步骤 是

最后 如果它能激励任何人

moriartymacbookair13:~ macuser$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
    /usr/local/lib/libguide.dylib
    /usr/local/lib/libKLF_OGL.dylib

Warning: Some directories in your path end in a slash.
Directories in your path should not end in a slash. This can break other
doctor checks. The following directories should be edited:
    $/Users/macuser/Dropbox/code/aws/ElasticBeanstalkCommandLineTools/AWS-ElasticBeanstalk-CLI-2.6.3/AWSDevTools.sh/macosx/python2.7/    /Users/macuser/Dropbox/code/aws/ElasticBeanstalkCommandLineTools/AWS-ElasticBeanstalk-CLI-2.6.3/AWSDevTools/eb/macosx/python2.7/

Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:

    git
    git-cvsserver
    git-receive-pack
    git-shell
    git-upload-archive
    git-upload-pack

Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
    echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile
moriartymacbookair13:~ macuser$ 
今天早些时候我犯了这个错误 createdb:无法连接到数据库postgres:无法连接到服务器:没有这样的文件或目录 服务器是否在本地运行并接受 Unix域套接字上的连接“/tmp/.s.PGSQL.5432”

根据
http://www.postgresql.org/docs/9.3/interactive/tutorial-createdb.html
但这一错误现在似乎已经消失了

关于取消或重新安装postgresql、解决
未知用户:postgres
错误、设置
数据目录的位置='ConfigDir'
或任何其他提示的任何建议。。。我会非常感激的。这已经是一整天的损失了,所以我会感激一切

致命:无法打开关系映射文件“global/pg_filenode.map”:没有此类文件或目录

您安装了PostgreSQL,但在服务器运行时删除或移动了数据目录。或者将其安装在可移动磁盘上,然后将其删除。或者系统中的某些应用程序正在干扰其他应用程序如何更改文件

postgres
是服务器应用程序。客户端是
psql
。但是,如果缺少
global/pg_filenode.map
,您就不会有任何运气使用
psql

sudo-brew卸载postgres

不管怎样,我们有它,在大输出的末尾 确认我的路径是
/usr/local/var/postgres
,因此我尝试了
-D

moriartymacbookair13:~ macuser$ postgres -D /usr/local/postgres
postgres cannot access the server configuration file "/usr/local/postgres/postgresql.conf": No such file or directory
你走错路了。请注意“brew信息”所说的内容:

对于
postgres
用户:

我认为一些MacOSX安装使用
\uPostgres
postgres
。我没有mac电脑,所以无法检查。但在您的情况下,这并不重要,因为datadir归您的用户所有,而不是
postgres

在我看来,您或您系统上的某个工具已经损坏了您的PostgreSQL数据目录,使其损坏。这不应该发生,所以我会努力找到你
moriartymacbookair13:~ macuser$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: The /usr/local directory is not writable.
Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
    /usr/local/lib/libguide.dylib
    /usr/local/lib/libKLF_OGL.dylib

Warning: Some directories in your path end in a slash.
Directories in your path should not end in a slash. This can break other
doctor checks. The following directories should be edited:
    $/Users/macuser/Dropbox/code/aws/ElasticBeanstalkCommandLineTools/AWS-ElasticBeanstalk-CLI-2.6.3/AWSDevTools.sh/macosx/python2.7/    /Users/macuser/Dropbox/code/aws/ElasticBeanstalkCommandLineTools/AWS-ElasticBeanstalk-CLI-2.6.3/AWSDevTools/eb/macosx/python2.7/

Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:

    git
    git-cvsserver
    git-receive-pack
    git-shell
    git-upload-archive
    git-upload-pack

Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
    echo export PATH='/usr/local/bin:$PATH' >> ~/.bash_profile
moriartymacbookair13:~ macuser$ 
  moriartymacbookair13:~ macuser$ postgres
  postgres does not know where to find the server configuration file.
  moriartymacbookair13:~ macuser$ brew uninstall postgres
moriartymacbookair13:~ macuser$ postgres -D /usr/local/postgres
postgres cannot access the server configuration file "/usr/local/postgres/postgresql.conf": No such file or directory
    Or, if you don't want/need launchctl, you can just run:
    postgres -D /usr/local/var/postgres
moriartymacbookair13:~ macuser$ sudo -u postgres pg_ctl -D /usr/local/var/postgres -w start
sudo: unknown user: postgres
moriartymacbookair13:~ macuser$ ls -ld /usr/local/var/postgres/
drwx------  19 macuser  admin   646B 20 Sep 19:46 /usr/local/var/postgres//
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm -rf /usr/local/var/postgres
initdb -D /usr/local/var/postgres -U postgres --auth-local peer --auth-host md5 -E utf-8l
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
 # 1:
 # For postgresql postgres postgres.app:
 # Otherwise psql isn't a recognised command
 # Based on http://postgresapp.com/documentation/cli-tools.html
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.3/bin
 # 2:
 # And this from https://devcenter.heroku.com/articles/heroku-postgresql#local-setup
export PATH="/Applications/Postgres93.app/Contents/MacOS/bin:$PATH:$PATH"
 # 3:
 # And now this based on error of file not existing
 # from http://stackoverflow.com/questions/13868730/socket-file-var-pgsql-socket-s-pgsql-5432-missing-in-mountain-lion-os-x-ser -- don't think this made a difference though
export PGHOST=localhost