我在OS X 10.6.8下启动所有(4个测试中的4个)rails3应用程序时得到这些错误
could not connect to server: No such file or directory (PG::Error)
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
或
could not connect to server: No such file or directory (PG::ConnectionBad)
之后是对端口5432的相同请求。
我在本地安装了9.1.3,9.2.4和9.3.4。9.3.4更新被安装,因为试图安装postGIS.
brew info postgresql
postgresql: stable 9.3.4, devel 9.4beta1
http://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.1.3 (2746 files, 36M)
/usr/local/Cellar/postgresql/9.2.4 (2831 files, 39M)
Built from source
/usr/local/Cellar/postgresql/9.3.4 (2921 files, 40M) *
Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/postgresql.rb
==> Dependencies
Required: openssl ✔, readline ✔
Recommended: ossp-uuid ✔
第一个错误是针对具有gem 'pg', '0.15.1'
的应用程序,而第二个错误设置为0.17.1
。这是通过自制更新的结果。第一个错误没有正确编译到新的9.3.4版本,用0.17.1重新编译会产生第二个ConnectionBad错误。
我的/tmp/目录有一个.s.PGSQL.5433
和姊妹锁文件,表明它想在5433端口上运行。
先前正在运行升级的应用程序。从那以后,这台机器出现了一些电源故障。
ps auxw | grep post
postgres 287 0.0 0.1 2465608 5204 ?? SNs 11:14AM 0:00.31 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdworker MDSImporterWorker com.apple.Spotlight.ImporterWorker.502
postgres 141 0.0 0.0 2446204 388 ?? Ss 11:13AM 0:00.36 postgres: stats collector process
postgres 139 0.0 0.0 2473664 1700 ?? Ss 11:13AM 0:00.41 postgres: autovacuum launcher process
postgres 137 0.0 0.0 2473532 556 ?? Ss 11:13AM 0:01.58 postgres: wal writer process
postgres 135 0.0 0.0 2473532 736 ?? Ss 11:13AM 0:02.13 postgres: writer process
postgres 130 0.0 0.0 2446204 328 ?? Ss 11:13AM 0:00.46 postgres: logger process
postgres 58 0.0 0.2 2473532 6696 ?? Ss 11:12AM 0:00.44 /Library/PostgreSQL/9.1/bin/postmaster -D/Library/PostgreSQL/9.1/data
jerdvo 5966 0.0 0.0 2435120 536 s001 S+ 5:32PM 0:00.00 grep post
所以有一个进程运行postgre,基于原来的9.1版本。我相信这是因为我有一个(不开明的?)的想法,安装pgAdmin3驻留在该目录。
现在我觉得有太多的兔子要追。据我所知,应该设置系统PATH,以便psql和它的libpq对齐。我的主要目标是通过控制台访问所有应用程序,从而使PG在5432上运行。
卸载pgadmin3是一个好主意吗?如果有,最好的路线是什么?
最后,我还有另外一个安装PostGIS的目的。安装postgre应用程序会使问题进一步恶化吗?
更新
ps auxww | grep ^postgres
postgres 182 0.0 0.0 2446204 240 ?? Ss 9:19PM 0:00.61 postgres: stats collector process
postgres 181 0.0 0.0 2473664 1332 ?? Ss 9:19PM 0:00.67 postgres: autovacuum launcher process
postgres 180 0.0 0.0 2473532 280 ?? Ss 9:19PM 0:02.69 postgres: wal writer process
postgres 179 0.0 0.0 2473532 484 ?? Ss 9:19PM 0:03.63 postgres: writer process
postgres 177 0.0 0.0 2446204 248 ?? Ss 9:19PM 0:00.77 postgres: logger process
postgres 57 0.0 0.1 2473532 5356 ?? Ss 9:19PM 0:00.46 /Library/PostgreSQL/9.1/bin/postmaster -D/Library/PostgreSQL/9.1/data
postgres 2802 0.0 0.1 2465608 5004 ?? SNs 10:58AM 0:00.13 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mdworker MDSImporterWorker com.apple.Spotlight.ImporterWorker.502
更新和分辨率
对于那些偶然发现这些情况的人……
感谢Craig和他的指点。假设机器故障和与版本冲突(OS X版本,自制版本,pgadmin3应用程序…)我决定把它擦干净。(备用(s)要求)。pgadmin有自己的卸载程序,它位于/Library/目录中,希望也能解决OS X的混乱。
brew remove postgresql
,对于以前的版本,brew remove——force postgresql
brew install postgresql
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
pg_ctl -D /usr/local/var/postgres -l logfile start
和
initdb
将postgresql.conf
中的port
指令改为5432
。