DB2 DAS其实就是DB2的管理服务器(Database Administration Server), DAS实际上是一个驻留在数据库服务器上的一个Instance,不同于DB2的Instance,这个DAS Instance是一个特殊的DB2管理控制点,主要用来让远程的DB2客户机可以利用图形界面(DB2 Client)来操作我们的数据库服务器,因此如果有一台远程DB2客户端想要通过图形界面的方式连接到我们运行业务的DB2数据库服务器,那么驻留在 DB2数据库服务器的DAS Instance需要启动并运。用一句话来概括就是DAS可以使远程DB2客户机以图形界面的方式连接到数据库服务器。
我们知道一台主机上可以有多个DB2 Instance,但是DAS在一台主机上只能有一个,即使存在多个DB2 Instance,一个且唯一的DAS Instance可以同时管理并服务于多个DB2 Instance。
那么如何创建DAS Instance,这里我只用Linux环境来举例说明:
首先创建对应实例的用户和组(dasusr1,dasadm1)
[root@alandb2 ~]# groupadd dasadm1
[root@alandb2 ~]# mkdir -p /home/dasusr1
[root@alandb2 ~]# useradd -d /home/dasusr1 -g dasadm1 dasusr1
[root@alandb2 ~]# passwd dasusr1
Changing password for user dasusr1.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
创建DAS Instance,需要利用到DB2DIR/Instance下面的dascrt命令(Windows平台,我们需要用db2admin create命令来创建):
[root@alandb2 instance]# pwd
/opt/ibm/db2/V9.5/instance
[root@alandb2 instance]# ./dascrt
DBI1025I Usage:
dascrt [-d] -u ASUser
Explanation:
An invalid argument was entered for the dascrt command. Valid arguments
for this command are:
-d enters debug mode, for use with DB2 Service
-u ASUser
is the user the DAS will run under
User response:
For more information about this command, please refer to theQuick
Beginnings manual. Enter the command again as follows:
dascrt -u ASUser
Confirm that user IDs and group names used to create the DB2 instance
are valid. For information about naming rules, see the topic called
"User, user ID and group naming rules" in the DB2 Information Center.
我们来运行dascrt命令来创建名为dasusr1的DAS Instance
[root@alandb2 instance]# ./dascrt -u dasusr1
SQL4406W The DB2 Administration Server was started successfully.
DBI1070I Program dascrt completed successfully.
创建完成后,我们可以看到dasusr1主目录下的Instance文件已经建好。
[dasusr1@alandb2 ~]$ pwd
/home/dasusr1
[dasusr1@alandb2 ~]$ ls
das
[dasusr1@alandb2 ~]$ cd das
[dasusr1@alandb2 das]$ ls
adm conv dasprofile java metadata usercshrc
bin ctrl dump lib msg userprofile
cfg dascshrc function log tmp
我们可以通过db2admin start或db2admin stop命令来起停DAS Instance
[dasusr1@alandb2 das]$ which db2admin
~/das/bin/db2admin
[dasusr1@alandb2 das]$ db2admin
dasusr1
[dasusr1@alandb2 das]$ db2admin stop
SQL4407W The DB2 Administration Server was stopped successfully.
[dasusr1@alandb2 das]$ db2admin start
SQL4406W The DB2 Administration Server was started successfully.
如果我们的DB2数据库服务器版本升级,我们可以通过运行DB2DIR/instance/dasupdt的命令,对DAS Instance进行升级。
我们还可以通过dasdrop命令来删除DAS Instance:
[root@alandb2 instance]# pwd
/opt/ibm/db2/V9.5/instance
[root@alandb2 instance]# ./dasdrop
SQL4407W The DB2 Administration Server was stopped successfully.
DBI1070I Program dasdrop completed successfully.
删除完成后,对应的实例目录也就不存在了:
[root@alandb2 instance]# su - dasusr1
[dasusr1@alandb2 ~]$ ls
[dasusr1@alandb2 ~]$
最后需要说明的是,我们还可以通过db2 get/update/reset admin cfg 命令来查询并管理配置DAS Instance,前提是DAS Instance需要创建并存在.