社区最近推出了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方式,后续再记。
就这样吧。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/1894901.html