这里主要针对客户端连接Linux操作系统上的DB2数据库
1、DB2的安装,可以参考IBM帮助文档:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/basic/help.jsp?topic=/com.ibm.db2.luw.qb.server.doc/doc/r0008865.html
(用户:root,db2inst1)
2、windows客户端连接
·DbVisualizer连接
·控制中心连接
2.1DbVisualizer连接
1、准备驱动程序,这个工具是采取JDBC方式进行数据库连接的,所以要准备驱动,DB2连接数据库的驱动有4种,具体可以参考相关网站说明;我们这里需要两个驱动:db2jcc.jar和db2jcc_license_cu.jar
2、创建数据库的连接信息
3、有的时候会报错:这里针对“root capability required”,主要是数据库用户db2inst1需要拥有root的权限。这里我们使用“db2rfe”
具体操作:
====================================================================================
**
** Sample configuration file for db2rfe of IBM DB2
** -----------------------------------------------
**
** To select features and settings to configure, uncomment the corresponding
** keywords and specify values for those keywords.
**
** Comments are made by placing either an asterisk (*) or a number sign (#) at
** the start of a line
**
** =========================================================================
INSTANCENAME=db2inst1
** This is required keyword.
** ----------------------------------------------------------------------------
** Enable DB2 Advanced Copy Services (ACS).
** ----------------------------------------------------------------------------
** Valid value is NO and YES. Change to YES if you need to enable DB2 ACS.
ENABLE_DB2_ACS=NO
** ----------------------------------------------------------------------------
** Enable DB2 High Availability (HA) feature
** ----------------------------------------------------------------------------
** Valid value is NO and YES. Change to YES if you need to enable this feature.
ENABLE_HA=NO
** ------------------------------------------------------------------------------
** ENABLE DB2 Authentication on the server using local operating system security.
** ------------------------------------------------------------------------------
** Valid value is NO and YES. Change to YES if you need to enable this feature.
ENABLE_OS_AUTHENTICATION=YES
** --------------------------------------------
** Reserve DB2 remote connection service entry
** --------------------------------------------
** Valid value is NO and YES. Change to YES if you need to do the reservation.
** If SVCENAME and/or SVCEPORT are defined and valid, the DB2 database manager
** configuration will be updated accordingly.
RESERVE_REMOTE_CONNECTION=YES
*SVCENAME=db2c_db2inst1
** char(14)
*SVCEPORT=48000
** Valid value: 1024 - 65535
** --------------------------------------
** Reserve DB2 text search service entry
** --------------------------------------
** Valid value is NO and YES. Change to YES if you need to do the reservation.
** If SVCENAME_TEXT_SEARCH and/or SVCEPORT_TEXT_SEARCH are defined and valid,
** the DB2 Text Search configuration will be updated accordingly.
RESERVE_TEXT_SEARCH_CONNECTION=NO
*SVCENAME_TEXT_SEARCH=db2j_db2inst1
** char(14)
*SVCEPORT_TEXT_SEARCH=53000
** Valid value: 1024 - 65535
====================================================================================
2.2控制中心的连接
需要设置Catalog,具体步骤:
·db2 catalog tcpip node hljnode remote 192.168.100.54 server 50000
·db2 catalog db sample at node hljnode
·刷新数据库
说明:linux的Ip 192.168.100.54
hljnode自定义节点名
sample是一个样例数据库