PostgreSQL小版本升级

本文涉及的产品
云原生数据库 PolarDB PostgreSQL 版,标准版 2核4GB 50GB
云原生数据库 PolarDB MySQL 版,通用型 2核8GB 50GB
简介:

我们知道pg_upgrade和pg_dump/pg_restore可以实现大版本升级数据库,那么小版本如何升级,比如从9.6.3到9.6.5?

原理:用新版本的软件程序启动,指定老的的数据目录


安装pgsql9.6.3

mkdir -p /usr/local/pgsql/pgsql9.6.3/{data,arch}

groupadd dba

useradd -g dba -G root postgres -d /usr/local/pgsql

tar xf postgresql-9.6.3.tar.gz

chmod -R 755 /usr/local/pgsql

chown -R postgres:dba /usr/local/pgsql

chmod -R 700 /usr/local/pgsql/pgsql9.6.3/data/

./configure --prefix=/usr/local/pgsql/pgsql9.6.3/

make world && make install-world

cd /usr/local/pgsql/pgsql9.6.3/bin

./initdb -D /usr/local/pgsql/pgsql9.6.3/data  -U postgres -E UTF8  -W


vim pg_hba.conf

host all all 0.0.0.0/0 md5


vim postgresql.conf

listen_addresses = '*'

wal_level = replica

port = 5432

max_connections = 300

shared_buffers = 128MB

logging_collector = on

log_directory = 'pg_log'

log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'

archive_mode = on

archive_command = 'test ! -f /usr/local/pgsql/pgsql9.6.5/arch/%f  &&  cp %p /usr/local/pgsql/pgsql9.6.5/arch/%f'

/usr/local/pgsql/pgsql9.6.3/bin/pg_ctl start -D /usr/local/pgsql/pgsql9.6.3/data


#生成测试数据

create database testdb1;

\c testdb1;

create table t1(id int primary key, info text);

insert into t1 select generate_series(1,1000000),'helloWorld';


安装pgsql9.6.5

mkdir -p /usr/local/pgsql/pgsql9.6.5/{data,arch}

groupadd dba

useradd -g dba -G root postgres -d /usr/local/pgsql

tar xf postgresql-9.6.5.tar.gz

chmod -R 755 /usr/local/pgsql

chown -R postgres:dba /usr/local/pgsql

chmod -R 700 /usr/local/pgsql/pgsql9.6.5/data/

./configure --prefix=/usr/local/pgsql/pgsql9.6.5/

make world && make install-world

cd /usr/local/pgsql/pgsql9.6.5/bin

/usr/local/pgsql/pgsql9.6.5/bin/initdb -D /usr/local/pgsql/pgsql9.6.5/data  -U postgres -E UTF8  -W


vim pg_hba.conf

host all all 0.0.0.0/0 md5


vim postgresql.conf

listen_addresses = '*'

wal_level = replica

port = 5431

max_connections = 300

shared_buffers = 128MB

logging_collector = on

log_directory = 'pg_log'

log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'

archive_mode = on

archive_command = 'test ! -f /usr/local/pgsql/pgsql9.6.5/arch/%f  &&  cp %p /usr/local/pgsql/pgsql9.6.5/arch/%f'

/usr/local/pgsql/pgsql9.6.5/bin/pg_ctl start -D /usr/local/pgsql/pgsql9.6.5/data

/usr/local/pgsql/pgsql9.6.5/bin/pg_ctl stop -m fast -D /usr/local/pgsql/pgsql9.6.5/data


#停止老的数据库9.6.3

/usr/local/pgsql/pgsql9.6.3/bin/pg_ctl stop -m fast -D /usr/local/pgsql/pgsql9.6.3/data

#用9.6.5的软件程序启动,指定9.6.3的数据目录

/usr/local/pgsql/pgsql9.6.5/bin/pg_ctl start -D /usr/local/pgsql/pgsql9.6.3/data


postgres=# select version();

                                                 version                                                 

---------------------------------------------------------------------------------------------------------

PostgreSQL 9.6.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4), 64-bit

testdb1=# select count(*) from t1;

  count  

---------

1000000



本文转自 Darren_Chen 51CTO博客,原文链接:http://blog.51cto.com/darrenmemos/1978060,如需转载请自行联系原作者

相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
相关文章
|
5月前
|
关系型数据库 分布式数据库 数据库
开源云原生数据库PolarDB PostgreSQL 15兼容版本正式发布
PolarDB进行了深度的内核优化,从而实现以更低的成本提供商业数据库的性能。
|
8月前
|
SQL 关系型数据库 数据库
nacos 2.2.3版本 查看配置文件的历史版本的接口 是针对MySQL数据库的sql 改成postgresql后 sql语句报错 该怎么解决
在Nacos 2.2.3中切换到PostgreSQL后,执行配置文件历史版本分页查询出错,因`LIMIT 0, 10`语法不被PostgreSQL支持,需改为`LIMIT 10 OFFSET 0`。仅当存在历史版本时报错。解决方案是调整查询SQL以兼容PostgreSQL语法。
|
9月前
|
安全 关系型数据库 数据库
上新|阿里云RDS PostgreSQL支持PG 16版本,AliPG提供丰富自研能力
AliPG在社区版16.0的基础上,在安全、成本、可运维性等多个方面做了提升,丰富的内核/插件特性支持,满足业务场景的需求
|
SQL 关系型数据库 PostgreSQL
PostgreSQL查看版本
PostgreSQL查看版本
100 0
|
Cloud Native 关系型数据库 数据挖掘
AnalyticDB PostgreSQL版7.0版本公测期间,享优先购买福利!一次性购买6个月资源,可享0.1折!
云原生向量数据库AnalyticDB PostgreSQL版全新发布7.0公测版本!版本性能较开源实现开箱5X性能提升!
|
SQL 关系型数据库 MySQL
Flink CDC 2.4 正式发布,新增 Vitess 数据源,PostgreSQL 和 SQL Server CDC 连接器支持增量快照,升级 Debezium 版本
Flink CDC 2.4 正式发布,新增 Vitess 数据源,PostgreSQL 和 SQL Server CDC 连接器支持增量快照,升级 Debezium 版本
1376 1
Flink CDC 2.4 正式发布,新增 Vitess 数据源,PostgreSQL 和 SQL Server CDC 连接器支持增量快照,升级 Debezium 版本
|
存储 关系型数据库 Go
深入理解 PostgreSQL 中的 MVCC(多版本并发控制)机制
深入理解 PostgreSQL 中的 MVCC(多版本并发控制)机制
300 0
|
SQL Oracle 关系型数据库
Polar DB-O (兼容 Oracle 语法版本)和Polar DB PostgreSQL 版本概述(二)
Polar DB-O (兼容 Oracle 语法版本)和Polar DB PostgreSQL 版本概述(二)
2012 0
|
存储 算法 安全
[翻译]PostgreSQL中的WAL压缩以及版本15中的改进
[翻译]PostgreSQL中的WAL压缩以及版本15中的改进
243 0
|
SQL 存储 缓存
PostgreSQL 14及更高版本改进
PostgreSQL 14及更高版本改进
371 0