gpt4 book ai didi

django - Homebrew 程序的data_directory在哪里?还是对于postgresql或如何解决错误,““global/pg_filenode.map”:没有这样的文件或目录”?

转载 作者:行者123 更新时间:2023-11-29 11:32:50 36 4
gpt4 key购买 nike

通过自制程序安装后,我在使用postgresql时遇到了困难。我在MacOSX10.9.5上(今天刚刚更新并重新启动)。
注意:我并没有故意更改默认postgresql安装的任何内容
问题
我无法卸载postgresql
我无法登录查看表/启动postgres的“命令行”
createdb返回一个关于pg_filenode.map“no such file or directory”的错误
initdb返回错误,不知道数据目录在哪里(我不知道)
任何一个都会成功
登录到PSQL(这样我就可以创建一个数据库或表,就像我可以在MySQL中做的那样,浏览现有表)
完全卸载postgres(以便我可以使用postgresql.app重新尝试)
我花了将近10个小时来解决这个问题,但还是没有成功。
我已经看了很多答案(包括问题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

建议使用postgres.app安装postgresql
我没有这么做,我用的是自制的,所以我试着卸载postgresql
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.

(出于绝望,我甚至试着删除它然后再去)
                moriartymacbookair13:~ macuser$ initdb /usr/local/var/postgres
The files belonging to this database system will be owned by user "macuser".
This user must also own the server process.
The database cluster will be initialized with locale "en_GB.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

initdb: directory "/usr/local/var/postgres" exists but is not empty
If you want to create a new database system, either remove or empty
the directory "/usr/local/var/postgres" or run initdb
with an argument other than "/usr/local/var/postgres".
moriartymacbookair13:~ macuser$ rm -rf /usr/local/var/postgres
moriartymacbookair13:~ macuser$ initdb /usr/local/var/postgres -E utf8
The files belonging to this database system will be owned by user "macuser".
This user must also own the server process.

The database cluster will be initialized with locale "en_GB.UTF-8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /usr/local/var/postgres ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
creating template1 database in /usr/local/var/postgres/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

postgres -D /usr/local/var/postgres
or
pg_ctl -D /usr/local/var/postgres -l logfile start


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行。。。几乎整个文件都被注释掉了)
 35 # FILE LOCATIONS
36 #----------------------------------------------------------------------------- -
37
38 # The default values of these variables are driven from the -D command-line
39 # option or PGDATA environment variable, represented here as ConfigDir.
40
41 #data_directory = 'ConfigDir' # use data in another directory
42 # (change requires restart)
43 #hba_file = 'ConfigDir/pg_hba.conf' # host-based authentication file
44 # (change requires restart)
45 #ident_file = 'ConfigDir/pg_ident.conf' # ident configuration file
46 # (change requires restart)
47
48 # If external_pid_file is not explicitly set, no extra PID file is written.
49 #external_pid_file = '' # write an extra PID file
50 # (change requires restart)

帮助:是否有人知道我应该指定'ConfigDir'作为数据目录的位置?
以防万一
这是酒窖文件夹的内容
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/

(我不明白为什么我在地窖里有一些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,所以这里是Chrome在本地运行 foreman start时从代码中给出的错误。
(注意“django应用程序”只是一个演示应用程序 https://devcenter.heroku.com/articles/getting-started-with-python#prepare-the-app
它适用于 localhost:5000主页,但是当我添加 /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

此处建议的步骤
detailed heroku docs

Remove and re-add the launch agent
Kill the processes for <postgresql version number>
Initialize the db initdb /usr/local/var/postgres
Restart my computer

如果这是相关的,请告诉我如何“删除并重新添加启动代理”?
是这个吗?(基于早期的brew info postgresql输出)
moriartymacbookair13:~ macuser$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
moriartymacbookair13:~ macuser$ killall postgresql
No matching processes belonging to you were found
moriartymacbookair13:~ macuser$ killall postgres
No matching processes belonging to you were found
moriartymacbookair13:~ macuser$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

最后
如果它能激励任何人,
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、解决 unknown user: postgres错误、设置 #data_directory = 'ConfigDir'位置或任何其他提示的建议。。。我真的很感激。今天已经整整一天没看到这个了,所以我非常感激。

最佳答案

FATAL: could not open relation mapping file "global/pg_filenode.map": No such file or directory
您安装了PostgreSQL,但在服务器运行时删除或移动了数据目录。或者你将它安装在一个可移动磁盘上,然后将其删除。或者你系统中的某个应用程序正在干扰其他应用程序如何更改文件。

  moriartymacbookair13:~ macuser$ postgres
postgres does not know where to find the server configuration file.

postgres是服务器应用程序。客户是 psql。但是,如果 global/pg_filenode.map不见了,你就不会有更多的运气了。
  moriartymacbookair13:~ macuser$ brew uninstall postgres

psql
不管怎样,我们有了它,在大输出的末尾
确认我的路径是 sudo brew uninstall postgres,所以我尝试了 /usr/local/var/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

你走错了路。注意“brew info”所说的:
    Or, if you don't want/need launchctl, you can just run:
postgres -D /usr/local/var/postgres

对于 -D用户:
moriartymacbookair13:~ macuser$ sudo -u postgres pg_ctl -D /usr/local/var/postgres -w start
sudo: unknown user: postgres

我认为有些MacOSX安装使用 postgres_postgres。我没有mac,所以我不能查。但不管怎样,在您的情况下,这并不重要,因为datadir是由您的用户拥有的,而不是 postgres_
moriartymacbookair13:~ macuser$ ls -ld /usr/local/var/postgres/
drwx------ 19 macuser admin 646B 20 Sep 19:46 /usr/local/var/postgres//

在我看来,您或系统上的某个工具损坏了PostgreSQL数据目录,使其损坏。这不应该发生,所以我会努力找出删除了什么 postgres以及如何/何时删除。
如果数据目录中没有您关心的数据,您应该删除它并重新初始化数据库。
我没有Mac,也看不到Homebrew如何配置PostgreSQL安装的启动,但听起来它可能以用户的身份运行。在这种情况下,只要:
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

最后,回复:
注意,当我尝试使用postgres.app安装程序时,它告诉我
“无法在端口5432上启动”并在安装过程中冻结
据猜测,当您尝试让来自Homebrew的 pg_filenode.map服务器已经在5432上运行,但由于数据目录损坏而无法正常运行时。
所以你真的有两件事:
重新初始化datadir以使PostgreSQL重新工作;以及
先弄清楚它是怎么损坏的

关于django - Homebrew 程序的data_directory在哪里?还是对于postgresql或如何解决错误,““global/pg_filenode.map”:没有这样的文件或目录”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25952943/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com