DB2 V9 Install Note


Install Note
1、如果许可证还没有过期 就直接按照顺序先删除DB 然后删除实例 最后卸载数据库,在此之前先导出数据。
2、如果已经过期的话 先调整系统时间 提前一个月 然后db2start 常识启动服务。
灰色字体 系统输出
蓝色字体 输入命令
红色字体 注释部分

Before Uninstall
1db2 list db directory 浏览数据库
-bash-3.1$ db2 list db directory

 System Database Directory

 Number of entries in the directory = 3

Database 1 entry:

 Database alias                       = SHIPMENT
 Database name                        = SHIPMENT
 Local database directory             = /usr/local/db2home/db2inst1
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

Database 2 entry:

 Database alias                       = GLOBALT
 Database name                        = GLOBALT
 Local database directory             = /usr/local/db2home/db2inst1
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

Database 3 entry:

 Database alias                       = SAMPLE
 Database name                        = SAMPLE @可有可无
 Local database directory             = /usr/local/db2home/db2inst1
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =


2、   Backup DDL.Script & DATA
@先停掉/etc/crontab中有关系统时间自动校正的任务
bash-3.1$ more /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
##31 * * * * root /usr/local/ntpd/bin/ntpdate 192.168.199.11
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
--准备备份用的目录
cd /usr/local/db2home
su db2inst1
mkdir 2011_11_22
mkdir 2011_11_22/SHIPMENT_DATA
mkdir 2011_11_22/GLOBALT_DATA

-- DDL 导出的SP会有缺失!!!使用客户端后期部署上去即可!!!
db2look -d SHIPMENT -e -l -i db2inst1 -w phxsha123 -o SHIPMENT_DDL_20111122.sql
--DATA EXTPORT
cd /usr/local/db2home/2011_11_22/SHIPMENT_DATA
db2move SHIPMENT EXPORT -tc db2inst1 -u db2inst1 -p phxsha123 -l /usr/local/db2home/2011_11_22/SHIPMENT_DATA

db2look -d GLOBALT -e -l -i db2inst1 -w phxsha123 -o GLOBALT_DDL_20111122.sql
db2look -d GLOBALT -i db2inst1 -w phxsha123 -e -l -o GLOBALT_DDL_2011_02_21.sql
cd /usr/local/db2home/2011_11_22/GLOBALT_DATA
db2move GLOBALT EXPORT -u db2inst1 -p phxsha123 -l /usr/local/db2home/2011_11_22/GLOBALT_DATA

Uninstall DB2 V9

--删除数据库
bash-3.1$ db2 drop db SHIPMENT
DB20000I  The DROP DATABASE command completed successfully.
bash-3.1$ db2 drop db GLOBALT
SQL1035N  The database is currently in use.  SQLSTATE=57019
bash-3.1$ db2 drop db GLOBALT
SQL1035N  The database is currently in use.  SQLSTATE=57019
@有错误 是因为还有Application在读取和操作数据库 断开应用连接后再删除
@或使用“db2 list application”先确认一下是否有Application再操作数据库
bash-3.1$ db2 force application all
DB20000I  The FORCE APPLICATION command completed successfully.
DB21024I  This command is asynchronous and may not be effective immediately.

bash-3.1$ db2 drop db GLOBALT
DB20000I  The DROP DATABASE command completed successfully.
bash-3.1$ db2 drop db SAMPLE
DB20000I  The DROP DATABASE command completed successfully.

--删除实例 @需要root权限
[root@global-tracking 2011_11_22]# cd /usr/local/db2V9/instance
[root@global-tracking instance]# ./db2ilist
db2inst1
[root@global-tracking instance]# ./db2idrop -f db2inst1
DBI1324W  Support of the -f command is deprecated. For
      more information, see the DB2 Information Center.


DB20000I  The FORCE APPLICATION command completed successfully.
DB21024I  This command is asynchronous and may not be effective immediately.

