[DB2]联邦数据库访问远程DB2
2009-08-12 11:03
323 查看
联邦数据库访问远程DB2
假定两个环境host1和host2
host1,本机
IP: 192.168.1.192
DB2 instance: db2inst1
DB2 db: local_db
host2,远程被访问机器
IP: 192.168.1.195
DB2 instance: db2inst1(port=50000,pwd=db2inst1)
DB2 db: remote_db
table: t_usertable
现在需要在host1的local_db数据库中访问远程host2上的表t_usertable
首先需要在host1上把host2节点和remote_db库编目进来
db2 catalog tcpip node node_195 remote 192.168.1.195 server 50000
db2 catalog db remote_db as remote_db_195 at node node_195
db2 TERMINATE (必须使用该命令否则可能导致catalog更新不能生效)
然后在host1上测试到host2的连通性
db2 connect to remote_db_195 user db2inst1 using db2inst1
db2 connect reset
修改host1和host2的实例配置参数,需要重起实例
db2 update dbm cfg using FED_NOAUTH yes
db2stop
db2start
然后连接到host1机器上的local_db数据库中
db2 connect to local_db
(本地为unix环境)create wrapper DRDA;
(本地为windows环境) create wrapper "DRDA" LIBRARY 'db2drda.dll' OPTIONS( ADD DB2_FENCED 'N');
create server remoteserver_195 TYPE DB2/UDB VERSION '8.2' WRAPPER DRDA AUTHORIZATION "db2inst1" PASSWORD "db2inst1" OPTIONS( DBNAME 'remote_db_195', PASSWORD 'Y');
CREATE USER MAPPING FOR "db2inst1" SERVER remoteserver_195 OPTIONS ( ADD REMOTE_AUTHID 'db2inst1', ADD REMOTE_PASSWORD 'db2inst1');
CREATE NICKNAME remote_t_usertable FOR remoteserver_195.db2inst1.t_usertable;
(其中,wrapper使用DB2数据源的缺省名称DRDA server名称是remoteserver_195,t_usertable表在local_db数据库中的nickname是remote_t_usertable)
在缺省的db2inst1模式下 然后可以在host1机器上,登陆进local_db,对remote_t_usertable表进行查询等操作了
db2 'select * from db2inst1.remote_t_usertable'
db2 connect reset
假定两个环境host1和host2
host1,本机
IP: 192.168.1.192
DB2 instance: db2inst1
DB2 db: local_db
host2,远程被访问机器
IP: 192.168.1.195
DB2 instance: db2inst1(port=50000,pwd=db2inst1)
DB2 db: remote_db
table: t_usertable
现在需要在host1的local_db数据库中访问远程host2上的表t_usertable
首先需要在host1上把host2节点和remote_db库编目进来
db2 catalog tcpip node node_195 remote 192.168.1.195 server 50000
db2 catalog db remote_db as remote_db_195 at node node_195
db2 TERMINATE (必须使用该命令否则可能导致catalog更新不能生效)
然后在host1上测试到host2的连通性
db2 connect to remote_db_195 user db2inst1 using db2inst1
db2 connect reset
修改host1和host2的实例配置参数,需要重起实例
db2 update dbm cfg using FED_NOAUTH yes
db2stop
db2start
然后连接到host1机器上的local_db数据库中
db2 connect to local_db
(本地为unix环境)create wrapper DRDA;
(本地为windows环境) create wrapper "DRDA" LIBRARY 'db2drda.dll' OPTIONS( ADD DB2_FENCED 'N');
create server remoteserver_195 TYPE DB2/UDB VERSION '8.2' WRAPPER DRDA AUTHORIZATION "db2inst1" PASSWORD "db2inst1" OPTIONS( DBNAME 'remote_db_195', PASSWORD 'Y');
CREATE USER MAPPING FOR "db2inst1" SERVER remoteserver_195 OPTIONS ( ADD REMOTE_AUTHID 'db2inst1', ADD REMOTE_PASSWORD 'db2inst1');
CREATE NICKNAME remote_t_usertable FOR remoteserver_195.db2inst1.t_usertable;
(其中,wrapper使用DB2数据源的缺省名称DRDA server名称是remoteserver_195,t_usertable表在local_db数据库中的nickname是remote_t_usertable)
在缺省的db2inst1模式下 然后可以在host1机器上,登陆进local_db,对remote_t_usertable表进行查询等操作了
db2 'select * from db2inst1.remote_t_usertable'
db2 connect reset
相关文章推荐
- 在JSP中访问Oracle ,SqlServer ,DB2, Informix ,Access 数据库
- JSP中访问Oracle ,SqlServer ,DB2, Informix ,Access 数据库
- 借助 AOP 重构 DB2 数据库访问程序
- 使用 Java 5 RowSet 新特性访问 IBM DB2 数据库
- 在JSP中访问Oracle ,SqlServer ,DB2, Informix ,Access 数据库
- 在 J2EE Web Application 中快速高效访问 IBM DB2 数据库
- 从Delphi 8中选择一种数据库连接方式访问IBM DB2 UDB
- 访问 db2 数据库 系统并发
- DB2跨数据库访问表的方法
- db2 创建联邦数据库 /nickname
- db2 联邦数据库练习
- 在JSP中访问Oracle ,SqlServer ,DB2, Informix ,Access 数据库
- 在JSP中访问Oracle ,SqlServer ,DB2, Informix ,Access 数据库
- 从Delphi 8中选择一种数据库连接方式访问IBM DB2 UDB
- 利用db2联邦数据库轻松实现程序部署
- SQL 教程数据库包括:Oracle, Sybase, SQL Server, DB2, Access 等等,您将学到如何使用 SQL 访问和处理数据系统中的数据
- db2 数据库访问系统并发问题Reason code = -2029060029
- DB2跨数据库访问表的方法
- 在JSP中访问Oracle ,SqlServer ,DB2, Informix ,Access 数据库 (njwx)
- DB2跨数据库访问表的方法