Coin163

首页 > windows环境下搭建DB2 单物理节点 DPF 数据库

windows环境下搭建DB2 单物理节点 DPF 数据库

2021腾讯云限时秒杀,爆款1核2G云服务器298元/3年!(领取2860元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1062

2021阿里云最低价产品入口+领取代金券(老用户3折起),
入口地址https://www.aliyun.com/minisite/goods

本文讲述了windows环境下,如何搭建一个单物理节点,4个逻辑节点的DPF数据库环境


1.) 安装DB2产品,假设安装信息如下:
DB2 副本名称:                           DB2COPY1
目标目录:                               C:\db2installpath                                     


新建实例:                              
    实例名:                             DB2
        重新引导时启动实例:             否
        TCP/IP 配置:                  
            服务名称:                   db2c_DB2
            端口号:                     50000
        实例用户信息:                  
            用户名:                     miaoqingsong


2.) 安装完成之后,会默认创建一个实例,实例名DB2,实例目录为C:\ProgramData\IBM\DB2\DB2COPY1\DB2, 在这个目录下,可以看到db2node.cfg文件


3.) 添加节点
C:\windows\system32>db2start DBPARTITIONNUM 1 ADD DBPARTITIONNUM HOSTNAME ADMINIB-PR7US3I PORT 1 COMPUTER ADMINIB-PR7US3I USER miaoqingsong PASSWORD yourpwd
2015-11-16 21:26:48     1   0   SQL1489I  The add database partition server  operation was successful. The new database partition server "1" is active.
SQL1489I  The add database partition server  operation was successful. The new database partition server "1" is active.


C:\windows\system32>db2start DBPARTITIONNUM 2 ADD DBPARTITIONNUM HOSTNAME ADMINIB-PR7US3I PORT 2 COMPUTER ADMINIB-PR7US3I USER miaoqingsong PASSWORD yourpwd
2015-11-16 21:27:15     2   0   SQL1489I  The add database partition server  operation was successful. The new database partition server "2" is active.
SQL1489I  The add database partition server  operation was successful. The new database partition server "2" is active.


C:\windows\system32>db2start DBPARTITIONNUM 3 ADD DBPARTITIONNUM HOSTNAME ADMINIB-PR7US3I PORT 3 COMPUTER ADMINIB-PR7US3I USER miaoqingsong PASSWORD yourpwd
2015-11-16 21:27:27     3   0   SQL1489I  The add database partition server  operation was successful. The new database partition server "3" is active.
SQL1489I  The add database partition server  operation was successful. The new database partition server "3" is active.




查看C:\Windows\System32\drivers\etc\services和hosts文件,可以看到如下内容
db2c_DB2 50000/tcp


db2icv101 51000/tcp
DB2_DB2   60000/tcp
DB2_DB2_1 60001/tcp
DB2_DB2_2 60002/tcp
DB2_DB2_3 60003/tcp
DB2_DB2_4 60004/tcp
DB2_DB2_END 60005/tcp


C:\ProgramData\IBM\DB2\DB2COPY1\DB2\db2nodes.cfg
0 ADMINIB-PR7US3I ADMINIB-PR7US3I 0
1 ADMINIB-PR7US3I ADMINIB-PR7US3I 1
2 ADMINIB-PR7US3I ADMINIB-PR7US3I 2
3 ADMINIB-PR7US3I ADMINIB-PR7US3I 3



C:\windows\system32>db2stop
2015-11-16 21:27:46     0   0   SQL1032N  No start database manager command was issued.
2015-11-16 21:27:47     1   0   SQL1064N  DB2STOP processing was successful.
2015-11-16 21:27:47     2   0   SQL1064N  DB2STOP processing was successful.
2015-11-16 21:27:47     3   0   SQL1064N  DB2STOP processing was successful.
SQL6033W  Stop command processing was attempted on "4" node(s).  "3" node(s) were successfully stopped.  "1" node(s) were already stopped.  "0" node(s) could not be stopped.



4.)启动实例,创建并连接到数据库
C:\windows\system32>db2start
2015-11-16 21:29:03     2   0   SQL1063N  DB2START processing was successful.
2015-11-16 21:29:03     3   0   SQL1063N  DB2START processing was successful.
2015-11-16 21:29:04     1   0   SQL1063N  DB2START processing was successful.
2015-11-16 21:29:06     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.


C:\windows\system32>db2 "create db sample"
DB20000I  The CREATE DATABASE command completed successfully.


C:\windows\system32>db2 "connect to sample"


   Database Connection Information


 Database server        = DB2/NT 10.5.4
 SQL authorization ID   = MIAOQING...
 Local database alias   = SAMPLE




C:\windows\system32>db2 "list tablespaces"


           Tablespaces for Current Database


 Tablespace ID                        = 0
 Name                                 = SYSCATSPACE
 Type                                 = Database managed space
 Contents                             = All permanent data. Regular table space.
 State                                = 0x0000
   Detailed explanation:
     Normal


 Tablespace ID                        = 1
 Name                                 = TEMPSPACE1
 Type                                 = System managed space
 Contents                             = System Temporary data
 State                                = 0x0000
   Detailed explanation:
     Normal


 Tablespace ID                        = 2
 Name                                 = USERSPACE1
 Type                                 = Database managed space
 Contents                             = All permanent data. Large table space.
 State                                = 0x0000
   Detailed explanation:
     Normal


DB21011I  In a partitioned database server environment, only the table spaces
on the current node are listed.


C:\windows\system32>set db2node=1




C:\windows\system32>db2 connect to sample


   Database Connection Information


 Database server        = DB2/NT 10.5.4
 SQL authorization ID   = MIAOQING...
 Local database alias   = SAMPLE




C:\windows\system32>db2 list tablespaces


           Tablespaces for Current Database


 Tablespace ID                        = 1
 Name                                 = TEMPSPACE1
 Type                                 = System managed space
 Contents                             = System Temporary data
 State                                = 0x0000
   Detailed explanation:
     Normal


 Tablespace ID                        = 2
 Name                                 = USERSPACE1
 Type                                 = Database managed space
 Contents                             = All permanent data. Large table space.
 State                                = 0x0000
   Detailed explanation:
     Normal


DB21011I  In a partitioned database server environment, only the table spaces
on the current node are listed.



报错与解释:

如果不是使用默认的实例DB2,您创建实例的时候需要指定 -s ESE -u username,之后才能创建多分区环境,否则会报错 SQL1096N  The command is not valid for this node type.


正确的方法如下:

C:\windows\system32>db2icrt dpf10 -s ESE -u miaoqingsong
Enter current password for miaoqingsong:
DB20000I  The DB2ICRT command completed successfully.


C:\windows\system32>db2ilist
DPF10
DB2INST1


C:\windows\system32>set db2instance=dpf10


C:\windows\system32>db2start DBPARTITIONNUM 1 ADD DBPARTITIONNUM HOSTNAME .... 


原文

本文讲述了windows环境下,如何搭建一个单物理节点,4个逻辑节点的DPF数据库环境 1.) 安装DB2产品,假设安装信息如下: DB2 副本名称:                           DB2COPY1 目标目录:        

------分隔线----------------------------
相关推荐