KingbaseES V8R6 运维系列 --单机小版本升级
案例说明:
在KingbaseES V8R6版本提供了sys_upgrade的升级工具, 本案例描述了KingbaseES V8R6单机环境下数据库的小版本升级操作,案例涉及的版本从‘(Kingbase) V008R006C005B0041’通过sys_upgrade升级到‘ (Kingbase) V008R006C005B0054’,此案例可以用于生产环境下数据库升级的参考。
适用版本:
KingbaseES V8R6
升级工具sys_upgade:
sys_upgrade — 升级KingbaseES服务器实例。
sys_upgrade 允许将存储在KingbaseES数据文件中的数据升级到一个更高的KingbaseES主版本,而无需进行主版本升级(例如从 V8R6C4 到 V8R6C5)通常所需的数据转储/重载。
sys_upgrade 支持从 V8R6(20211031版本) 及其后版本升级到当前的KingbaseES主版本,包括快照和beta版本。
sys_upgrade 目前暂不支持 Windows 版本的KingbaseES升级。
详情见官网说明:https://help.kingbase.com.cn/v8/admin/reference/ref-server/pgupgrade.html?highlight=sys_upgrade#id4
一、查看升级前后数据库版本信息
#升级前数据库版本
[kingbase@node101 lib]$ cd /opt/Kingbase/ES/V8R6_041/Server/bin
[kingbase@node101 bin]$ ./ksql -V
ksql (Kingbase) V008R006C005B0041
#升级后数据库版本
[kingbase@node101 mnt]$ cd /opt/Kingbase/ES/V8R6_054/Server/bin
[kingbase@node101 bin]$ ./ksql -V
ksql (Kingbase) V008R006C005B0054
---如果旧版本数据库中有新增插件相关的so 库,而新版本数据库中没有的,需要把相关so 拷贝到新版本数据库lib 目录下。
二、升级前原版本相关参数配置
#升级前版本数据库目录
[kingbase@node101 data]$ pwd
/data/kingbase/v8r6_041/data
#关闭原版本的归档
[kingbase@node101 data]$ cat kingbase.conf |grep archive_mode
archive_mode = off # enables archiving; off, on, or always
#编辑原版本sys_hba.conf文件
[kingbase@node101 data]$ cp sys_hba.conf sys_hba.conf.old
[kingbase@node101 data]$ sed -i "s/scram-sha-256/trust/g" sys_hba.conf
[kingbase@node101 data]$ cat sys_hba.conf
.......
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
host all all 0.0.0.0/0 trust
# IPv6 local connections:
host all all ::1/128 trust
host all all ::0/0 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
host replication all 192.168.1.0/24 trust
host all all 0.0.0.0/0 trust
---如上所示,将sys_hba.conf的认证改为trust,升级期间,便于新旧版本之间访问连接。
三、查看原版本字符集相关信息
Tips:
必须保证升级前后版本的数据库字符集及lc_ctype一致。
test=# show server_encoding;
server_encoding
-----------------
UTF8
(1 row)
test=# \l+ List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description
-----------+--------+----------+----------+-------------+-------------------+-------+-------------+--------------------------------------------
prod | system | UTF8 | ci_x_icu | en_US.UTF-8 | | 12 MB | sys_default |
security | system | UTF8 | ci_x_icu | en_US.UTF-8 | | 12 MB | sys_default |
template0 | system | UTF8 | ci_x_icu | en_US.UTF-8 | =c/system +| 12 MB | sys_default | unmodifiable empty database
| | | | | system=CTc/system | | |
template1 | system | UTF8 | ci_x_icu | en_US.UTF-8 | =c/system +| 12 MB | sys_default | default template for newdatabases
| | | | | system=CTc/system | | |
test | system | UTF8 | ci_x_icu | en_US.UTF-8 | | 12 MB | sys_default | default administrative connection database
(5 rows)
四、安装新版本数据库软件及初始化新的实例
Tips:
- 新版本和旧版本的相关参数:字符集、lc_ctype、数据块大小保证一致。
- 必须使用旧版本数据库initdb时使用的操作系统用户。
- 必须使用和旧版本数据库一样的数据库用户,及-U 参数保持一致。
- block_size 和wal_segsize 必须和旧版本数据库的data 保持一致。
- initdb 初始化的所有参数必须和旧版本数据库initdb 时保持一致。
- 若不一致,在后续的升级兼容性检查也会检测出具体信息。
#在新版本数据库初始化实例
[kingbase@node101 bin]$ ./initdb -U system -W --enable-ci -E utf8 --lc-ctype="en_US.UTF-8" -D /data/kingbase/v8r6_054/data
The files belonging to this database system will be owned by user "kingbase".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".
......
Success. You can now start the database server using:
./sys_ctl -D /data/kingbase/v8r6_054/data -l logfile start
#查看新版本数据库信息
[kingbase@node101 bin]$ ./ksql -U system test -p 54323
ksql (V8.0)
Type "help" for help.
test=# \l+
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Descriptio
n
-----------+--------+----------+----------+-------------+-------------------+-------+-------------+--------------------------
------------------
security | system | UTF8 | ci_x_icu | en_US.UTF-8 | | 12 MB | sys_default |
template0 | system | UTF8 | ci_x_icu | en_US.UTF-8 | =c/system +| 12 MB | sys_default | unmodifiable empty databa
se
| | | | | system=CTc/system | | |
template1 | system | UTF8 | ci_x_icu | en_US.UTF-8 | =c/system +| 12 MB | sys_default | default template for new
databases
| | | | | system=CTc/system | | |
test | system | UTF8 | ci_x_icu | en_US.UTF-8 | | 12 MB | sys_default | default administrative co
nnection database
(4 rows)
五、将原版本相关配置文件拷贝到新版本下
[kingbase@node101 data]$ cp kingbase.conf /data/kingbase/v8r6_054/data/
[kingbase@node101 data]$ cp kingbase.auto.conf /data/kingbase/v8r6_054/data/
[kingbase@node101 data]$ cp sys_hba.conf /data/kingbase/v8r6_054/data/
六、版本升级前兼容性检查
#在新版本数据库bin目录下执行sys_upgrade工具
[kingbase@node101 bin]$ ./sys_upgrade -b /opt/Kingbase/ES/V8R6_041/Server/bin -B /opt/Kingbase/ES/V8R6_054/Server/bin -d /data/kingbase/v8r6_041/data -D /data/kingbase/v8r6_054/data -c -p 54325 -P 54323 -U system
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 presence of required libraries ok
Checking database user is the install user ok
Checking for prepared transactions ok
*Clusters are compatible*
---如上所示,新旧版本之间兼容性检查通过。

