0

試圖在OSX Mountain Lion上設置Postgres/PostGIS以與Django一起使用。然而,有些事情是錯誤的,我不知道如何解決它。Postgres數據庫本地安裝/運行

$ createdb geo 
createdb: could not connect to database postgres: could not connect to server: No such file or directory 
    Is the server running locally and accepting 
    connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"? 

$ postgres -D /usr/local/var/postgres 
FATAL: lock file "postmaster.pid" already exists 
HINT: Is another postmaster (PID 221) running in data directory "/usr/local/var/postgres"? 

$ pg_ctl -D /usr/local/var/postgres -l logfile start 
pg_ctl: another server might be running; trying to start server anyway 
server starting 

然後,我發現this gist說,如何解決它在獅子。然而,它並沒有爲我工作:

$ kill -9 221 
$ pg_ctl -D /usr/local/var/postgres stop 
waiting for server to shut down.... done 
server stopped 

$ pg_ctl -D /usr/local/var/postgres start 
pg_ctl: another server might be running; trying to start server anyway 
server starting 
FATAL: lock file "postmaster.pid" already exists 
HINT: Is another postmaster (PID 1436) running in data directory "/usr/local/var/postgres"? 

的另一種嘗試:

$ cd /usr/local/var/postgres 
$ mv postmaster.pid postmaster.backup 
$ pg_ctl -D /usr/local/var/postgres start 
server starting 

$ LOG: could not bind IPv6 socket: Address already in use 
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 
LOG: could not bind IPv4 socket: Address already in use 
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 
LOG: could not bind IPv6 socket: Address already in use 
HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. 
WARNING: could not create listen socket for "localhost" 
FATAL: could not create any TCP/IP sockets 

有沒有人成功地做到了這一點與美洲獅?如果是這樣,我錯過了什麼?感謝您對此問題的幫助!

回答

1

此消息:

CREATEDB:無法連接到數據庫的Postgres:無法連接到 服務器:沒有這樣的文件或目錄 是在本地運行和驗收Unix域套接字 連接服務器「/ VAR/pgsql_socket/.s.PGSQL.5432" ?

表明你的PostgreSQL服務器不使用/var/pgsql_socket作爲其Unix域套接字目錄,這是在服務器和客戶端之間的會合點。這很常見,因爲只有Apple發佈的PostgreSQL和OSX服務器使用該路徑。順便說一下,這就是爲什麼Apple提供的createdb命令會嘗試連接到Apple配置的服務器。

從這一點出發,有很多不同的解決方案可以解決這個問題,但更明顯的是使用PostgreSQL安裝附帶的createdb命令,而不是系統中預安裝的命令。

如果你需要進一步的幫助,你應該指定你安裝PostgreSQL的方式,因爲有很多不同的包提供它,並且它們都使用不同的路徑來避免相互之間的踐踏。

更新家釀

如果使用BREW,我建議應用在superuser.com答案: How should I set the PATH variable on my Mac so the Hombrew-installed tools are found?

想必你指的是Postgres的+ PostGIS的教程的作者已經改變它很早以前就忘記在他的文本中提及它。

完成後,命令which createdb應返回/usr/local/bin/psql,這是自制軟件版本,而不是原始版本/usr/bin/psql,它是Apple版本。

+0

感謝您的想法@Daniel。我使用自制軟件安裝了PostGRE,並按照[說明](http://pageworthy.com/blog/postgis-on-mountain-lion/)進行操作。你對如何解決這個問題有任何想法,以便我可以在django項目中使用我的PostGREs數據庫?感謝您的想法! –

+0

@NickB:查看更新 –

+0

謝謝@Daniel。我跟着從鏈接後的指令,並把'USR /本地/ bin'以上'USR/bin',但是當我嘗試'這createdb'它輸出'在/ usr/bin中/ createdb',你上面列出的不是什麼。我是否錯過了正確鏈接路徑的內容?感謝您的想法! –

相關問題