设为首页 收藏本站
查看: 1458|回复: 0

[经验分享] DB2数据迁移用法

[复制链接]

尚未签到

发表于 2016-11-13 11:42:42 | 显示全部楼层 |阅读模式
参看: http://www.ibm.com/developerworks/cn/education/data/db2-cert7315/section6.html 和 http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0712xiam/index.html?ca=drs
The below is how to do the db2 data migration.
(1).Export source data from source DB
     db2move <database_name> export -sn <database_schema> -u <DBA> -p <DBA_PASSWORD> > <logFile>
For example:
     db2move GEHGAL export -sn GEH_ADMIN -u GEH_ADMIN -p GEH_ADMIN > mv.log
If you want to export the db DDL schema from source DB, you should use the below db2 commands:
db2look -d GEHGAL -e -o ddlfile -i GEH_ADMIN -w GEH_ADMIN
or
db2look -d GEHGAL -u GEH_ADMIN -e -o alltables.sql

(2).Create a 32k normal or large tablespace
db2 CREATE LARGE TABLESPACE LARGEGEHGAL32 PAGESIZE 32 K MANAGED BY DATABASE USING (FILE 'C:\DB2\NODE0000\SQL00001\largegehgal32' 20000) BUFFERPOOL IBMDEFAULT32K
(3).Create the db2 user that should be same name as exported <database_schema> that is from source DB in target DB2 database, assign the 32k tablespace to the user, and delete the other tablespaces
(4).Code page from target DB should be same as the code page of source DB. You should use the following command to check:
db2 get db cfg
If they are different, change the code page in target DB, use the following command:
      db2set db2codepage=1252 (1252 is the page code of source DB)
db2 terminate
db2 terminate command must be executed(注意一定要进行terminate)
(5).Create a 16k or 32k temporary tablespace. It will be used when you view the Project Exception List from deployed GEH GUI
DB2 CREATE TEMPORARY TABLESPACE gehgalsystemtmp32 IN DATABASE PARTITION GROUP IBMTEMPGROUP PAGESIZE 32K MANAGED BY SYSTEM USING ('C:\DB2\NODE0000\SQL00001\gehgalsystemtmp32') EXTENTSIZE 32 PREFETCHSIZE 16 BUFFERPOOL IBMDEFAULT32K
(6).Import the data into the target DB
db2move <database_name> import -io create -u <DBA> -p <DBA_PASSWORD> > <logFile>
For example:
db2move GEHGAL import -io create -u GEH_MIGRATION -p Gal@pass > imp.log
Check the imp.log whether the import operation is successful.
If the table schema has been created/existed in target DB, so you can use the following command:
db2move GEHGAL import -io INSERT_UPDATE -u GEH_MIGRATION -p Gal@pass > imp.log

(7).If the export operation is successful, and you will find some tables in userspace1 tablespace, and the other tables in LARGEGEHGAL32 tablespace
(8).If there are some procedures in your db schema, you should execute the procedures that will not be imported into target database
(9).You should change the tables that have identify column if you want to store new messages in the target DB. The below is the commands that reset the identify value of EXCEPTION_MESSAGE table.
select max(EXCEPTION_MESSAGE_ID) from EXCEPTION_MESSAGE
$nextMessageId = max(EXCEPTION_MESSAGE_ID) + 1
alter table EXCEPTION_MESSAGE alter column EXCEPTION_MESSAGE_ID restart with $nextMessageId

import usage:
db2move <database-name> <action> [<option> <value>]
首先,您必须指定数据库名(想要移动的表所在的数据库)和要执行的操作(export和import或load)。然后指定一个选项来定义操作的范围。例如,可以将一个操作限制在特定的表(-tn)、表空间(-ts)、表创建者(-tc)或模式名(-sn)范围内。指定表、表空间或表的创建者的一个子集只对export操作有效。如果指定多个值,就必须使用逗号将其分隔开;在值列表项之间不允许有空格。可以指定的项最多为10个。
另外,也可以指定-tf选项,此时要使用一个文件名作为参数,其中列出了要导出的表名;在该文件中,每行只能列出一个完整的表名。您还可以指定以下内容:
-io import-option   
指定DB2的import工具可以运行的一种模式。有效的选项有:CREATE、INSERT、INSERT_UPDATE、REPLACE和REPLACE_CREATE。缺省值为REPLACE_CREATE。参看: http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/core/r0008304.htm
-lo load-option   
指定DB2的load工具可以运行的一种模式。有效的选项有:INSERT和REPLACE。缺省值为INSERT。
-l lobpaths   
指定要创建或查找的LOB文件的位置。必须指定一个或多个绝对路径名。如果指定了多个绝对路径,就必须使用逗号将其分隔开;值之间不允许有空格。缺省值是当前目录。   
-u userid   
指定一个用户ID,该工具可以使用这个用户ID登录到远程系统上。   
-p password   
指定对该用户进行认证的密码;该工具需要使用一个有效的用户ID和密码登录到远程系统上。
db2codepage 设置
1、db2 变量查看
db2set -all
(connect to dbanme ) get db cfg
db2pd -osinfo

2、db2c变量的设置用命令
db2set 变量=value
可以参考一下:
客户端:
db2codepage=1386(简体中文)
db2country=86(中国)
db2comm=tcpip
服务器端:
db2codepage=1386(简体中文)
db2country=86(中国)
db2comm=tcpip
一定要把缺省的db2codepage=819改为数据库的代码页设置

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-299692-1-1.html 上篇帖子: DB2中like使用 locate 下篇帖子: DB2数据导出工具
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表