Home  >  Article  >  Database  >  Postgres 9.2.4的升级方案与步骤

Postgres 9.2.4的升级方案与步骤

WBOY
WBOYOriginal
2016-06-07 17:28:001242browse

社区最近推出了Postgres 9.2.4版本,旨在打一个安全补丁,需要做一个升级,升级的步骤文档上也写得较为详细(Part 17),一般有pg_

社区最近推出了Postgres 9.2.4版本,旨在打一个安全补丁,需要做一个升级,升级的步骤文档上也写得较为详细(Part 17),一般有pg_upgrade和dump/restore两种方式,对9.2.0及以上版本采用直接编译安装的方式即可,,9.2.0以下版本还需要dump/restore方式,中间会涉及停机操作,做好业务沟通工作。本次升级,数据量较大的版本是9.2.0,其他小版本的数据量相对不大,故采用后一种方式升级。

步骤 :

1.备份
pg_dump -h 192.168.2.150 -p 5432 -U postgres -b -Fp  db_  -f db.bak
安全起见,备份出来的文件检查一下是否正常,能否正确导入,最好记一下用户名及密码等

2.关闭服务
pg_stop
ps -ef|grep postgres 检查一下

3.编译postgresql_9.2.4,原先是9.1.3
[postgres@ ~] $tar -zxvf postgresql_9.2.4.tar.gz
[postgres@ ~] cd postgresql_9.2.4
[postgres@ postgresql_9.2.4]./configure --prefix=/home/postgres --with-pgport=5432 --with-segsize=8 --with-wal-segsize=64 --with-wal-blocksize=64 --with-perl --with-python --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --enable-thread-safety
[postgres@ postgresql_9.2.4]gmake world
[postgres@ postgresql_9.2.4]gmake install-world
如果顺利的话,这个时候可以看一下BIN是否已经换成9.2.4
[postgres@ postgresql_9.2.4]$ psql -V
psql (PostgreSQL) 9.2.4
[postgres@ postgresql_9.2.4]$
说明BIN文件等已经OK
如果原始版本是9.2.0及以上,可忽略以下步骤,直接启动postgres,如果是9.2.0以下版本,直接启动会报错,则继续,类似initdb与configure版本不一致的问题

4.修改数据文件
[postgres@ ~]mv /database/pgdata /database/pgdata.old
[postgres@ ~]mkdir /database/pgdata

5.初始化DB
[postgres@ ~]$initdb -D /database/pgdata -E UTF8 --locale=C -U postgres -W

6.拷贝老的postgresql.conf与pg_hba.conf文件到新的$PGDATA下
[postgres@ ~]$cp /database/pgdata.old/postgresql.conf /database/pgdata/postgresql.conf
[postgres@ ~]$cp /database/pgdata.old/hba.conf /database/pgdata/hba.conf

7.启动数据库
pg_start
--如果是单个库导出恢复则建一下DB和相关的用户,省得导入报错

8.恢复数据
[postgres@ ~]$psql -d db_ -f db.bak

9.检查
检查数据、应用及日志是否有异常,还有一些容易遗漏的参数如timezone等,这个可以通过数据库里select now()与系统时间是否匹配来检查还有一种不用数据dump导出的pg_upgrade方式,后续再记。

就这样吧。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn