Welcome 微信登录

首页 / 数据库 / MySQL / Postgres 9.2.4的升级方案与步骤

社区最近推出了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_www.linuxidc.com  -f db.bak
安全起见,备份出来的文件检查一下是否正常,能否正确导入,最好记一下用户名及密码等2.关闭服务
pg_stop
ps -ef|grep postgres 检查一下3.编译postgresql_9.2.4,原先是9.1.3
[postgres@www.linuxidc.com ~] $tar -zxvf postgresql_9.2.4.tar.gz
[postgres@www.linuxidc.com ~] cd postgresql_9.2.4
[postgres@www.linuxidc.com 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@www.linuxidc.com postgresql_9.2.4]gmake world
[postgres@www.linuxidc.com postgresql_9.2.4]gmake install-world
如果顺利的话,这个时候可以看一下BIN是否已经换成9.2.4
[postgres@www.linuxidc.com postgresql_9.2.4]$ psql -V
psql (PostgreSQL) 9.2.4
[postgres@www.linuxidc.com postgresql_9.2.4]$
说明BIN文件等已经OK
如果原始版本是9.2.0及以上,可忽略以下步骤,直接启动postgres,如果是9.2.0以下版本,直接启动会报错,则继续,类似initdb与configure版本不一致的问题4.修改数据文件
[postgres@www.linuxidc.com ~]mv /database/pgdata /database/pgdata.old
[postgres@www.linuxidc.com ~]mkdir /database/pgdata5.初始化DB
[postgres@www.linuxidc.com ~]$initdb -D /database/pgdata -E UTF8 --locale=C -U postgres -W6.拷贝老的postgresql.conf与pg_hba.conf文件到新的$PGDATA下
[postgres@www.linuxidc.com ~]$cp /database/pgdata.old/postgresql.conf /database/pgdata/postgresql.conf
[postgres@www.linuxidc.com ~]$cp /database/pgdata.old/hba.conf /database/pgdata/hba.conf7.启动数据库
pg_start
--如果是单个库导出恢复则建一下DB和相关的用户,省得导入报错8.恢复数据
[postgres@www.linuxidc.com ~]$psql -d db_www.linuxidc.com -f db.bak9.检查
检查数据、应用及日志是否有异常,还有一些容易遗漏的参数如timezone等,这个可以通过数据库里select now()与系统时间是否匹配来检查还有一种不用数据dump导出的pg_upgrade方式,后续再记。就这样吧。Oracle归档模式设置的相关指令与简要说明ORA-27102:out of memory Linux-X86_64相关资讯      Postgres  Postgres 9.2.4  Postgres升级 
  • 在 Postgres 里克隆一个 MongoDB  (04/29/2014 07:59:53)
  • 3月数据库排名 —— Postgres 上升  (03/06/2013 08:13:44)
  • Sqoop配置安装  (08/24/2011 07:11:53)
  • PostgreSQL 9.3 新特性预览 ——   (04/15/2013 08:12:25)
  • Postgres 9.2 新特性之:范围类型   (11/02/2012 08:17:30)
本文评论 查看全部评论 (0)
表情: 姓名: 字数