db2move,db2look使用及所遇到问题详解

先看我们最关心的问题

db2move用于快速导出/导入整个数据库的数据,操作过程:

1.数据导出: db2move DBNAME export -u userName -p password
2.数据导入: db2move DBNAME import -u userName -p password

注意:在linux下导入导出数据时要注意db2codepage的一致性,1386表示GBK,1208表示UTF-8还有注意该数据库账户(如db2inst1)是否具有待导入文件的读写权限

遇到上述问题,参见我的博文:http://blog.csdn.net/fuwencaho/article/details/22539727

或许还会遇上这样的问题

* IMPORT:  table "CRMUSER "."IFS_CUSTGROUP_DG"   
***ERROR -3015.  Check message file tab215.msg!
***  SQLCODE:  -3015  -  SQLSTATE:       
***  SQL3015N  An SQL error "-1218" occurred during processing.

db2inst1@infosrvr:/backup/db2/lscrm/lscrmdb> more tab215.msg
SQL3104N  The Export utility is beginning to export data to file "tab215.ixf".

SQL3105N  The Export utility has finished exporting "0" rows.

SQL3150N  The H record in the PC/IXF file has product "DB2    02.00", date 
"20140327", and time "221001".

SQL3153N  The T record in the PC/IXF file has name "tab215.ixf", qualifier "", 
and source "            ".

SQL3109N  The utility is beginning to load data from file "tab215.ixf".

SQL3110N  The utility has completed processing.  "0" rows were read from the 
input file.

SQL3221W  ...Begin COMMIT WORK. Input Record Count = "0".

SQL3222W  ...COMMIT of any database changes was successful.

SQL3149N  "0" rows were processed from the input file.  "0" rows were 
successfully inserted into the table.  "0" rows were rejected.

SQL3150N  The H record in the PC/IXF file has product "DB2    02.00", date 
"20140327", and time "221001".

SQL3153N  The T record in the PC/IXF file has name "tab215.ixf", qualifier "", 
and source "            ".

SQL3015N  An SQL error "-1218" occurred during processing.

SQL1218N  There are no pages currently available in bufferpool "4096".  
SQLSTATE=57011

SQL3015N  An SQL error "-1218" occurred during processing.

SQL1218N  There are no pages currently available in bufferpool "4096".  
SQLSTATE=57011

SQL3110N  The utility has completed processing.  "0" rows were read from the 
input file.

db2inst1@infosrvr:/backup/db2/lscrm/lscrmdb> more tab294
tab294: No such file or directory
db2inst1@infosrvr:/backup/db2/lscrm/lscrmdb> more tab294.
tab294.ixf  tab294.msg  
db2inst1@infosrvr:/backup/db2/lscrm/lscrmdb> more tab294.msg 
SQL3104N  The Export utility is beginning to export data to file "tab294.ixf".

SQL3105N  The Export utility has finished exporting "800537" rows.

SQL3150N  The H record in the PC/IXF file has product "DB2    02.00", date 
"20140327", and time "221059".

SQL3153N  The T record in the PC/IXF file has name "tab294.ixf", qualifier "", 
and source "            ".

SQL3109N  The utility is beginning to load data from file "tab294.ixf".

SQL3186W  Data was not loaded into the database, because the log was full or 
the lock space was exhausted.  SQLCODE "-964" was returned.  A commit will be 
attempted and the operation will continue if the commit is successful.

SQL0964C  The transaction log for the database is full.  SQLSTATE=57011

SQL3221W  ...Begin COMMIT WORK. Input Record Count = "161339".

SQL3222W  ...COMMIT of any database changes was successful.

SQL3186W  Data was not loaded into the database, because the log was full or 
the lock space was exhausted.  SQLCODE "-964" was returned.  A commit will be 
attempted and the operation will continue if the commit is successful.

SQL0964C  The transaction log for the database is full.  SQLSTATE=57011

