随笔 - 136, 文章 - 0, 评论 - 14, 阅读 - 13万
  首页  :: 新随笔  :: 管理
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

使用db2move跨多版本迁移

Posted on   高&玉  阅读(256)  评论(0编辑  收藏  举报

迁移背景

源端

AIX 5.3.0.0

DB2 V9.1

目标端

SUSE 11.4

DB2 V9.7

迁移步骤

1. 导出源端数据库对象DDL

[db2inst1]# db2look -d DBNAME -e -a -l -x -f -o DBNAME.ddl

2. 使用db2move导出源端数据

[db2inst1]# db2move DBNAME export

主要文件介绍:

  • db2move.lst:导出的表清单以及对应的导出文件信息;
  • EXPORT.out:导出表对象的概要信息;
  • .ixf:导出表的数据文件;
  • *.msg:导出对应表时产生的日志。

3. 将导出的数据以二进制的方式传输到目标端

4. 目标端执行DDL生成对应的表空间和对象

[db2inst1]# db2 -tvf DBNAME.ddl

5. 目标端导入数据之前需要先将拥有表的“外键约束”禁用,否则导入数据库后表无法查看报SQL0668N错误

查看那些表拥有外键约束

[db2inst1]# db2 "select substr(table_name,1,30),substr(CONSTRAINT_NAME,1,30),CONSTRAINT_TYPE from sysibm.TABLE_CONSTRAINTS where CONSTRAINT_TYPE like '%FOREIGN KEY%'"

禁用外键约束

[db2inst1]# db2 "alter table TABNAME alter foreign key FK_NAME not enforced"

6. 目标端导入数据

[db2inst1]# db2move DBNAME load

7. 重新启用表的外键约束

[db2inst1]# db2 "alter table TABNAME alter foreign key FK_NAME enforced"

 8. 根据需求调整“源端”与“目标端”参数配置

[db2inst1]# db2set -all
[db2inst1]# db2 get dbm cfg
[db2inst1]# db2 get db cfg for DBNAME

 9. 比对“源端”与“目标端”数据库对象个数

[db2inst1]# db2 "select count(*) from SYSCAT.TABLES where TABSCHEMA not like 'SYS%'"
[db2inst1]# db2 "select COUNT(*) from SYSCAT.INDEXES where INDSCHEMA not like 'SYS%'"
[db2inst1]# db2 "select COUNT(*) from SYSCAT.VIEWS where VIEWSCHEMA not like 'SYS%'"
[db2inst1]# db2 "select count(*) from SYSCAT.TRIGGERS where TRIGSCHEMA not like 'SYS%'"
[db2inst1]# db2 "select count(*) from SYSCAT.ROUTINES where ROUTINESCHEMA not like 'SYS%'"
[db2inst1]# db2 "select count(*) from SYSCAT.FUNCTIONS where FUNCSCHEMA not like 'SYS%'"
[db2inst1]# db2 "select count(*) from SYSCAT.PROCEDURES where PROCSCHEMA not like 'SYS%'"

 

相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 记一次.NET内存居高不下排查解决与启示
点击右上角即可分享
微信分享提示