DBI1070I  Program db2idrop completed successfully.


--卸载 @需要root权限
[root@global-tracking instance]# cd /usr/local/db2V9/install/
[root@global-tracking install]#  ./db2_deinstall -a
DBI1016I  Program db2_deinstall is performing uninstallation. Please
      wait.


The execution completed successfully.

For more information see the DB2 uninstallation log at
"/tmp/db2_deinstall.log.727".
[root@global-tracking install]#

Install DB2 V9
1、   先同步系统时间 & 同时开启卸载前停掉的时间同步的Crontab任务
/usr/local/ntpd/bin/ntpdate 192.168.199.11
2、   安装服务端在 68上的/root目录中
档名:v9.7_linuxx64_server.tar.gz
解压缩后是 /root/server  -- @可以直接使用 无需再解压缩 但前提是安装的时候选择其他路径

[root@global-tracking ~]# cd server/
[root@global-tracking server]# ls -lah
total 104K
drwxr-xr-x  4 root root 4.0K Jun  1  2009 .
drwxr-x---  7 root root 4.0K Aug 23 10:47 ..
drwxr-xr-x  6 bin  bin  4.0K Jun  1  2009 db2
-r-xr-xr-x  1 bin  bin  5.2K Jun  1  2009 db2_deinstall
-r-xr-xr-x  1 bin  bin  5.1K Jun  1  2009 db2_install
-r-xr-xr-x  1 bin  bin  5.1K Jun  1  2009 db2ls
-r-xr-xr-x  1 bin  bin  5.1K Jun  1  2009 db2prereqcheck
-r-xr-xr-x  1 bin  bin  5.1K Jun  1  2009 db2setup
drwxr-xr-x 15 bin  bin  4.0K Jun  1  2009 doc
-r-xr-xr-x  1 bin  bin  5.1K Jun  1  2009 installFixPack

[root@global-tracking server]# ./db2_install

Default directory for installation of products - /opt/ibm/db2/V9.7

***********************************************************
Do you want to choose a different directory to install [yes/no] ?
yes     @问是否选择一个不同的目录安装 否则就安装到/root/server上了
Enter full path name for the install directory -

------------------------------------------------
/usr/local/db2V9      @填入一个安装路径,这个路径在上次卸载的时候已经删除掉了 可以直接使用。


Specify one of the following keywords to install DB2 products.

  ESE
  CONSV
  WSE
  EXP
  PE
  CLIENT
  RTCL

Enter "help" to redisplay product names.

Enter "quit" to exit.

***********************************************************
ESE               @选择ese 企业版



创建实例
/usr/local/db2V9/instance/db2icrt -a server -u db2fenc1 db2inst1
注册profile
[root@global-tracking server]# cd /usr/local/db2home/db2inst1/sqllib/
[root@global-tracking sqllib]# ./db2profile


创建数据库
bash-3.1$ db2start
11/22/2010 14:35:16     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.
bash-3.1$ db2
(c) Copyright IBM Corporation 1993,2007
Command Line Processor for DB2 Client 9.7.0

You can issue database manager commands and SQL statements from the command
prompt. For example:
    db2 => connect to sample
    db2 => bind sample.bnd

For general help, type: ?.
For command help, type: ? command, where command can be
the first few keywords of a database manager command. For example:
 ? CATALOG DATABASE for help on the CATALOG DATABASE command
 ? CATALOG          for help on all of the CATALOG commands.

To exit db2 interactive mode, type QUIT at the command prompt. Outside
interactive mode, all commands must be prefixed with 'db2'.
To list the current command option settings, type LIST COMMAND OPTIONS.

For more detailed help, refer to the Online Reference Manual.