SQL3221W  ...Begin COMMIT WORK. Input Record Count = "325740".

SQL3222W  ...COMMIT of any database changes was successful.

SQL3186W  Data was not loaded into the database, because the log was full or 
the lock space was exhausted.  SQLCODE "-964" was returned.  A commit will be 
attempted and the operation will continue if the commit is successful.

SQL0964C  The transaction log for the database is full.  SQLSTATE=57011

SQL3221W  ...Begin COMMIT WORK. Input Record Count = "490421".

SQL3222W  ...COMMIT of any database changes was successful.

SQL3186W  Data was not loaded into the database, because the log was full or 
the lock space was exhausted.  SQLCODE "-964" was returned.  A commit will be 
attempted and the operation will continue if the commit is successful.

SQL0964C  The transaction log for the database is full.  SQLSTATE=57011

SQL3221W  ...Begin COMMIT WORK. Input Record Count = "640736".

SQL3222W  ...COMMIT of any database changes was successful.

SQL3005N  Processing was interrupted.

SQL3110N  The utility has completed processing.  "771285" rows were read from 
the input file.

SQL3150N  The H record in the PC/IXF file has product "DB2    02.00", date 
"20140327", and time "221059".

SQL3153N  The T record in the PC/IXF file has name "tab294.ixf", qualifier "", 
and source "            ".

SQL3109N  The utility is beginning to load data from file "tab294.ixf".

SQL3306N  An SQL error "-1218" occurred while inserting a row into the table.

SQL1218N  There are no pages currently available in bufferpool "4096".  
SQLSTATE=57011

SQL3110N  The utility has completed processing.  "85812" rows were read from 
the input file.

好像是说缓冲区太小之类,修改缓冲区,但是我又想修改数据库存放的表空间!我本来想这样操作

创建数据库:create database crm

创建缓冲区:CREATE BUFFERPOOL LSSPOOL  IMMEDIATE  ALL DBPARTITIONNUMS  SIZE 131072  NUMBLOCKPAGES 0  PAGESIZE 32 K

创建表空间:

CREATE LARGE TABLESPACE LSDBSPACE1  IN DATABASE PARTITION GROUP IBMDEFAULTGROUP  PAGESIZE 32K  MANAGED BY DATABASE USING (File '/crm/db2inst1/db2/NODE0000/CRMDB/T0000002/C0000001.LRG' 168304)EXTENTSIZE 32 PREFETCHSIZE AUTOMATIC  BUFFERPOOL LSSPOOL  OVERHEAD 7.50  TRANSFERRATE 0.06  DROPPED TABLE RECOVERY ON


但是失败报错:

DB21034E  The command was processed as an SQL statement because it was not a 
valid Command Line Processor command.  During SQL processing it returned:
SQL0970N  The system attempted to write to a read-only file.  SQLSTATE=55009

我的解决方案:

先mkdir crm

infosrvr:/ # chmod -R 777 crm/

表空间创建成功

导入数据:db2move DBNAME import -u userName -p password

还是遇到上面的表空间大小问题,难道新建的表空间没用用上,查一下发现db2使用默认的表空间userspaces;

list tablespaces show detail 发现新表空间果然没有使用,

所以又引发了一个问题“

db2move xxx import的时候,怎么能够指定import进来的表的表空间?

Google发现

db2move只能把数据导到已有数据库的表中去,不能指定表空间。
表空间是在建表时指定的。
一般先用db2look导出数据库结构,然后用db2move导数据。

不甘心,看一下db2move help命令

db2inst1@infosrvr:~> db2move -help

Application code page not determined, using ANSI codepage 1208