七、执行版本升级
Tips:
升级前对原数据库执行物理备份,并停止原版本和新版本数据库服务。
#在新版本数据库bin目录下执行sys_upgrade工具
[kingbase@node101 bin]$ ./sys_upgrade -b /opt/Kingbase/ES/V8R6_041/Server/bin -B /opt/Kingbase/ES/V8R6_054/Server/bin -d /data/kingbase/v8r6_041/data -D /data/kingbase/v8r6_054/data -p 54325 -P 54323 -U system
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
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 sys_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 sys_xact ok
Copying old sys_xact to new server ok
Setting next transaction ID and epoch for new cluster ok
Deleting files from new sys_multixact/offsets ok
Copying old sys_multixact/offsets to new server ok
Deleting files from new sys_multixact/members ok
Copying old sys_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
Copying wallet 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 sys_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
八、对升级后的数据库执行统计分析
#在新版本数据库bin目录下执行分析脚本
[kingbase@node101 bin]$ ./analyze_new_cluster.sh
This script will generate minimal optimizer statistics rapidly
so your system is usable, and then gather statistics twice more
with increasing accuracy. When it is done, your system will
have the default level of optimizer statistics.
If you have used ALTER TABLE to modify the statistics target for
any tables, you might want to remove them and restore them after
running this script because they will delay fast statistics generation.
If you would like default statistics as quickly as possible, cancel
this script and run:
"/opt/Kingbase/ES/V8R6_054/Server/bin/vacuumdb" -U system --all --analyze-only
vacuumdb: error: could not connect to database template1: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.KINGBASE.54321"?
Done
---以上错误,需要修改脚本中数据库连接服务端口(默认:54321)
#修改脚本中数据库连接端口
[kingbase@node101 bin]$ cat analyze_new_cluster.sh |grep vacuum
echo ' "/opt/Kingbase/ES/V8R6_054/Server/bin/vacuumdb" -U system --all --analyze-only'
"/opt/Kingbase/ES/V8R6_054/Server/bin/vacuumdb" -U system --all --analyze-in-stages -p 54323
#执行脚本分析
[kingbase@node101 bin]$ ./analyze_new_cluster.sh
This script will generate minimal optimizer statistics rapidly
so your system is usable, and then gather statistics twice more
with increasing accuracy. When it is done, your system will
have the default level of optimizer statistics.
If you have used ALTER TABLE to modify the statistics target for
any tables, you might want to remove them and restore them after
running this script because they will delay fast statistics generation.
If you would like default statistics as quickly as possible, cancel
this script and run:
"/opt/Kingbase/ES/V8R6_054/Server/bin/vacuumdb" -U system --all --analyze-only
vacuumdb: processing database "prod": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "security": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "template1": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "test": Generating minimal optimizer statistics (1 target)
vacuumdb: processing database "prod": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "security": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "template1": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "test": Generating medium optimizer statistics (10 targets)
vacuumdb: processing database "prod": Generating default (full) optimizer statistics
vacuumdb: processing database "security": Generating default (full) optimizer statistics
vacuumdb: processing database "template1": Generating default (full) optimizer statistics
vacuumdb: processing database "test": Generating default (full) optimizer statistics
Done
---如上所示,数据库分析完成。
九、查看新版本数据库数据(应该和原版本数据一致)
[kingbase@node101 bin]$ ./ksql -U system test -p 54323
ksql (V8.0)
Type "help" for help.
test=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+--------+----------+----------+-------------+-------------------
prod | system | UTF8 | ci_x_icu | en_US.UTF-8 |
security | system | UTF8 | ci_x_icu | en_US.UTF-8 |
template0 | system | UTF8 | ci_x_icu | en_US.UTF-8 | =c/system +
| | | | | system=CTc/system
template1 | system | UTF8 | ci_x_icu | en_US.UTF-8 | system=CTc/system+
| | | | | =c/system
test | system | UTF8 | ci_x_icu | en_US.UTF-8 |
(5 rows)
prod=# select * from t1 limit 10;
id | name
----+----------
1 | 524fe608
2 | a281abeb
3 | 12596181
4 | 8c6964fd
5 | 53dabd51
6 | 681f8e17
7 | 7f4747d7
8 | 05fb8475
9 | 53c67d00
10 | 6b993d5e
(10 rows)
十、删除原版本数据
#在新版本数据库bin目录下执行清理脚本
[kingbase@node101 bin]$ pwd
/opt/Kingbase/ES/V8R6_054/Server/bin
[kingbase@node101 bin]$ ./delete_old_cluster.sh
#原版本data目录下数据已经被删除
[kingbase@node101 data]$ ls -lh
total 0
---如上所示,原版本数据库相关数据文件被删除。
十一、恢复升级版本后的sys_hba.conf
[kingbase@node101 data]$ sed -i "s/trust/scram-sha-256/g" sys_hba.conf

