db2 "CREATE DB WPREL using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR WPREL USING locktimeout 30"
db2 "CONNECT TO WPREL"
db2 "GRANT DBADM, SECADM ON DATABASE TO USER db2inst1"
db2 "CONNECT RESET"
db2 "CREATE DB WPCOMM using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR WPCOMM USING locktimeout 30"
db2 "CONNECT TO WPCOMM"
db2 "GRANT DBADM, SECADM ON DATABASE TO USER db2inst1"
db2 "CONNECT RESET"
db2 "CREATE DB WPCUST using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR WPCUST USING locktimeout 30"
db2 "CONNECT TO WPCUST"
db2 "GRANT DBADM, SECADM ON DATABASE TO USER db2inst1"
db2 "CONNECT RESET"
db2 "CREATE DB WPJCR using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR WPJCR USING locktimeout 30"
db2 "CONNECT TO WPJCR"
db2 "GRANT DBADM, SECADM ON DATABASE TO USER db2inst1"
db2 "CONNECT RESET"
db2 "CREATE DB WPFDBK using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR WPFDBK USING locktimeout 30"
db2 "CONNECT TO WPFDBK"
db2 "GRANT DBADM, SECADM ON DATABASE TO USER db2inst1"
db2 "CONNECT RESET"
db2 "CREATE DB WPLM using codeset UTF-8 territory us PAGESIZE 8192"
db2 "UPDATE DB CFG FOR WPLM USING locktimeout 30"
db2 "CONNECT TO WPLM"
db2 "GRANT DBADM, SECADM ON DATABASE TO USER db2inst1"
db2 "CONNECT RESET"
db2 "CONNECT TO WPJCR USER db2inst1 USING passw0rd"
db2 "CREATE BUFFERPOOL ICMLSFREQBP4 SIZE 1000 AUTOMATIC PAGESIZE 4K"
db2 "CREATE BUFFERPOOL ICMLSVOLATILEBP4 SIZE 16000 AUTOMATIC PAGESIZE 4K"
db2 "CREATE BUFFERPOOL ICMLSMAINBP32 SIZE 16000 AUTOMATIC PAGESIZE 32K"
db2 "CREATE BUFFERPOOL CMBMAIN4 SIZE 1000 AUTOMATIC PAGESIZE 4K"
db2 "CREATE REGULAR TABLESPACE ICMLFQ32 PAGESIZE 32K BUFFERPOOL ICMLSMAINBP32"
db2 "CREATE REGULAR TABLESPACE ICMLNF32 PAGESIZE 32K BUFFERPOOL ICMLSMAINBP32"
db2 "CREATE REGULAR TABLESPACE ICMVFQ04 PAGESIZE 4K BUFFERPOOL ICMLSVOLATILEBP4"
db2 "CREATE REGULAR TABLESPACE ICMSFQ04 PAGESIZE 4K BUFFERPOOL ICMLSFREQBP4"
db2 "CREATE REGULAR TABLESPACE CMBINV04 PAGESIZE 4K BUFFERPOOL CMBMAIN4"
db2 "CREATE SYSTEM TEMPORARY TABLESPACE ICMLSSYSTSPACE32 PAGESIZE 32K BUFFERPOOL ICMLSMAINBP32"
db2 "CREATE SYSTEM TEMPORARY TABLESPACE ICMLSSYSTSPACE4 PAGESIZE 4K BUFFERPOOL ICMLSVOLATILEBP4"
db2 "CREATE USER TEMPORARY TABLESPACE ICMLSUSRTSPACE4 PAGESIZE 4K BUFFERPOOL ICMLSVOLATILEBP4"
db2 "DISCONNECT WPJCR"
db2 "TERMINATE"
db2 "UPDATE DB CFG FOR WPJCR USING logfilsiz 16000"
db2 "UPDATE DB CFG FOR WPJCR USING logprimary 20"
db2 "UPDATE DB CFG FOR WPJCR USING logsecond 50"
db2 "UPDATE DB CFG FOR WPJCR USING logbufsz 500"
db2 "UPDATE DB CFG FOR WPJCR USING DFT_QUERYOPT 2"
脚本执行完成后,会在DB2实例中创建门户所需的数据库,切换至db2inst1用户,使用如下命令查看建库结果:
db2 list db directory
试验环境返回结果示例:
[db2inst1@localhost ~]$ db2 list db directory
System Database Directory
Number of entries in the directory = 6
Database 1 entry:
Database alias = WPJCR
Database name = WPJCR
Local database directory = /home/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 = WPCOMM
Database name = WPCOMM
Local database directory = /home/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 = WPREL
Database name = WPREL
Local database directory = /home/db2inst1
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
Database 4 entry:
Database alias = WPLM
Database name = WPLM
Local database directory = /home/db2inst1
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
Database 5 entry:
Database alias = WPCUST
Database name = WPCUST
Local database directory = /home/db2inst1
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number =
Database 6 entry:
Database alias = WPFDBK
Database name = WPFDBK
Local database directory = /home/db2inst1
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = 0
Alternate server hostname =
Alternate server port number = 3.4、下载脚本并在数据库服务器上运行该脚本,以设置数据库
scripts目录中的SetupDB2Database.sql文件用于对数据库进行设置;
所以需要切换至db2inst1用户下使用如下命令执行该脚本:
db2 -tvf SetupDB2Database.sql 注意:
因为自动生成的脚本中使用的操作系统用户组等信息与演示环境不太相同,所以为避免迁移出错,所以需要手动修改设置数据库脚本中的部分信息,将给组赋权的语句修改为db2inst1用户赋权;
如:
GRANT CONNECT, CREATETAB ON DATABASE TO GROUP WP_BASE_CONFIG_USERS;
修改为:
GRANT CONNECT, CREATETAB ON DATABASE TO USER db2inst1;
最终,试验环境设置数据库SQL脚本如下:
CONNECT TO WPREL USER db2inst1 USING passw0rd;
CREATE SCHEMA release AUTHORIZATION db2inst1;
COMMIT;
GRANT CONNECT, CREATETAB ON DATABASE TO GROUP db2inst1;
GRANT EXECUTE ON PACKAGE NULLID.SYSSH200 TO GROUP db2inst1;
GRANT ALTERIN, CREATEIN, DROPIN ON SCHEMA release TO GROUP db2inst1;
GRANT USE OF TABLESPACE USERSPACE1 TO GROUP db2inst1;
GRANT USAGE ON WORKLOAD SYSDEFAULTUSERWORKLOAD TO GROUP db2inst1;
CONNECT RESET;
CONNECT TO WPCOMM USER db2inst1 USING passw0rd;
CREATE SCHEMA community AUTHORIZATION db2inst1;
COMMIT;
GRANT CONNECT, CREATETAB ON DATABASE TO GROUP db2inst1;
GRANT EXECUTE ON PACKAGE NULLID.SYSSH200 TO GROUP db2inst1;
GRANT ALTERIN, CREATEIN, DROPIN ON SCHEMA community TO GROUP db2inst1;
GRANT USE OF TABLESPACE USERSPACE1 TO GROUP db2inst1;
GRANT USAGE ON WORKLOAD SYSDEFAULTUSERWORKLOAD TO GROUP db2inst1;
CONNECT RESET;
CONNECT TO WPCUST USER db2inst1 USING passw0rd;
CREATE SCHEMA customization AUTHORIZATION db2inst1;
COMMIT;
GRANT CONNECT, CREATETAB ON DATABASE TO GROUP db2inst1;
GRANT EXECUTE ON PACKAGE NULLID.SYSSH200 TO GROUP db2inst1;
GRANT ALTERIN, CREATEIN, DROPIN ON SCHEMA customization TO GROUP db2inst1;
GRANT USE OF TABLESPACE USERSPACE1 TO GROUP db2inst1;
GRANT USAGE ON WORKLOAD SYSDEFAULTUSERWORKLOAD TO GROUP db2inst1;
CONNECT RESET;
CONNECT TO WPJCR USER db2inst1 USING passw0rd;
CREATE SCHEMA jcr AUTHORIZATION db2inst1;
COMMIT;
GRANT CONNECT, CREATETAB ON DATABASE TO GROUP db2inst1;
GRANT EXECUTE ON PACKAGE NULLID.SYSSH200 TO GROUP db2inst1;
GRANT ALTERIN, CREATEIN, DROPIN ON SCHEMA jcr TO GROUP db2inst1;
GRANT USE OF TABLESPACE USERSPACE1 TO GROUP db2inst1;
GRANT USAGE ON WORKLOAD SYSDEFAULTUSERWORKLOAD TO GROUP db2inst1;
GRANT USE OF TABLESPACE ICMLFQ32 TO GROUP db2inst1;
GRANT USE OF TABLESPACE ICMLNF32 TO GROUP db2inst1;
GRANT USE OF TABLESPACE ICMVFQ04 TO GROUP db2inst1;
GRANT USE OF TABLESPACE ICMSFQ04 TO GROUP db2inst1;
GRANT USE OF TABLESPACE CMBINV04 TO GROUP db2inst1;
GRANT USE OF TABLESPACE ICMLSUSRTSPACE4 TO GROUP db2inst1;
CONNECT RESET;
CONNECT TO WPFDBK USER db2inst1 USING passw0rd;
CREATE SCHEMA feedback AUTHORIZATION db2inst1;
COMMIT;
GRANT CONNECT, CREATETAB ON DATABASE TO GROUP db2inst1;
GRANT EXECUTE ON PACKAGE NULLID.SYSSH200 TO GROUP db2inst1;
GRANT ALTERIN, CREATEIN, DROPIN ON SCHEMA feedback TO GROUP db2inst1;
GRANT USE OF TABLESPACE USERSPACE1 TO GROUP db2inst1;
GRANT USAGE ON WORKLOAD SYSDEFAULTUSERWORKLOAD TO GROUP db2inst1;
CONNECT RESET;
CONNECT TO WPLM USER db2inst1 USING passw0rd;
CREATE SCHEMA likeminds AUTHORIZATION db2inst1;
COMMIT;
GRANT CONNECT, CREATETAB ON DATABASE TO GROUP db2inst1;
GRANT EXECUTE ON PACKAGE NULLID.SYSSH200 TO GROUP db2inst1;
GRANT ALTERIN, CREATEIN, DROPIN ON SCHEMA likeminds TO GROUP db2inst1;
GRANT USE OF TABLESPACE USERSPACE1 TO GROUP db2inst1;
GRANT USAGE ON WORKLOAD SYSDEFAULTUSERWORKLOAD TO GROUP db2inst1;
CONNECT RESET; 3.5、重新启动DB2服务器
对DB2重新设置参数后需要重新启动DB2服务;
切换至db2inst1用户,执行以下命令重启DB2服务:
su - db2inst1
db2stop
db2start
exit
切换至dasusr1用户,执行以下命令重启管理服务:
su - dasusr1
db2admin stop
db2admin start
exit 注意:
保险起见,有必要使用reboot命令重启整个服务器以生效所有配置;