antdb-upgrade大版本升级介绍

news2024/7/7 17:10:19

antdb-upgrade

 

pg_upgrade 是postgresql 大版本升级的得力工具。

  • 数据库系统数据部分通过 new version的pg_upgrade自动升级完成
  • 数据库用户数据部分,主要有两种用法:
  1. 使用pg_upgrade copy物理拷贝方式升级(非copy to/copy from逻辑拷贝)。
  2. 使用pg_upgrade link 硬链接方式升级。

两种方式对比说明:

2种数据库版本的二进制安装过程,这里忽略,请自行研究。

​数据库规划信息:

 

1.1升级步骤说明

新数据库重新initdb

1.初始化新数据库 

/tmp/antdb60/bin/initdb -D /data/sy/adb50oltp/data6 -E UTF8 --locale=C -k

​2.调整配置

​log_destination = 'csvlog'

logging_collector = on

log_directory = 'pg_log'

port = '8432'

listen_addresses = '*'


3.启动新数据库

​/tmp/antdb60/bin/pg_ctl -D /data/sy/adb50oltp/data6 start

新数据库删除2个schema

postgres=# update pg_database set datallowconn='t' where datname='template0';

postgres=# drop schema dbms_lock,dbms_output cascade;

postgres=# \c template1

template1=# drop schema dbms_lock,dbms_output cascade;

template1=# \c template0

template0=# drop schema dbms_lock,dbms_output cascade;

postgres=# update pg_database set datallowconn='f' where datname='template0';

新数据库停止

/tmp/antdb60/bin/pg_ctl -D /data/sy/adb50oltp/data6 -m fast stop

老数据库停止

pg_ctl -D /data/sy/adb50oltp/data5 -m fast stop

新数据库pg_upgrade检测兼容性

/tmp/antdb60/bin/pg_upgrade -d /data/sy/adb50oltp/data5 -D /data/sy/adb50oltp/data6 -b /data/sy/adb50oltp/antdb50/bin -B /tmp/antdb60/bin -p 7432 -P 8432 -c

Performing Consistency Checks

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

Checking cluster versions ok

Checking database user is the install user ok

Checking database connection settings ok

Checking for prepared transactions ok

Checking for reg* data types in user tables ok

Checking for contrib/isn with bigint-passing mismatch ok

Checking for tables WITH OIDS ok

Checking for invalid "sql_identifier" user columns ok

Checking for presence of required libraries ok

Checking database user is the install user ok

Checking for prepared transactions ok

*Clusters are compatible*

输出 *Clusters are compatible*,说明检测ok。

新数据库升级pg_upgrade

以下2种升级方式,二选一,操作其中一种方式即可。

copy方式升级

升级时,可以指定通过 -j 参数指定并行,此处并行度设置为2

/tmp/antdb60/bin/pg_upgrade -d /data/sy/adb50oltp/data5 -D /data/sy/adb50oltp/data6 -b /data/sy/adb50oltp/antdb50/bin -B /tmp/antdb60/bin -p 7432 -P 8432 -j 2

Performing Consistency Checks

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

Checking cluster versions ok

Checking database user is the install user ok

Checking database connection settings ok

Checking for prepared transactions ok

Checking for reg* data types in user tables ok

Checking for contrib/isn with bigint-passing mismatch ok

Checking for tables WITH OIDS ok

Checking for invalid "sql_identifier" user columns ok

Creating dump of global objects ok

Creating dump of database schemas

ok

Checking for presence of required libraries ok

Checking database user is the install user ok

Checking for prepared transactions ok

If pg_upgrade fails after this point, you must re-initdb the

new cluster before continuing.

Performing Upgrade

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

Analyzing all rows in the new cluster ok

Freezing all rows in the new cluster ok

Deleting files from new pg_xact ok

Copying old pg_xact to new server ok

Setting next transaction ID and epoch for new cluster ok

Deleting files from new pg_multixact/offsets ok

Copying old pg_multixact/offsets to new server ok

Deleting files from new pg_multixact/members ok

Copying old pg_multixact/members to new server ok

Setting next multixact ID and offset for new cluster ok

Resetting WAL archives ok

Setting frozenxid and minmxid counters in new cluster ok

Restoring global objects in the new cluster ok

Restoring database schemas in the new cluster

ok

Copying user relation files

ok

Setting next OID for new cluster ok

Sync data directory to disk ok

Creating script to analyze new cluster ok

Creating script to delete old cluster ok

Upgrade Complete

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

Optimizer statistics are not transferred by pg_upgrade so,

once you start the new server, consider running:

./analyze_new_cluster.sh

Running this script will delete the old cluster's data files:

./delete_old_cluster.sh

运行结束,会生成2个脚本。

analyze_new_cluster.sh收集数据库统计信息 –必须执行

delete_old_cluster.sh删除老数据库 –可选,如磁盘空间紧张,可执行该脚本,建议保留一段时间后,再执行该脚本

link方式升级

升级时,可以指定通过 -j 参数指定并行,此处并行度设置为2

-k 参数指定使用link硬连接方式升级。

/tmp/antdb60/bin/pg_upgrade -d /data/sy/adb50oltp/data5 -D /data/sy/adb50oltp/data6 -b /data/sy/adb50oltp/antdb50/bin -B /tmp/antdb60/bin -p 7432 -P 8432 -j 2 -k

Performing Consistency Checks

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

Checking cluster versions ok

Checking database user is the install user ok

Checking database connection settings ok

Checking for prepared transactions ok

Checking for reg* data types in user tables ok

Checking for contrib/isn with bigint-passing mismatch ok

Checking for tables WITH OIDS ok

Checking for invalid "sql_identifier" user columns ok

Creating dump of global objects ok

Creating dump of database schemas

ok

Checking for presence of required libraries ok

Checking database user is the install user ok

Checking for prepared transactions ok

If pg_upgrade fails after this point, you must re-initdb the

new cluster before continuing.

Performing Upgrade

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

Analyzing all rows in the new cluster ok

Freezing all rows in the new cluster ok

Deleting files from new pg_xact ok

Copying old pg_xact to new server ok

Setting next transaction ID and epoch for new cluster ok

Deleting files from new pg_multixact/offsets ok

Copying old pg_multixact/offsets to new server ok

Deleting files from new pg_multixact/members ok

Copying old pg_multixact/members to new server ok

Setting next multixact ID and offset for new cluster ok

Resetting WAL archives ok

Setting frozenxid and minmxid counters in new cluster ok

Restoring global objects in the new cluster ok

Restoring database schemas in the new cluster

ok

Adding ".old" suffix to old global/pg_control ok

If you want to start the old cluster, you will need to remove

the ".old" suffix from /data/sy/adb50oltp/data5/global/pg_control.old.

Because "link" mode was used, the old cluster cannot be safely

started once the new cluster has been started.

Linking user relation files

ok

Setting next OID for new cluster ok

Sync data directory to disk ok

Creating script to analyze new cluster ok

Creating script to delete old cluster ok

Upgrade Complete

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

Optimizer statistics are not transferred by pg_upgrade so,

once you start the new server, consider running:

./analyze_new_cluster.sh

Running this script will delete the old cluster's data files:

./delete_old_cluster.sh

运行结束,会生成2个脚本。

analyze_new_cluster.sh收集数据库统计信息 –必须执行

delete_old_cluster.sh删除老数据库 –可选,如磁盘空间紧张,可执行该脚本,建议保留一段时间后,再执行该脚本

新数据库启动

/tmp/antdb60/bin/pg_ctl -D /data/sy/adb50oltp/data6 start

参考链接

https://blog.csdn.net/ctypyb2002/article/details/80782235

https://blog.csdn.net/ctypyb2002/article/details/80787903

 ​​​​

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/650830.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

内网渗透—隧道搭建SPP与NPS内网穿透

内网渗透—隧道搭建&SPP与NPS内网穿透 1. 前言2. SPP2.1. SPP代理通信2.1.1. 服务端配置2.1.2. 客户端配置2.1.3. CS设置2.1.3.1. 设置生成的监听器2.1.3.2. 设置监听的监听器 2.1.4. 执行效果 2.2. SPP隧道建立2.2.1. 服务端设置2.2.2. 客户端配置2.2.3. CS设置2.2.3.1. 设…

Mybatis学习笔记三

目录 一、MyBatis的缓存1.1 MyBatis的一级缓存1.2 MyBatis的二级缓存1.3 二级缓存的相关配置1.4 MyBatis缓存查询的顺序1.5 整合第三方缓存EHCache(了解) 二、MyBatis的逆向工程2.1 创建逆向工程的步骤2.2 简单使用查询增改 三、 分页插件3.1 分页插件使…

Endnote解决文章题目Title大小写问题,以及专有名词保持全部大写

在写毕业论文或综述类文章时,需要添加大量参考文献(100左右或更多),而每个期刊的要求是不一样的,因此手动输入或修改参考文献的格式是愚蠢的(狗头保命),所以需要强大的endnote来进行…

一篇博客搞定C++11之Lambda表达式(附案例代码+解析)

Lambda表达式 1.lambda表达式语法2.捕获列表说明3.lambda表达式实现原理4.具体案例5.总结 1.lambda表达式语法 ambda表达式的语法非常简单,具体定义如下: [ captures ] ( params ) specifiers exception -> ret { body } 先不用急于解读这个定义&…

面向对象内部类

概念 将一个类 A 定义在另一个类 B 里面,里面的那个类 A 就称为内部类 (InnerClass),类 B 则称为外部类(OuterClass) 根据内部类声明的位置(如同变量的分类),我们可以分…

首次使用云服务器搭建网站(二)

书接上文,我们已经完成了服务器的租赁,宝塔面板的下载与安装。 接下来我们将正式开始网站搭建。 一、网站创建 点击网站、添加站点 输入网站域名、数据库选择MySQL数据库,选择utf8,数据库账号密码会自动生成。无论你要创建什么样…

【linux网络配置】多个网卡一起使用,一个网卡连内网,一个网卡连外网

