如何选择 - Ubuntu桌面上的多个版本的PostgreSql



我安装了 9.5 版。 要从 Heroku 创建本地备份,我需要版本 9.6.1,因为这是 Heroku 上的版本 - 否则pg__dump失败并显示错误。

下面的 Ubuntu 控制台转储 -

(py27infoBOT) dhankar@dhankar-VPCEB44EN:~$ psql --version
psql (PostgreSQL) 9.6.2
(py27infoBOT) dhankar@dhankar-VPCEB44EN:~$ 
(py27infoBOT) dhankar@dhankar-VPCEB44EN:~$ pg_config --version
PostgreSQL 9.6.2
(py27infoBOT) dhankar@dhankar-VPCEB44EN:~$ 
(py27infoBOT) dhankar@dhankar-VPCEB44EN:~$ sudo su - postgres
postgres@dhankar-VPCEB44EN:~$ 
postgres@dhankar-VPCEB44EN:~$ psql -c 'SELECT version();'
                                                     version                                                     
-----------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.5.6 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609, 64-bit
(1 row)
postgres@dhankar-VPCEB44EN:~$ 
postgres@dhankar-VPCEB44EN:~$ 

更新 - 正如建议的那样 -

~$ locate pg_dump
/etc/alternatives/pg_dump.1.gz
/etc/alternatives/pg_dumpall.1.gz
/usr/bin/pg_dump
/usr/bin/pg_dumpall
/usr/lib/postgresql/9.5/bin/pg_dump
/usr/lib/postgresql/9.5/bin/pg_dumpall
/usr/share/man/man1/pg_dump.1.gz
/usr/share/man/man1/pg_dumpall.1.gz
/usr/share/postgresql/9.5/man/man1/pg_dump.1.gz
/usr/share/postgresql/9.5/man/man1/pg_dumpall.1.gz

进一步更新,使用pg_lsclusters:~

(py27infoBOT) dhankar@dhankar-VPCEB44EN:~$ 
(py27infoBOT) dhankar@dhankar-VPCEB44EN:~$ pg_lsclusters
Ver Cluster Port Status Owner    Data directory               Log file
9.5 main    5432 online postgres /var/lib/postgresql/9.5/main /var/log       /postgresql/postgresql-9.5-main.log
9.6 main    5433 online postgres /var/lib/postgresql/9.6/main /var/log    /postgresql/postgresql-9.6-main.log

(py27infoBOT( dhankar@dhankar-VPCEB44EN:~$

似乎我应该记录对我有用的解决方案 - 我编辑了 9.6.2 的 .conf 文件以侦听端口 5432 -

"config_file=/etc/postgresql/9.6/main/postgresql.conf"

现状如下 -

Ver Cluster Port Status Owner    Data directory               Log file
9.5 main    5432 down   postgres /var/lib/postgresql/9.5/main /var/log/postgresql/postgresql-9.5-main.log
9.6 main    5432 online postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log

进一步更新 :~问题未解决 - 现在参考用户这个非常有教育意义的答案 - 欧文·布兰兹泰特,https://dba.stackexchange.com/questions/21006/how-to-run-specific-version-8-4-9-1-of-postgresql-pg-command-e-g-pg-dump/21007#21007 。进一步的问题 - 我如何使用$ pg_dump --cluster 9.6/main,以及 Heroku CLI 命令,即:- heroku pg:pull DATABASE_URL localDB_infobot --app infobot-co-in

独立 - 在本地控制台$ pg_dump --cluster 9.6/main导致 - another ERROR

截至目前 - 作为临时解决方案,诉诸数据库备份,下载和本地还原 -

heroku pg:backups:capture heroku pg:backups:download pg_restore --verbose --clean --no-acl --no-owner -h localhost -U user_name -d database_name latest.dump

最新更新