如何将 PostgreSQL 从 8.4 版升级到 9.4 版?

Ale*_*lig 18 postgresql upgrade postgresql-8.4 centos postgresql-9.4

我想将我的 PostgreSQL 从版本8.4升级到9.4

文件是不是很清楚,我。

  1. 如果进行升级,我会丢失旧数据库吗?
  2. 如果升级后丢失旧数据库,如何备份它们?
  3. 如何升级我的 psql?

我的 PostgreSQL 在CentOS 6.6服务器上运行。

Ale*_*lig 26

这就是我解决我的问题的方法。

在 Centos 中将 Postgresql 8.4 升级到 9.4

 1. Yum Install PG9.4
 2. wget http://yum.postgresql.org/9.4/redhat/rhel-6-x86_64/pgdg-redhat94-9.4-1.noarch.rpm
 3. yum install pgdg-redhat94-9.4-1.noarch.rpm
 4. yum install postgresql94-server
 5. service postgresql-9.4 initdb
 6. chkconfig postgresql-9.4 on
Run Code Online (Sandbox Code Playgroud)

资料备份

 7. su - postgres

 8. pg_dumpall > dump.sql
Run Code Online (Sandbox Code Playgroud)

恢复数据

 9. service postgresql stop

 10. service postgresql-9.4 start

 11. su - postgres

 12. psql < dump.sql
Run Code Online (Sandbox Code Playgroud)

配置网络访问

vi /var/lib/pgsql/9.4/data/postgresql.conf

 1. listen_addresses = '*'
 2. port = 5432
Run Code Online (Sandbox Code Playgroud)

/var/lib/pgsql/9.4/data/pg_hba.conf

# "local" is for Unix domain socket connections only
local   all         all                               ident
# IPv4 local connections:
host    all         all         127.0.0.1/32          ident
host    all         all         130.51.79.0/24        md5
host    all         all         10.210.29.0/24        md5
# IPv6 local connections:
host    all         all         ::1/128               ident
Run Code Online (Sandbox Code Playgroud)

删除 PG8.4

 1. yum remove postgresql
 2. ln -s /usr/pgsql-9.4/bin/psql /usr/local/bin/psql
Run Code Online (Sandbox Code Playgroud)

  • 我不确定你为什么拒绝我的编辑,因为“损害可读性”。它实际上使命令更容易复制, (3认同)