`
guoyanxi
  • 浏览: 275690 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

migrate from win to linux(简单版)

    博客分类:
  • db2
阅读更多
本文讲述最简单的从windows到linux的db2迁移
1.跳过实例、数据库等参数设置
2.数据库版本版本基本相同
3.使用简单的sample数据库

马上有个重要的项目就是从windows到AIX,做点小准备,后续的工作还有很多。

原数据库:
OS:windows xp
DB2: db2 9.7
database name:sample

目标数据库:
OS:RHEL 5
DB2: db2 9.7
database name:sample

首先导出原数据库数据和数据库结构ddl
--建立测试表
C:\DOCUME~1\ADMINI~1\db2move>db2 describe table aaa

                                Data type                     Column
Column name                     schema    Data type name      Length     Scale N
ulls
------------------------------- --------- ------------------- ---------- ----- -
-----
AAA                             SYSIBM    INTEGER                      4     0 Y
es

  1 record(s) selected.

C:\DOCUME~1\ADMINI~1\db2move>db2 "select * from aaa"

AAA
-----------
        123

  1 record(s) selected.

--使用db2move导出数据
C:\DOCUME~1\ADMINI~1\db2move>db2move sample export -u inst00 -p ibm2blue

Application code page not determined, using ANSI codepage 1252

*****  DB2MOVE  *****

Action:  EXPORT

Start time:  Tue May 24 03:42:45 2011


Connecting to database SAMPLE ... successful!  Server : DB2 Common Server V9.7.0


EXPORT:      1 rows from table "ADMINISTRATOR"."AAA"
EXPORT:     18 rows from table "INST00  "."ACT"
EXPORT:      0 rows from table "INST00  "."CATALOG"
EXPORT:      5 rows from table "INST00  "."CL_SCHED"
EXPORT:      6 rows from table "INST00  "."CUSTOMER"
EXPORT:     14 rows from table "INST00  "."DEPARTMENT"
EXPORT:     42 rows from table "INST00  "."EMPLOYEE"
EXPORT:  10000 rows from table "INST00  "."EMPMDC"
EXPORT:     73 rows from table "INST00  "."EMPPROJACT"
EXPORT:      8 rows from table "INST00  "."EMP_PHOTO"
EXPORT:      8 rows from table "INST00  "."EMP_RESUME"
EXPORT:    157 rows from table "SYSTOOLS"."HMON_ATM_INFO"
EXPORT:      0 rows from table "SYSTOOLS"."HMON_COLLECTION"
EXPORT:      4 rows from table "INST00  "."INVENTORY"
EXPORT:      3 rows from table "INST00  "."IN_TRAY"
EXPORT:      8 rows from table "INST00  "."ORG"
EXPORT:      5 rows from table "SYSTOOLS"."POLICY"
EXPORT:      4 rows from table "INST00  "."PRODUCT"
EXPORT:      2 rows from table "INST00  "."PRODUCTSUPPLIER"
EXPORT:     65 rows from table "INST00  "."PROJACT"
EXPORT:     20 rows from table "INST00  "."PROJECT"
EXPORT:      6 rows from table "INST00  "."PURCHASEORDER"
EXPORT:     41 rows from table "INST00  "."SALES"
EXPORT:     35 rows from table "INST00  "."STAFF"
EXPORT:     35 rows from table "INST00  "."STAFFG"
EXPORT:      2 rows from table "INST00  "."SUPPLIERS"

Disconnecting from database ... successful!

End time:  Tue May 24 03:42:48 2011

--看到每个表默认导出到一个ixf文件当中
C:\DOCUME~1\ADMINI~1\db2move>dir
 Volume in drive C has no label.
 Volume Serial Number is 58AE-B492

 Directory of C:\DOCUME~1\ADMINI~1\db2move

05/24/2011  03:42 AM    <DIR>          .
05/24/2011  03:42 AM    <DIR>          ..
05/24/2011  03:42 AM             1,158 db2move.lst
05/24/2011  03:42 AM             1,669 EXPORT.out
05/24/2011  03:42 AM             2,599 tab1.ixf
05/24/2011  03:42 AM               145 tab1.msg
05/24/2011  03:42 AM             5,926 tab10.ixf
05/24/2011  03:42 AM               146 tab10.msg
05/24/2011  03:42 AM           387,034 tab10a.001.lob
05/24/2011  03:42 AM             5,909 tab11.ixf
05/24/2011  03:42 AM               146 tab11.msg
05/24/2011  03:42 AM            15,396 tab11a.001.lob
05/24/2011  03:42 AM           105,147 tab12.ixf
05/24/2011  03:42 AM               148 tab12.msg
05/24/2011  03:42 AM            10,722 tab13.ixf
05/24/2011  03:42 AM               146 tab13.msg
05/24/2011  03:42 AM             5,583 tab14.ixf
05/24/2011  03:42 AM               146 tab14.msg
05/24/2011  03:42 AM             6,769 tab15.ixf
05/24/2011  03:42 AM               146 tab15.msg
05/24/2011  03:42 AM             6,602 tab16.ixf
05/24/2011  03:42 AM               146 tab16.msg
05/24/2011  03:42 AM             8,019 tab17.ixf
05/24/2011  03:42 AM               146 tab17.msg
05/24/2011  03:42 AM             5,986 tab17a.001.lob
05/24/2011  03:42 AM            12,034 tab18.ixf
05/24/2011  03:42 AM               358 tab18.msg
05/24/2011  03:42 AM             1,073 tab18a.001.xml
05/24/2011  03:42 AM             3,519 tab19.ixf
05/24/2011  03:42 AM               146 tab19.msg
05/24/2011  03:42 AM             7,208 tab2.ixf
05/24/2011  03:42 AM               146 tab2.msg
05/24/2011  03:42 AM             9,731 tab20.ixf
05/24/2011  03:42 AM               147 tab20.msg
05/24/2011  03:42 AM            12,710 tab21.ixf
05/24/2011  03:42 AM               147 tab21.msg
05/24/2011  03:42 AM            12,424 tab22.ixf
05/24/2011  03:42 AM               358 tab22.msg
05/24/2011  03:42 AM             2,464 tab22a.001.xml
05/24/2011  03:42 AM             8,079 tab23.ixf
05/24/2011  03:42 AM               147 tab23.msg
05/24/2011  03:42 AM             9,763 tab24.ixf
05/24/2011  03:42 AM               147 tab24.msg
05/24/2011  03:42 AM            10,312 tab25.ixf
05/24/2011  03:42 AM               147 tab25.msg
05/24/2011  03:42 AM             4,870 tab26.ixf
05/24/2011  03:42 AM               358 tab26.msg
05/24/2011  03:42 AM               562 tab26a.001.xml
05/24/2011  03:42 AM             4,717 tab3.ixf
05/24/2011  03:42 AM               357 tab3.msg
05/24/2011  03:42 AM             5,448 tab4.ixf
05/24/2011  03:42 AM               145 tab4.msg
05/24/2011  03:42 AM            10,480 tab5.ixf
05/24/2011  03:42 AM               357 tab5.msg
05/24/2011  03:42 AM             2,087 tab5a.001.xml
05/24/2011  03:42 AM            10,243 tab6.ixf
05/24/2011  03:42 AM               146 tab6.msg
05/24/2011  03:42 AM            21,424 tab7.ixf
05/24/2011  03:42 AM               146 tab7.msg
05/24/2011  03:42 AM           324,507 tab8.ixf
05/24/2011  03:42 AM               361 tab8.msg
05/24/2011  03:42 AM            11,130 tab9.ixf
05/24/2011  03:42 AM               146 tab9.msg
              61 File(s)      1,058,378 bytes
               2 Dir(s)  35,149,488,128 bytes free

--使用db2look导出ddl
C:\DOCUME~1\ADMINI~1\db2move>db2look -d sample -e -a -o db2look.sql
-- Generate statistics for all creators
-- Creating DDL for table(s)
-- Output is sent to file: db2look.sql

--查看db2look.sql的文件头
-- This CLP file was created using DB2LOOK Version "9.7" 
-- Timestamp: 5/24/2011 3:15:52 AM
-- Database Name: SAMPLE         
-- Database Manager Version: DB2/NT Version 9.7.0          
-- Database Codepage: 1208
-- Database Collating Sequence is: IDENTITY


CONNECT TO SAMPLE;


---------------------------------
-- DDL Statements for Sequences
---------------------------------


CREATE SEQUENCE "INST00  "."SAMPSEQUENCE" AS BIGINT
	MINVALUE 1 MAXVALUE 9223372036854775807
	START WITH 1 INCREMENT BY 1
	CACHE 20 NO CYCLE NO ORDER;


把以上所有相关文件传到linux之后,开始导入数据库结构和数据
--使用db2look.sql ddl文件导入数据库结构
[db2inst2@localhost tmp]$ db2 -tvf db2look.sql;

DB21007E  End of file reached while reading the command.
--报出DB21007E错误,这个是本次实验当中唯一一个问题
--原因在于
[db2inst2@localhost tmp]$ file db2look.sql 
db2look.sql: ASCII English text, with CRLF line terminators
--使用dos2unix进行格式转换
[db2inst2@localhost tmp]$ dos2unix db2look.sql 
dos2unix: converting file db2look.sql to UNIX format ...
dos2unix: problems renaming './d2utmpMZpuAR' to 'db2look.sql'
          output file remains in './d2utmpMZpuAR'
dos2unix: problems converting file db2look.sql

--再检查格式,ok
[db2inst2@localhost tmp]$ file d2utmpMZpuAR
d2utmpMZpuAR: ASCII English text

--导入ddl
[db2inst2@localhost tmp]$ db2 -tvf ./d2utmpMZpuAR
CONNECT TO SAMPLE

   Database Connection Information

 Database server        = DB2/LINUX 9.7.2
 SQL authorization ID   = DB2INST2
 Local database alias   = SAMPLE


CREATE SEQUENCE "INST00  "."SAMPSEQUENCE" AS BIGINT MINVALUE 1 MAXVALUE 9223372036854775807 START WITH 1 INCREMENT BY 1 CACHE 20 NO CYCLE NO ORDER
DB20000I  The SQL command completed successfully.

--成功了,检查一下测试表
[db2inst2@localhost ~]$ db2 describe table administrator.aaa

                                Data type                     Column
Column name                     schema    Data type name      Length     Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
AAA                             SYSIBM    INTEGER                      4     0 Yes   

  1 record(s) selected.


--现在是没有数据的
[db2inst2@localhost ~]$ db2 "select * from administrator.aaa"

AAA        
-----------

  0 record(s) selected.

--使用db2move load导入ixf文件
[db2inst2@localhost db2move]$ db2move sample load

Application code page not determined, using ANSI codepage 1208

*****  DB2MOVE  *****

Action:  LOAD

Start time:  Sun Apr 24 08:07:57 2011


Connecting to database SAMPLE ... successful!  Server : DB2 Common Server V9.7.2

Binding package automatically ... /home/db2inst2/sqllib/bnd/db2common.bnd ... successful!

Binding package automatically ... /home/db2inst2/sqllib/bnd/db2move.bnd ... successful!

* LOAD:  table "ADMINISTRATOR"."AAA"           
  -Rows read:          1
  -Loaded:             1
  -Rejected:           0
  -Deleted:            0
  -Committed:          1

--再检查测试表,有数据了
[db2inst2@localhost ~]$ db2 "select * from administrator.aaa"

AAA        
-----------
        123

  1 record(s) selected.

--到此为止,基本完成



小结:
1.总的来说,这个是标准的跨平台迁移,相对问题不多,如file format这些小问题更多是OS层面的基本功
2.真正的迁移难点在于在新平台当中参数的设置、表空间、容器、日志等设置,稍后再做一个更全面的






分享到:
评论

相关推荐

    Migrate from Oracle 9i RAC to 10g RAC

    #### 标题解析:Migrate from Oracle 9i RAC to 10g RAC 标题明确了本文档的主要内容是关于如何从Oracle 9i Real Application Clusters (RAC) 数据库迁移至Oracle 10g RAC数据库的过程。这涉及到数据库架构、软件...

    Paragon.Migrate.OS.to.SSD.v4.0.x64.HAPPY.NEW.YEAR-DVT.zip

    标题中的“Paragon Migrate OS to SSD v4.0 x64”是一款专门用于操作系统迁移的软件工具,由Paragon Software公司开发。该版本号“v4.0”表明这是该软件的第四次主要更新,而“x64”则表示它支持64位操作系统。后缀...

    migrate from on-premises to Azure SQL Database Managed Instance

    migrate from on-premises to Azure SQL Database Managed Instance

    Upgrade, Migrate & Consolidate to Oracle Database 12c

    Upgrade, Migrate & Consolidate to Oracle Database 12c: Strategies, General Preparation Steps, Upgrade & Migration Cases; Fallback Strategies; New Features in Oracle 12c; Performance Management.

    3364574-2_1645_How to Migrate from On-premises to Office 365.pdf

    How to Migrate from On-premises to Office 365, https://docs.microsoft.com/zh-cn/sharepointmigration/introducing-the-sharepoint-migration-tool

    Migrate ARM Compiler 5 to ARM Compiler 6 中文翻译版

    Migrate ARM Compiler 5 to ARM Compiler 6 中文翻译版本

    jquery-migrate3.4版本

    《jQuery Migrate 3.4 版本详解》 jQuery Migrate 是一个插件,它的主要目的是帮助开发者平滑地过渡到较新版本的 jQuery,解决老版本代码在新版本中可能遇到的兼容性问题。在jQuery Migrate 3.4.0版本中,我们看到...

    jquery-migrate

    Migrate 有两个版本。jquery-migrate-1.4.1版本将帮助您将 1.9 之前的 jQuery 代码更新到 jQuery 1.9 到 3.0。 jquery-migrate-3.4.0版本将帮助您更新代码以在 jQuery 3.0 或更高版本上运行。 jQuery Migrate是应用...

    SAP S_4HANA Migration Cockpit - Migrate your Data to SAP S_4HANA.pdf

    SAP S_4HANA Migration Cockpit - Migrate your Data to SAP S_4HANA.pdf

    Nginx From Beginner to Pro(Apress,2016)

    Teaches you to start up Nginx and quickly take your expertise to a level where you can comfortably work with various aspects of the web ...Learn how and what to migrate from IIS & Apache web servers.

    Migrate from Box to Dropbox-crx插件

    【标题】:“Migrate from Box to Dropbox-crx插件”是一种专为用户设计的工具,旨在帮助他们方便地将数据从Box云存储平台迁移至Dropbox。这款扩展程序解决了用户在多个云服务之间同步和迁移数据时可能遇到的困扰,...

    A Guide for Migrating From Oracle to MySQL

    With the rapid growth of MySQL in the database market, many corporations, government agencies, educational institutions, and others have begun to migrate away from their expensive and proprietary ...

    jquery-migrate-3.0.0.zip

    &lt;script src="path/to/jquery-migrate-3.0.0.min.js"&gt; ``` 这样,当jQuery运行时,jQuery Migrate会自动检测并修复不兼容的问题。 需要注意的是,虽然jQuery Migrate可以暂时解决兼容性问题,但它并不推荐作为长期...

    How to Migrate Email to the Cloud-EN.pdf

    How to Migrate Email to the Cloud-EN.pdf

    How to Migrate Email to the Cloud-CN.pdf

    How to Migrate Email to the Cloud-CN.pdf

    Go-migrate-在Golang中的数据库迁移处理

    Go-migrate是一个强大的开源库,专为处理Golang应用的数据库迁移而设计。它支持多种主流数据库系统,包括MySQL、PostgreSQL、Cassandra和SQLite,这使得它成为一个灵活且跨平台的解决方案。 首先,让我们详细了解Go...

    jquery-migrate-3.0.1.js jar包

    使用jQuery Migrate 3.0.1.js非常简单,只需要在引入新的jQuery版本之后,再引入jQuery Migrate即可,通常是这样排列: ```html &lt;script src="path/to/jquery-3.x.x.js"&gt; &lt;script src="path/to/jquery-migrate-...

    jquery-migrate-3.0.0.js

    &lt;script src="path/to/jquery-migrate-3.0.0.js"&gt; ``` - **检查控制台**:运行后,开发者应在浏览器控制台看到Migrate发出的相关警告信息。 - **修复代码**:根据控制台的警告,找到并更新旧的jQuery代码段。 4...

    jquery-migrate-1.2.1.js文件

    **jQuery Migrate插件详解** `jquery-migrate-1.2.1.js` 文件是jQuery的一个辅助工具,它主要用于帮助开发者解决在升级到较新版本的jQuery时可能遇到的向后兼容性问题。这个插件的主要目的是为了警告开发者那些在新...

Global site tag (gtag.js) - Google Analytics