--------db2move - database movement tool--------

 Usage: "db2move <dbname> <action> [options]"

  <dbname> is the name of the database.

  <action> is one of:
     EXPORT - Export all tables that meet the filtering criteria in [options]
              (If no [options] specified, export all tables).
              Internal staging information is stored in file 'db2move.lst'.
              Messages are stored in 'EXPORT.msg'.

     IMPORT - Import all tables listed in the staging file 'db2move.lst'.
              Messages are stored in 'IMPORT.msg'..
              Use the -io option for IMPORT specific actions.

     LOAD   - Load all tables listed in the staging file 'db2move.lst'.
              Messages are stored in 'LOAD.msg'.
              Use the -lo option for LOAD specific actions.

     COPY   - Duplicate a schema(s) into a target database.
              Use the -sn option to specify one or more schemas.
              See the -co option for COPY specific options.
              Use the -tn or -tf option to filter tables in LOAD_ONLY mode.
              Messages are stored in 'COPY.<timestamp>.msg'
              Error only messages in 'COPY.<timestamp>.err'
              Load messages in 'LOADTABLE.<timestamp>.msg'
              List of tables that failed Load in 'LOADTABLE.<timestamp>.err'


  [options] are one or more of:

    Option      Description                  Use for   Notes              
                                             Action                       
  ------------------------------------------------------------------------
  -tc <value>  Table Definers. Filter on     EXPORT   Comma seperated list,
                SYSCAT.TABLES.DEFINER                 Wildcard (*) allowed.

  -tn <value>  Table Names. Filter on        EXPORT   Comma seperated list,
                SYSCAT.TABLES.TABNAME        COPY     Wildcard (*) allowed for
                                                      EXPORT (not COPY).

  -sn <value>  Schema Names. Filter on       EXPORT,  Comma seperated list,
                SYSCAT.TABLES.TABSCHEMA      COPY     Wildcard (*) allowed for
                                                      EXPORT (not COPY).

  -ts <value>  Tablespace Names. Filter on   EXPORT   Comma seperated list,
                SYSCAT.TABLES.TBSPACE                 Wildcard (*) allowed.

  -tf <file>   Fully qualified list of       EXPORT   one table per line,like:
                table names in <file>        COPY      "MYSCHEMA1"."TAB1"
                                                       "MY SCHEMA2"."TAB2"

  -aw          Allow warnings                EXPORT   Don't disclude tables
                                                      that encounter warnings.

  -io <value>  IMPORT specific actions.      IMPORT   One of: INSERT,
               Default is REPLACE_CREATE               INSERT_UPDATE, REPLACE,
               (see docs for limitations               CREATE, REPLACE_CREATE
                of Import create function)

  -lo <value>  LOAD specific options.        LOAD     One of: INSERT,
                Default is INSERT                      REPLACE

  -l <path>    Path to lobfiles.             EXPORT,  Comma seperated list,
                Default is cwd               IMPORT,  no space characters
                                             LOAD

  -u <value>   Userid to connect to db.      ALL
                Default is current user

  -p <value>   Password to connect to db.    ALL

  -co <opt>    COPY specific options.        COPY     See options listed below.

      TARGET_DB <dbname> [USER <userid> [USING <passwd>]
         This mandatory option specifies the target database (and optional
         user/passwd) where the schema(s) will be created. (Default
         user/passwd are current user/passwd).
      MODE <value>
         The mode is one of DDL_AND_LOAD (default), DDL_ONLY, or LOAD_ONLY.
      SCHEMA_MAP <value>
         To rename the schema on the target db. For example, to rename schema
         'srcsch1' to 'tgtsch1', and schema 'srcsch2' to 'tgtsch2', use:
         "((srcsch1,tgtsch1), (scrsch2,tgtsch2))".
      TABLESPACE_MAP <value>
         To override tablespaces on the target db. For example, to
         recreate all tables that reside in TS1 on the source db, into TS2 on
         the target db, and all other tablespaces to use the default tablespace
         on the target, use: "((TS1,TS2), SYS_ANY)".
      NONRECOVERABLE
         To override the default Load recoverability action COPY-NO, to
         NONRECOVERABLE.
      OWNER <owner-name>
         To override the owner of each new object created on the target db.


Examples:
  1) Use db2move to Export all tables:
      >db2move dbname EXPORT
  2) Use db2move to Export all tables, filtering on table-name with 'mytab*'
     and table-definer with 'USER1', and lobs in /bigfs/mydir/:
      >db2move dbname EXPORT -tn mytab* -tc USER1 -l /bigfs/mydir/
  3) Use db2move to Import (recreate and repopulate) all previously exported
     tables:
      >db2move dbname IMPORT
  4) Use db2move to Load (repopulate) all previously exported tables:
      >db2move dbname LOAD
  5) Use db2move to Load (append) all previously exported tables, where
     lobfiles reside in /bigfs/mydir:
      >db2move dbname LOAD -lo INSERT -l /bigfs/mydir
  6) Use db2move to duplicate schema 'schema1' from source database 'dbsrc'
     to target database 'dbtgt':
      >db2move dbsrc COPY -sn schema1 -co TARGET_DB dbtgt
        USER myuser1 USING mypass1
  7) Use db2move to duplicate schema 'schema1' from source database 'dbsrc'
     to target database 'dbtgt', rename the schema to 'newschema1' on the 
     target, and map source tablespace 'ts1' to 'ts2' on the target:
      >db2move dbsrc COPY -sn schema1 -co TARGET_DB dbtgt
        USER myuser1 USING mypass1 SCHEMA_MAP ((schema1,newschema1))
        TABLESPACE_MAP ((ts1,ts2), SYS_ANY))

