DB2安装部署以及应用部署配置操作(3)

$ db2 "CREATE LARGE TABLESPACE TBS_DAT_32k PAGESIZE 32K MANAGED BY AUTOMATIC STORAGE  EXTENTSIZE 4 PREFETCHSIZE AUTOMATIC BUFFERPOOL BP_DAT_32K AUTORESIZE YES INCREASESIZE 1G  NO FILE SYSTEM CACHING"

$ db2 "CREATE LARGE TABLESPACE TBS_IDX_32k PAGESIZE 32K MANAGED BY AUTOMATIC STORAGE  EXTENTSIZE 4 PREFETCHSIZE AUTOMATIC BUFFERPOOL BP_IDX_32K AUTORESIZE YES  INCREASESIZE 1G  NO FILE SYSTEM CACHING"

$ db2 "CREATE system TEMPORARY TABLESPACE TBS_SYSTMP_32K PAGESIZE 32K MANAGED BY AUTOMATIC STORAGE  BUFFERPOOL BP_TMP_32K  NO FILE SYSTEM CACHING"

12.数据库恢复

创建所需目录:

$ mkdir -p /oradata4/db2

首先对备份文件进行分析:

$ ls -al | grep -i RESLT4

-rw-r--r-- 1 db2inst1 db2iadm1 13223706624 Jan 19 12:42 RESLT4.0.db2inst1.DBPART000.20170118202238.001

生成restore.clp文件

$ db2 restore db RESLT4 taken at 20170118202238 redirect generate script restore.clp

DB20000I  The RESTORE DATABASE command completed successfully.

修改restore.clp文件:

RESTORE DATABASE RESLT4

-- USER  <username>

-- USING '<password>'

FROM '/oradata4/db2'

TAKEN AT 20170118202238

-- ON '/oradata4/db2'

-- DBPATH ON '<target-directory>'

INTO RESDB

-- NEWLOGPATH '/oradata4/db2/db2inst1/NODE0000/SQL00004/LOGSTREAM0000/'

-- WITH <num-buff> BUFFERS

-- BUFFER <buffer-size>

-- REPLACE HISTORY FILE

-- REPLACE EXISTING

REDIRECT

-- PARALLELISM <n>

WITHOUT ROLLING FORWARD

-- WITHOUT PROMPTING

;

-- SET STOGROUP PATHS FOR IBMSTOGROUP

-- ON '/oradata4/db2'

-- ;

RESTORE DATABASE RESLT4 CONTINUE;

批注:远端备份的数据库名为RESLT4,远端备份路径为/oradata4/db2,本地数据库名为RESDB,本地需要先创建/oradata4/db2路径。

执行恢复操作:

$ db2 -tvf restore.clp

UPDATE COMMAND OPTIONS USING S ON Z ON RESLT4_NODE0000.out V ON

DB20000I  The UPDATE COMMAND OPTIONS command completed successfully.

SET CLIENT ATTACH_MEMBER  0

DB20000I  The SET CLIENT command completed successfully.

SET CLIENT CONNECT_MEMBER 0

DB20000I  The SET CLIENT command completed successfully.

RESTORE DATABASE RESLT4 FROM '/oradata4/db2' TAKEN AT 20170118202238 INTO RESDB REDIRECT WITHOUT ROLLING FORWARD

SQL2529W  Warning!  Restoring to an existing database that is different from

the backup image database, and the alias name "RESDB" of the existing database

does not match the alias name "RESLT4" of the backup image, and the database

name "RESDB" of the existing database does not match the database name

"RESLT4" of the backup image. The target database will be overwritten by the

backup version. The Roll-forward recovery logs associated with the target

database will be deleted.

Do you want to continue ? (y/n)y

SQL1277W  A redirected restore operation is being performed. During a table

space restore, only table spaces being restored can have their paths

reconfigured. During a database restore, storage group storage paths and DMS

table space containers can be reconfigured.

DB20000I  The RESTORE DATABASE command completed successfully.

RESTORE DATABASE RESLT4 CONTINUE

DB20000I  The RESTORE DATABASE command completed successfully.

 

应用环境部署

13.WAS应用部署连接DB2数据库

之前部署的WAS环境连接的都是Oracle库,连接DB2的库数据源配置还是第一次,找了些资料,将与配置Oracle不同的地方记录如下:

13.1配置DB2环境变量   --本次WAS部署采用的是单机环境

控制台界面中选择Environment-->WebSphere-->variables-->作用域(选择server1)

点击"new"创建DB2UNIVERSAL_JDBC_DRIVER_PATH变量值为:"/was/DB2lib"

批注:部署was应用的主机创建该目录,并将所需jar包传入到该路径下,jar包位置/opt/ibm/db2/V10.5/java

13.2配置JDBC提供程序:

控制台界面中选择Resources-->JDBC-->JDBC providers-->选择"server1",点击"New"

名称:DB2 Universal JDBC Driver Provider

数据库类型选择"DB2",提供程序类型选择"DB2 Universal JDBC Driver Provider",实施类型选择"Connection pool data source",点击“Next”

class path设置:

/was/DB2lib/db2jcc.jar

/was/DB2lib/db2jcc_license_cu.jar

13.3创建J2C用户

db2inst1/db2inst1

13.4.数据源配置

jdbcResTxDataSource          jdbc/ResTxDataSource  

jdbcoracleResTxDataSource      jdbc/oracle/ResTxDataSource

数据源连接测试

14.应用部署,测试验证

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/a9e40c1abc7086179114b64abc91e9d6.html