Db2 卸载步骤(参考)

开始卸载

1.      删除所有数据库。

可以使用“控制中心”或drop database命令删除数据库。笔者卸载而未删除数据库,结果是重新安装后无法建立同名数据库。

若要显示所有已创建的数据库可以执行如下命令:

# db2 list db directory

 

删除数据库

# db2 drop database 数据库名

 

[db2inst1@gxmzd-test-db2 ~]$ db2 list dbdirectory

 

 System Database Directory

 

 Number of entries in the directory = 2

 

Database 1 entry:

 

 Database alias                       = GXMZDDB

 Database name                        = GXMZDDB

 Local database directory             = /home/db2inst1/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                       = GXMZD

 Database name                        = GXMZD

 Nodename                            = GXMZD

 Database release level               = d.00

 Comment                              =

 Directory entry type                 = Remote

 Catalog database partition number    = -1

 Alternate server hostname            =

 Alternate server port number         =

 

执行删除数据库动作

# db2 drop database + 数据库名称

[db2inst1@gxmzd-test-db2 ~]$ db2 dropdatabase

SQL0104N An unexpected token "END-OF-STATEMENT" was found following

"DATABASE".  Expected tokens may include:  "<identifier>".  SQLSTATE=42601

[db2inst1@gxmzd-test-db2 ~]$ db2 dropdatabase GXMZDDB

DB20000I The DROP DATABASE command completed successfully.

[db2inst1@gxmzd-test-db2 ~]$ db2 dropdatabase GXMZD

SQL1428N The application is already attached to "DB2INST1" while thecommand

issued requires an attachment to"GXMZD" for successful execution.

 

停止DB2管理服务器:

必须要停止DB2管理服务器才能在linux上卸载DB2

1.1.  作为DB2管理服务器所有者登陆。

1.2.  db2adminstop命令停止DB2管理服务器

 

[root@gxmzd-test-db2 home]# su dasusr1

[dasusr1@gxmzd-test-db2 home]$ db2adminstop

SQL4407W The DB2 Administration Server was stopped successfully.

 

 

停止DB2实例:

必须要停止DB2实例才能在linux上卸载DB2

1.3.  作为具有root用户权限的用户登陆。

1.4.  输入/opt/ibm/db2/V9.7/bin/db2ilist命令,获取系统上的所有DB2实例的名称。

1.5.  注销。

1.6.  作为想要停止的实例的所有者登陆。

1.7.  进入该用户的主目录下,运行脚本:. sqllib/db2profile

1.8.  输入db2 forceapplication all命令来停止所有数据库应用程序。

1.9.  输入db2stop命令来停止DB2数据库管理器。

1.10.         输入db2terminate来确认DB2数据库管理器已停止。

1.11.         对每一个要删除的实例重复以上步骤。

[db2inst1@gxmzd-test-db2 home]$/opt/ibm/db2/V9.7/bin/db2ilist

db2inst1

[db2inst1@gxmzd-test-db2 home]$ cd db2inst1

[db2inst1@gxmzd-test-db2 ~]$ ls

db2inst1 sqllib

[db2inst1@gxmzd-test-db2 ~]$ ll

总用量 8

drwxr-xr-x. 2 db2inst1 db2iadm1 4096 Apr 13 00:32 db2inst1

drwxrwsr-t. 23 db2inst1 db2iadm1 4096 Apr12 11:41 sqllib

[db2inst1@gxmzd-test-db2 ~]$ .sqllib/db2profile

[db2inst1@gxmzd-test-db2 ~]$ db2 forceapplication all

DB20000I The FORCE APPLICATION command completed successfully.

DB21024I This command is asynchronous and may not be effective immediately.

 

[db2inst1@gxmzd-test-db2 ~]$

[db2inst1@gxmzd-test-db2 ~]$ db2stop

SQL1064N DB2STOP processing was successful.

 

[db2inst1@gxmzd-test-db2 ~]$ db2 terminate

DB20000I The TERMINATE command completed successfully.

 

4.      删除DB2管理服务器:

必须删除DB2管理服务器才能卸载DB2

1.12.         作为DB2管理服务器所有者登陆。

1.13.         进入该用户的主目录下,运行脚本:. das/dasprofile.

1.14.         注销。

1.15.         作为root登陆,通过输入命令/opt/ibm/db2/V9.7/instance/dasdrop除去DB2管理服务器。

[dasusr1@gxmzd-test-db2 home]$ cd dasusr1

[dasusr1@gxmzd-test-db2 ~]$ ls

das

[dasusr1@gxmzd-test-db2 ~]$ .das/dasprofile

[dasusr1@gxmzd-test-db2 ~]$

[dasusr1@gxmzd-test-db2 ~]$ exit

exit

[root@gxmzd-test-db2 home]#

[root@gxmzd-test-db2 home]#

[root@gxmzd-test-db2 home]#/opt/ibm/db2/V9.7/instance/dasdrop

SQL4410W The DB2 Administration Server is not active.

DBI1070I Program dasdrop completed successfully.

 

5.      删除DB2实例:

一旦删除系统上的实例,该实例下的所有DB2数据库都将不可用。

1.16.         通过输入/opt/ibm/db2/V9.7/instance/db2idropdb2instname删除实例。

[root@gxmzd-test-db2 home]#/opt/ibm/db2/V9.7/instance/db2idrop db2inst1

DBI1070I Program db2idrop completed successfully.

 

 

6. 卸载DB2产品

root身份登陆,到DB2版本产品CD-ROM上的根目录或DB2安装文件(通常就是tar解包文件)下找到 db2_deinstall命令,

运行db2_deinstall a命令可以删除所有DB2产品。

可能需要输入DB2安装路径,这里是/var/opt/ibm/db2/V9.7

然后也可以在LINUX中删除DB2用户,这并非必须,重新安装仍可使用它们。

 

[root@gxmzd-test-db2 expc]# ls

db2           db2_deinstall  db2ls           db2setup  installFixPack  readmefirst.htm

db2ckupgrade  db2_install   db2prereqcheck  doc       readmefirst     readmefirst.txt

[root@gxmzd-test-db2 expc]# ./db2_deinstall-a

 

Enter full path name for the installdirectory -

 

------------------------------------------------

/opt/ibm/db2/V9.7

DBI1016I Program db2_deinstall is performing uninstallation. Please

     wait.

 

The execution completed successfully.

 

For more information see the DB2uninstallation log at

"/tmp/db2_deinstall.log.31318".

[root@gxmzd-test-db2 expc]#