db2 => CREATE DATABASE SHIPMENT USING CODESET UTF-8 TERRITORY US
DB20000I  The CREATE DATABASE command completed successfully.
db2 => CREATE DATABASE GLOBALT USING CODESET UTF-8 TERRITORY US
DB20000I  The CREATE DATABASE command completed successfully.
db2 => CREATE DATABASE SAMPLE USING CODESET UTF-8 TERRITORY US
DB20000I  The CREATE DATABASE command completed successfully.

@schema很重要  重构时DDL 和源数据export文件要注意修改。如果数据就是从本机导出来的就不存在这个问题。
@相对的schema有一定的权限。
bash-3.1$ db2 connect to GLOBALT

   Database Connection Information

 Database server        = DB2/LINUXX8664 9.7.0
 SQL authorization ID   = DB2INST1
 Local database alias   = GLOBALT

bash-3.1$ db2 grant dbadm on database to user dwdev
DB20000I  The SQL command completed successfully.

LOAD DATA
@ SHIPMENT部分
cd /usr/local/db2home/2011_11_22/
db2 connect to SHIPMENT
db2 -tvf SHIPMENT_DDL_20111122.sql 
cd /usr/local/db2home/2011_11_22/SHIPMENT_DATA
@ GLOBALT部分
cd /usr/local/db2home/2011_11_22/
db2 connect to GLOBALT
db2 -tvf GLOBALT_DDL_20111122.sql 
cd /usr/local/db2home/2011_11_22/GLOBALT_DATA
db2move GLOBALT import -u db2inst1 -p phxsha123  #尽量使用load
/*
If Error -à Pls look here!  
* IMPORT:  table "DWDEV   "."TB_SHIPMENT_MOVEMENT"
***ERROR -3201.  Check message file tab46.msg!
***  SQLCODE:  -3201  -  SQLSTATE:      
***  SQL3201N  The specified table cannot be replaced because another table is dependent on it.
@如果import出现以上错误 就将import命令更换为load
@db2move GLOBALT load -u db2inst1 -p phxsha123
#2011-2-23 Remark @Woody.xu & Joson.Chen
*/
配置jdbc type v4的连接
db2set DB2COMM=TCPIP

更新dbm & 配置连接权限
bash-3.1$ db2
(c) Copyright IBM Corporation 1993,2007
Command Line Processor for DB2 Client 9.7.0

You can issue database manager commands and SQL statements from the command
prompt. For example:
    db2 => connect to sample
    db2 => bind sample.bnd

For general help, type: ?.
For command help, type: ? command, where command can be
the first few keywords of a database manager command. For example:
 ? CATALOG DATABASE for help on the CATALOG DATABASE command
 ? CATALOG          for help on all of the CATALOG commands.

To exit db2 interactive mode, type QUIT at the command prompt. Outside
interactive mode, all commands must be prefixed with 'db2'.
To list the current command option settings, type LIST COMMAND OPTIONS.

For more detailed help, refer to the Online Reference Manual.

db2 => connect to SHIPMENT

   Database Connection Information

 Database server        = DB2/LINUXX8664 9.7.0
 SQL authorization ID   = DB2INST1
 Local database alias   = SHIPMENT
db2 => update dbm cfg using SVCENAME db2inst1
DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.
SQL1362W  One or more of the parameters submitted for immediate modification
were not changed dynamically. Client changes will not be effective until the
next time the application is started or the TERMINATE command has been issued.
Server changes will not be effective until the next DB2START command.
db2 => update dbm cfg using SVCENAME dwetl @此配置会覆盖之前的权限信息。
db2 => quit
db2 terminate
db2stop  
db2start


吸气 ~~ 吐气 ~~ 运气 ~~ 打完收工 ~~
By:Woody 2010-11-23

@PS:以上流程是在INNER环境中的192.168.103.68上完成的 如果是新安装的Server要多一些添加用户和组的步骤
@欲知详情:You can Google it.

评论

此博客中的热门博文

Kettle设计中 判断的基准和多数据流时的主键唯一性

9月的诚品书单[待修订]

引用 vista下.lnk快捷方式打开方式修复