2012-07-06 36 views
4

我在Mac OS X 10.6.x上安裝了postgres。 當我跑了Postgres數據庫版本:postgres數據庫和服務器的衝突版本

psql --versionpsql (PostgreSQL) 9.1.1 
contains support for command-line editing 

當我檢查了該版本的服務器:

psql -c "select version();"                  version                  
-------------------------------------------------------------------------------------------------------------------------------------------------- 
PostgreSQL 9.0.5 on x86_64-apple-darwin10.8.0, compiled by GCC i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3), 64-bit 
(1 row) 

所以,當我運行

bash-3.2$ psql 
psql (9.1.1, server 9.0.5) 
WARNING: psql version 9.1, server version 9.0. 
     Some psql features might not work. 

我不知道那些功能是。這些版本是衝突的。我是新來的使用postgres,所以我不知道如何升級只是postgres服務器。我試圖在網上搜索一些東西,但沒有找到太多的幫助。我不想卸載並重新安裝postgres。無論如何,我可以一起使用它們,而不會發生衝突嗎?或者只是將服務器升級到與數據庫相同的版本?

編輯:

which psql 
/opt/local/lib/postgresql91/bin//psql 

which postgres 
/opt/local/lib/postgresql91/bin//postgres 

ps -eaf|grep postgres 
    0 60  1 0 0:00.07 ??   0:00.09 /opt/local/bin/daemondo --label=postgresql90-server --start-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql90-server/postgresql90-server.wrapper restart ; --pid=none 
    103 3971 3967 0 0:00.69 ??   0:01.17 postgres: writer process  
    103 3972 3967 0 0:00.67 ??   0:00.88 postgres: wal writer process  
    103 3973 3967 0 0:00.18 ??   0:00.23 postgres: autovacuum launcher process  
    103 3974 3967 0 0:00.19 ??   0:00.21 postgres: stats collector process  
    0 3616 2726 0 0:00.04 ttys000 0:00.06 su postgres 
    103 3967 3619 0 0:00.23 ttys000 0:00.34 postgres -D /usr/local/pgsql/data 
    0 4559 4055 0 0:00.03 ttys001 0:00.05 su postgres 
    103 5922 4560 0 0:00.01 ttys001 0:00.01 grep postgres 

謝謝。

+0

的KyngChaos的MAC構建?你有沒有修改任何配置文件? '哪個psql'和'哪個postgres'報告什麼? ps -eaf | grep postgres報告了什麼? – vyegorov 2012-07-06 19:57:48

+0

我在我的問題 – Maddy 2012-07-06 20:02:03

回答

4

我想你已經安裝過PostgreSQL了。請確認這一點,'在這種情況下,你將不得不升級你的數據庫。 這是重要的一步,不可能只是升級軟件。

請嘗試停止當前正在運行的服務器。首先,檢查當前正在運行的PostgreSQL來源:

sudo launchctl list | grep -Ei "macports|postgres" 

然後執行:

sudo launchctl unload -w <OldPostgreSQL.plist> 

,並開始像這樣的新服務器:

sudo launchctl load -w <NewPostgreSQL.plist> 

我希望新的plist是
/Library/LaunchDaemons/org.macports.postgresql91-server.plist


如果您需要升級:

  1. 確保你的數據庫的完全轉儲先用版本的pg_dump
  2. 執行版本的initdb在新的PGDATA文件夾中。
  3. 如上所述啓動新的服務器。
  4. 上傳完整轉儲。

這是small description我碰到過這個問題。這是official PostgreSQL documentation on upgrading between major releases

+1

請注意引用文檔底部的小部分,用於升級非pg_dump方法。通常可以使用pg_upgrade轉換幾分鐘的停機時間,即使對於數TB的數據也是如此。如果您需要在秒內測量停機時間,請查看slony複製方法。請注意,這些方法中的任何一種都需要同時提供兩種版本的軟件。 – kgrittn 2012-07-07 14:30:13

1

如果您在新安裝之前已經有PostgreSQL的版本,則可能會發生這種情況。

既然你有兩個版本的PostgreSQL,你需要兩個版本的psql。基本上,現在當你鍵入psql時,你的系統可能不確定你要連接哪個版本的數據庫。

刪除以前的版本。或者安裝新的psql以及新版本的服務器。

+0

毫米中加入這是我想避免的。但我想有沒有簡單的方法來更新服務器。謝謝。 – Maddy 2012-07-06 20:27:40

1

礦是一個自制安裝和這裏的我做了什麼(給我帶來了一個運作的psql沒有版本的問題) - 我想你如何安裝PostgreSQL的安裝PostgreSQL的

step 0 (already did): 
brew uninstall postgresql 

step1 
which psql 
=> "locationpath" (in my case, /usr/bin/psql) 
sudo rm "locationpath" 

step2 
#inside ~/.bash_profile 
export PATH=/usr/local/pgsql-9.3/bin:$PATH 

step3 
psql 
#works