zoukankan      html  css  js  c++  java
  • 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_kenyon  -f db.bak
    安全起见,备份出来的文件检查一下是否正常,能否正确导入,最好记一下用户名及密码等
    
    2.关闭服务
    pg_stop
    ps -ef|grep postgres 检查一下
    
    3.编译postgresql_9.2.4,原先是9.1.3
    [postgres@kenyon ~] $tar -zxvf postgresql_9.2.4.tar.gz
    [postgres@kenyon ~] cd postgresql_9.2.4
    [postgres@kenyon 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@kenyon postgresql_9.2.4]gmake world
    [postgres@kenyon postgresql_9.2.4]gmake install-world
    如果顺利的话,这个时候可以看一下BIN是否已经换成9.2.4
    [postgres@kenyon postgresql_9.2.4]$ psql -V
    psql (PostgreSQL) 9.2.4
    [postgres@kenyon postgresql_9.2.4]$
    说明BIN文件等已经OK
    如果原始版本是9.2.0及以上,可忽略以下步骤,直接启动postgres,如果是9.2.0以下版本,直接启动会报错,则继续,类似initdb与configure版本不一致的问题
    
    4.修改数据文件
    [postgres@kenyon ~]mv /database/pgdata /database/pgdata.old
    [postgres@kenyon ~]mkdir /database/pgdata
    
    5.初始化DB
    [postgres@kenyon ~]$initdb -D /database/pgdata -E UTF8 --locale=C -U postgres -W
    
    6.拷贝老的postgresql.conf与pg_hba.conf文件到新的$PGDATA下
    [postgres@kenyon ~]$cp /database/pgdata.old/postgresql.conf /database/pgdata/postgresql.conf
    [postgres@kenyon ~]$cp /database/pgdata.old/hba.conf /database/pgdata/hba.conf
    
    7.启动数据库
    pg_start
    --如果是单个库导出恢复则建一下DB和相关的用户,省得导入报错
    
    8.恢复数据
    [postgres@kenyon ~]$psql -d db_kenyon -f db.bak
    
    9.检查
    检查数据、应用及日志是否有异常,还有一些容易遗漏的参数如timezone等,这个可以通过数据库里select now()与系统时间是否匹配来检查

    还有一种不用数据dump导出的pg_upgrade方式,后续再记。

    就这样吧。

  • 相关阅读:
    quagga源码学习--BGP协议的初始化
    Golang pprof heap profile is empty
    python requests 配置超时及重试次数
    SVN: bdb: BDB1538 Program version 5.3 doesn't match environment version 4.7
    OpenSSL Command-Line HOWTO
    树莓派保卫战--防止SSH暴力破解
    Mac OS X Tips
    Git Tips
    SQL分组多列统计(GROUP BY后按条件分列统计)
    Show Linux Package Sort By Size
  • 原文地址:https://www.cnblogs.com/shihao/p/3013753.html
Copyright © 2011-2022 走看看