2016-01-19 80 views
2

我安裝了兩個PostgreSQL的(一個或多個),9.5應選用5433,9.3.4應使用端口5432:PostgreSQL的:錯誤安裝並運行PostgreSQL-9.5

[email protected]:/usr/lib/postgresql/9.5/bin$ ls -al psql 
-rwxr-xr-x 1 root root 564464 Jan 7 14:54 psql 
[email protected]:/opt/pkgs/postgresql-9.3.4/bin$ ls -al psql 
-rwxr-xr-x 1 root root 405960 Aug 5 18:52 psql 
[email protected]:/opt/pkgs/postgresql-9.3.4/bin$ cat /etc/group 
postgres:x:200: 
[email protected]:/opt/pkgs/postgresql-9.3.4/bin$ groups postgres 
postgres : postgres ssl-cert 

我寫了一個腳本來安裝PostgreSQL-9.5從9.3.4遷移到9.5

問題0:在PostgreSQL-9.5能無法成功啓動,以及爲什麼狀態爲在線

輸出在安裝過程中:

* Starting PostgreSQL 9.5 database server 
* The PostgreSQL server failed to start. Please check the log output: 
2016-01-19 19:41:49 UTC [16523-1] LOG: database system was shut down at 2016-01-19 19:41:48 UTC 
2016-01-19 19:41:49 UTC [16523-2] LOG: MultiXact member wraparound protections are now enabled 
2016-01-19 19:41:49 UTC [16522-1] LOG: database system is ready to accept connections 
2016-01-19 19:41:49 UTC [16527-1] LOG: autovacuum launcher started 
2016-01-19 19:41:49 UTC [16529-1] [unknown]@[unknown] LOG: incomplete startup packet 
    ...fail! 
invoke-rc.d: initscript postgresql, action "start" failed. 
dpkg: error processing postgresql-9.5 (--configure): 
subprocess installed post-installation script returned error exit status 1 
dpkg: dependency problems prevent configuration of postgresql: 
postgresql depends on postgresql-9.5; however: 
    Package postgresql-9.5 is not configured yet. 
dpkg: error processing postgresql (--configure): 
dependency problems - leaving unconfigured 
Processing triggers for libc-bin ... 
No apport report written because the error message indicates its a followup error from a previous failure. 
ldconfig deferred processing now taking place 
Errors were encountered while processing: 
postgresql-9.5 
postgresql 
E: Sub-process /usr/bin/dpkg returned an error code (1) 
Error while installing Postgresql-9.5:1 

然後我做了一些測試:

[email protected]:/usr/lib/postgresql/9.5/bin$ sudo service postgresql start 
* Starting PostgreSQL 9.5 database server                  [ OK ] 
[email protected]:/usr/lib/postgresql/9.5/bin$ sudo service postgresql status 
9.5/main (port 5433): online 

什麼做上述錯誤?

順便說一句,另一個錯誤是:

ERROR: role "postgres" already exists 

問題1:爲什麼我不能用/usr/lib/postgresql/9.5/bin/psql到loginto數據庫中,但我能做到這一點通過/opt/pkgs/postgresql-9.3.4/bin/psql

[email protected]:/usr/lib/postgresql/9.5/bin$ sudo -u postgres /opt/pkgs/postgresql-9.3.4/bin/psql -p 5433 reporting_central postgres 
psql (9.3.4, server 9.5.0) 
WARNING: psql major version 9.3, server major version 9.5. 
     Some psql features might not work. 
Type "help" for help. 

reporting_central=# \q 
[email protected]:/usr/lib/postgresql/9.5/bin$ sudo -u postgres /opt/pkgs/postgresql-9.3.4/bin/psql -p 5432 reporting_central postgres 
psql (9.3.4) 
Type "help" for help. 

reporting_central=# \q 
[email protected]:/usr/lib/postgresql/9.5/bin$ sudo -u postgres /usr/lib/postgresql/9.5/bin/psql -p 5433 reporting_central postgres 
/usr/lib/postgresql/9.5/bin/psql: symbol lookup error: /usr/lib/postgresql/9.5/bin/psql: undefined symbol: PQsslInUse 
[email protected]:/usr/lib/postgresql/9.5/bin$ sudo -u postgres /usr/lib/postgresql/9.5/bin/psql -p 5432 reporting_central postgres 
/usr/lib/postgresql/9.5/bin/psql: symbol lookup error: /usr/lib/postgresql/9.5/bin/psql: undefined symbol: PQsslInUse 

錯誤是 「未定義的符號:PQsslInUse」。這是什麼意思?爲什麼我不能使用/usr/lib/postgresql/9.5/bin/psql登錄數據庫,但我可以通過/opt/pkgs/postgresql-9.3.4/bin/psql執行此操作?

感謝

順便說一句,我運行下面做遷移:

sudo -u postgres /opt/pkgs/postgresql-9.3.4/bin/pg_dumpall -p 5432 | sudo -u postgres /opt/pkgs/postgresql-9.3.4/bin/psql -p 5433 

感謝

+0

這是一個動態庫問題。兩個安裝(新的)之一不能找到正確的庫。你可以在周圍的shell中明確地設置LD_LIBRARY_PATH,(後來用正確的search_paths集運行ldconfig)BTW:'pg_upgrade'自動處理這一切。 – joop

+0

可能就像卸載以前版本的Postgres一樣簡單 – 125

回答

2

的錯誤是 「未定義的符號:PQsslInUse」

我自己就遇到了這個問題。我發現原因是我將Postgres 9.5從頭開始編譯到一個特定的目錄中,然後決定在其他地方需要它並將安裝移到新目錄。當我用psql恢復我的數據庫時,出現了上述錯誤。我通過刪除我的安裝目錄,更改PREFIX到正確的位置,重新編譯並重新安裝Postgres來糾正了這個問題。此後,psql正常工作。

1

您必須使用與psql 9.5中使用的庫相同的libpq庫。 你應該做到以下幾點:

export LD_LIBRARY_PATH=/usr/lib/postgresql/9.5/lib:$LD_LIBRARY_PATH 
sudo /sbin/ldconfig /usr/lib/postgresql/9.5/lib 

你亂用不同版本的PostgreSQL。 開始/使用9。5,您必須使用相應的二進制文件:在initdb,pg_ctl和psql(例如):

mkdir /usr/lib/postgresql/9.5/data 
/usr/lib/postgresql/9.5/bin/initdb -D ../data/ 
/usr/lib/postgresql/9.5/bin/pg_ctl -D ../data/ -l logfile start 
/usr/lib/postgresql/9.5/bin/psql -p 5432 -d template1 

更多信息:https://www.postgresql.org/docs/devel/static/install-post.html 和PQsslInUse問題:http://postgresql.nabble.com/psql-error-on-postgresql-9-0-psql-symbol-lookup-error-psql-undefined-symbol-PQconnectdbParams-td5104930.html

0

我也有類似的問題,終於找到了解決辦法:

我的用戶沒有postgres安裝權限。

什麼工作對我來說是切換到postgres用戶:

sudo su - postgres 
psql 

,然後它的工作沒有問題。