一、问题背景 因为有一个工作站在内网中,但是没有办法联网(校园网账户有限)。 虽然工作站没有联网,但是我仍然可以通过局域网远程控制工作站,使其访问校园网验证页面实现上网。 当给工作站安装软件或依赖项时&#…

SpringBoot配置文件application.properties的理解

一、存放位置分类 1.当前项目根目录下的config目录下 2.当前项目的根目录下 3.resources目录下的config目录下 4.resources目录下 按照这上面的顺序,4个配置文件的优先级依次降低。 我们在项目里面4个位置分别设置了各种的application.properties文件。每个文件…

MySQL查看和修改最大连接数

标题:MySQL查看和修改最大连接数 MySQL 是一种广泛使用的开源关系型数据库管理系统,被许多应用程序用作其后端存储解决方案。在高并发的环境下,MySQL 的最大连接数变得尤为重要。本文将介绍如何查看当前的最大连接数,并详细说明每…

安卓实战开发之——使用 WIFI 进行设备搜索并获取相应信息

目录 一、前言 二、准备条件 三、功能要求 四、显示效果 五、关键代码 一、前言 此玩意是本人很早很早(记不清有多早了,反正很早)做过的一个课程任务了,无意之中翻到了,所以把它放上来。不愿再找以前写的代码了…

大数据环境搭建 Hadoop+Hive+Flume+Sqoop+Azkaban

目录 零:版本说明一、安装CentOS二、Hadoop单机配置三、Hive安装部署 零:版本说明 Hadoop:3.1.0 CentOS:7.6 JDK:1.8 一、安装CentOS 这里网上教程很多,就不贴图了 【内存可以尽量大一些,不然…

DeepBIO:一个自动化和可解释的深度学习平台,用于高通量生物序列预测,功能注释和可视化分析

DeepBIO: an automated and interpretable deep-learning platform for high-throughput biological sequence prediction, functional annotation and visualization analysis 期刊:Nucleic Acids Research 中科院分区:2区 影像因子:19.1…

面向对象抽象

抽象类 1 概念 Java中可以定义被abstract关键字修饰的方法,这种方法只有声明,没有方法体,叫做抽象方法. Java中可以定义被abstract关键字修饰的类,被abstract关键字修饰的类叫做抽象类 如果一个类含有抽象方法,那么它一定是抽象类 抽象类中的方法实现交给子类来完成 2 抽象…

redisTemplate海量数据批量存储

有个表的数据需初始化到redis, 目前18w, 后期会达到千万1. 使用redisTemplate批量存储数据 Autowiredprivate RedisTemplate redisTemplate;public void init(){List<WxPois> list SpringUtils.getBean(WxPoisMapper.class).selectWxPoisList(new WxPois());if (Collect…

华为OD机试之数组拼接(Java源码)

数组拼接 题目描述 现在有多组整数数组&#xff0c;需要将它们合并成一个新的数组。 合并规则&#xff0c;从每个数组里按顺序取出固定长度的内容合并到新的数组中&#xff0c;取完的内容会删除掉&#xff0c;如果该行不足固定长度或者已经为空&#xff0c;则直接取出剩余部…

APP、Web自动化测试面试题

App/Web自动化的面试题 备注&#xff1a;一般面试的时候是结合简历上的项目一步一步深入进行问的问题&#xff0c;只要你实际做过一个项目的&#xff0c;加上自己面试准备下&#xff0c;问题不会太大 【APP自动化问题&#xff1a;1.3.6.10.11.12.13.14.19】 【Web自动化问题&…

意向共享锁和意向排他锁

InnoDB表级锁 在绝大部分情况下都应该使用行锁&#xff0c;因为事务和行锁往往是选择InnoDB的理由&#xff0c;但个别情况下也使用表级锁&#xff1a; 1&#xff09;事务需要更新大部分或全部数据&#xff0c;表又比较大&#xff0c;如果使用默认的行锁&#xff0c;不仅这个事…

【Android开发基础】蓝牙信息的获取(Bluetooth)

文章目录 一、引言二、操作1、权限2、开启蓝牙3、可检测4、搜索蓝牙5、广播 三、附件1、UI界面设计2、总代码 一、引言 描述&#xff1a;蓝牙技术是一种无线数据和语音通信开放的全球规范&#xff0c;它是基于低成本的近距离无线连接&#xff0c;为固定和移动设备建立通信环境…

华为OD机试真题 JavaScript 实现【知识图谱新词挖掘1】【2023Q1 100分】

一、题目描述 小华负责公司知识图谱产品&#xff0c;现在要通过新词挖掘完善知识图谱。 新词挖掘: 给出一个待挖掘文本内容字符串Content和一个词的字符串word&#xff0c;找到content中所有word的新词。 新词&#xff1a;使用词word的字符排列形成的字符串。 请帮小华实现新词…

cesium学习(相机)

飞到一个地方 如果你知道位置的经纬度和高度&#xff0c;你可以使用相机的flyTo功能直接飞到CesiumJS中的那个位置。 viewer.camera.flyTo({destination: Cesium.Cartesian3.fromDegrees(-117.16, 32.71, 15000.0), });更改相机的方向 flyTo要在完成后更改相机的方向&#x…