首页 文章

postgresql:错误安装并运行postgresql-9.5

提问于
浏览
2

我安装了两个postgresql(s),9.5应该使用端口5433,9.3.4应该使用端口5432:

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

我写了一个脚本来安装postgresql-9.5并从9.3.4迁移到9.5

Problem 0: postgresql-9.5 can not start sucessfully and why status is online

安装期间的输出:

* 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

然后我做了一些测试:

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

What do the above errors?

顺便说一下,另一个错误是:

ERROR:  role "postgres" already exists

Problem 1: Why I cannot use /usr/lib/postgresql/9.5/bin/psql to loginto the database, but I can do this by /opt/pkgs/postgresql-9.3.4/bin/psql

me@camb:/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
me@camb:/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
me@camb:/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
me@camb:/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

谢谢

4 回答

  • 0

    错误是“未定义的符号:PQsslInUse”

    我自己也遇到了这个问题 . 我发现原因是因为我从头开始将Postgres 9.5编译成一个特定的目录,然后决定我想在其他地方使用它并将安装移动到一个新目录 . 当我用 psql 恢复我的数据库时,我得到了上述错误 . 我通过删除我的安装目录,将PREFIX更改为正确的位置,重新编译并重新安装Postgres来更正了问题 . psql 在此之后工作正常 .

  • 1

    我有类似的问题,最后找到了解决方案:

    我的用户没有postgres安装的权限 .

    对我有用的是切换到postgres用户:

    sudo su - postgres
    psql
    

    然后它没有任何问题 .

  • 2

    我有同样的问题

    psql: symbol lookup error: psql: undefined symbol: PQsetErrorContextVisibility
    

    解决方案是:

    export LD_LIBRARY_PATH=$PGXZ_HOME/lib:${LD_LIBRARY_PATH}
    
  • 0

    您必须使用与psql 9.5中使用的libpq库相同的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

相关问题