十二、升级中常见故障问题
1、新旧版本数据库lc_ctype不同

2、新旧版本数据库block size不同

以上故障问题,在创建新版本实例前,必须查看旧版本数据库的相关配置,保证新版本创建的实例数据库配置和旧版本一致。
KingbaseES V8R6 运维系列 --单机小版本升级的更多相关文章
- SQL Server自动化运维系列——关于邮件通知那点事(.Net开发人员的福利)
需求描述 在我们的生产环境中,大部分情况下需要有自己的运维体制,包括自己健康状态的检测等.如果发生异常,需要提前预警的,通知形式一般为发邮件告知. 邮件作为一种非常便利的预警实现方式,在及时性和易用性 ...
- SQL Server自动化运维系列——监控跑批Job运行状态(Power Shell)
需求描述 在我们的生产环境中,大部分情况下需要有自己的运维体制,包括自己健康状态的检测等.如果发生异常,需要提前预警的,通知形式一般为发邮件告知. 在上一篇文章中已经分析了SQL SERVER中关于邮 ...
- saltstack自动化运维系列⑤之saltstack的配置管理详解
saltstack自动化运维系列⑤之saltstack的配置管理详解 配置管理初始化: a.服务端配置vim /etc/salt/master file_roots: base: - /srv/sal ...
- saltstack自动化运维系列④之saltstack的命令返回结果mysql数据库写入
saltstack自动化运维系列④之saltstack的命令返回结果mysql数据库写入salt的返回值写入mysql数据库:可参考:https://docs.saltstack.com/en/lat ...
- saltstack自动化运维系列③之saltstack的常用模块使用
saltstack自动化运维系列③之saltstack的常用模块使用 1.命令的常用方法: 指定主机运行命令 # salt 'mini1' cmd.run 'date'mini1: Fri Apr 7 ...
- saltstack自动化运维系列②之saltstack的数据系统
saltstack自动化运维系列②之saltstack的数据系统 grains:搜集minion启动时的系统信息,只有在minion启动时才会搜集,grains更适合做一些静态的属性值的采集,例如设备 ...
- SQL Server自动化运维系列——监控性能指标脚本(Power Shell)
需求描述 一般在生产环境中,有时候需要自动的检测指标值状态,如果发生异常,需要提前预警的,比如发邮件告知,本篇就介绍如果通过Power shell实现状态值监控 监控值范围 根据经验,作为DBA一般需 ...
- SQL Server自动化运维系列——监控磁盘剩余空间及SQL Server错误日志(Power Shell)
需求描述 在我们的生产环境中,大部分情况下需要有自己的运维体制,包括自己健康状态的检测等.如果发生异常,需要提前预警的,通知形式一般为发邮件告知. 在所有的自检流程中最基础的一个就是磁盘剩余空间检测. ...
- SQL Server自动化运维系列——关于数据收集(多服务器数据收集和性能监控)
需求描述 在生产环境中,很多情况下需要采集数据,用以定位问题或者形成基线. 关于SQL Server中的数据采集有着很多种的解决思路,可以采用Trace.Profile.SQLdiag.扩展事件等诸多 ...
- SQL Server自动化运维系列 - 监控磁盘剩余空间及SQL Server错误日志(Power Shell)
需求描述 在我们的生产环境中,大部分情况下需要有自己的运维体制,包括自己健康状态的检测等.如果发生异常,需要提前预警的,通知形式一般为发邮件告知. 在所有的自检流程中最基础的一个就是磁盘剩余空间检测. ...
随机推荐
- html中iframe调用兄弟iframe中的js方法
问题说明 最近工作中碰到一个页面有一个主iframe A,用于操作主要业务元素.其中有一个弹出框里面也嵌入了一个iframe B, 此时,我需要在B中调用A中JS的指定方法.下面咱们来通过例子还原一下 ...
- 我在winform项目里使用“Windows I/O完成端口”的经验分享
少年!看你骨骼惊奇,是万中无一的练武奇才,我这儿有本武林秘籍,见与你有缘就送你了! 如来神掌 Windows I/O完成端口是一个我至今都说不好的话题,请宽容的接受我这不是科班出身的自学成才的野生程序 ...
- win32-ReadProcessMemory在x86和x64下运行
#include <iostream> #include <Windows.h> #include <winternl.h> #include <tchar. ...
- ThreadLocal的应用场景和注意事项有哪些?
https://cloud.tencent.com/developer/article/1618405
- 【Java复健指南02】方法的注意事项
[方法] 方法基本内容 √访问修饰符 (作用是控制方法使用的范围) 可选,[有四种:public\protected\默认\private],具体在后面说 √返回类型 1.一个方法最多有一 ...
- 适配http分发Directory.Build.props文件,需要替换默认的微软sdk:8.0映像
背景 我们是把Directory.Build.props及其Import的文件,都放在http://dev.amihome.cn 那么docker build的时候,也是需要下载Directory.B ...
- Elasticsearch使用实战以及代码详解
Elasticsearch 是一个使用 Java 语言编写.遵守 Apache 协议.支持 RESTful 风格的分布式全文搜索和分析引擎,它基于 Lucene 库构建,并提供多种语言的 API.El ...
- MVVM框架模式
MVC框架模式 MVP框架模式 MVVM框架模式 MVVM模式即: 1.Model:数据层.网络数据操作,file文件操作,本地数据库操作: 2.View:视图层.布局加载,ui交互. 3.ViewM ...
- 【aspose-words】Aspose.Words for Java模板语法详细剖析
前言 缘由 aspose-words模板语法再了解 垂死病中惊坐起,小丑竟是我自己.对于aspose-words的使用本狗自以为已炉火纯青,遂在新的迭代任务中毛遂自荐,并在小姐姐面前吹了一个大牛,分分 ...
- XSS漏洞原理整理
一.通常使用XSS脚本来获取浏览器版本信息,alert(navigator.userAgnet ) ,浏览器的UserAgent是可以伪造的,比方火狐或者很多扩展都可以屏蔽或者自定义浏览器发送的Us ...