For more information, please see the DB2 documentation.



End time:  Sun Mar 30 01:04:43 2014



可以看到可以指定表空间,但是只能在export的时候指定,难道真的是没有办法使用我们自己新建的表空间嘛????

有人说:默认的表空间不能更改,但可以删除重建!!!!!!!!!

这是真的吗??????????????




有谁知道一个用户的默认表空间在那里可以察看,还有如何修改。另外,oracle中用户名和模式名一般是一样的。db2中的用户管理和模式好像是分开的,那么一个用户创建一个表,会默认在那个模式下呢?这些信息应该在那察看和如何修改呢?


别人的方案:
用户默认的tablespace均为SYSTEM MANAGED TABLESPACE,分别是:

REGULAR TABLESPACE ---- USERAPACE1
SYSTEM CATALOG TABLESPACE  ---- SYSCATSPACE
SYSTEM TEMPORARY TABLE SPACE ------- TEMPSPACE1

如要修改,则或者在建database的时候指明,如:
CREATE DATABASE TEMP 
          CATALOG TABLESPACE
                 MANAGED BY DATABASE USING
                            (FILE 'C:\DATABASE\TEMP\CATALOG.DAT',2000
                            ,FILE 'D:\DATABASE\TEMP\CATALOG.DAT',2000)
           TEMPORARY TABLESPACR
                  MANAGED BY SYSTEM USING
                            ('C:\TEMPTS' , 'D:\TEMPTS' )
           USER TABLESPACE
                  MANAGED BY DATABASE USING
                           (DEVICE '\\.\E:' 8001)



或者通过:RESTORE ....... REDIRECT 重新指定tablespace



方案二:重建用户默认表空间的问题

Drop TABLESPACE USERSPACE1;

 

CREATE TABLESPACE USERSPACE1
  IN DATABASE PARTITION GROUP 
IBMDEFAULTGROUP
  PAGESIZE 
16K
  MANAGED BY SYSTEM 
  USING
   
('/dw/edwdata/userspace1'
   
)
  EXTENTSIZE 
32
  PREFETCHSIZE 
32
  BUFFERPOOL 
BP16
  OVERHEAD 
24.10
  TRANSFERRATE 
0.90
  DROPPED TABLE RECOVERY OFF
;



http://ssqmeng.iteye.com/blog/803595

http://blog.csdn.net/xwnxwn/article/details/7097468



你可能感兴趣的:(db2,db2look,db2move)