如何从远程 Db2 实例连接到 IBM Db2 Event Store 实例? [英] How do I connect to an IBM Db2 Event Store instance from a remote Db2 instance?

查看:18
本文介绍了如何从远程 Db2 实例连接到 IBM Db2 Event Store 实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Db2 实例,我正在尝试将它连接到远程 IBM Db2 Event Store 集群.我已经能够连接 Db2 CLP 客户端,是否可以让 Db2 实例看到 Db2 Event Store 集群中的表,就像它们是本地表一样?

I have a Db2 instance and I am trying to connect it to a remote IBM Db2 Event Store cluster. I have been able to connect the Db2 CLP client, is it possible to have the Db2 instance see the tables in the Db2 Event Store cluster as well like if they were local tables ?

我使用的容器已经包含最新的 Db2 11.5 实例,并且可以直接从 码头工人枢纽.使用此容器,我能够按照这些步骤配置 Db2 客户端以远程访问 IBM Db2 Event Store 实例,因此我知道我有连接.

I am using a container that already contains the latest Db2 11.5 instance, and that can be downloaded directly from docker hub. With this container, I was able to configure the Db2 client to remotely access the IBM Db2 Event Store instance following these steps, so I know I have connectivity.

首先我用 db2 实例启动容器

First I started the container with the db2 instance

$ docker run -itd --name db2 -e DBNAME=testdb -v ~/:/database -e DB2INST1_PASSWORD=GD1OJfLGG64HV2dtwK -e LICENSE=accept -p 50000:50000 --privileged=true ibmcom/db2

进入容器

$ docker exec -it  db2 bash -c "su - db2inst1"

遵循 在非 Java Db2 客户端中配置安全套接字层 (SSL) 支持的文档

为此,我在容器中下载了 GsKit 包并安装了,并使用 GSKCapiCmd 工具创建了一个密钥数据库

For this, I downloaded the GsKit package within the container and installed it and used the GSKCapiCmd tool to create a key database

[db2inst1@a33d5b29ffa2 ~]$ mkdir /database/config/db2inst1/sqllib/security/keystore
[db2inst1@a33d5b29ffa2 ~]$ cd /database/config/db2inst1/sqllib/security/keystore
[db2inst1@a33d5b29ffa2 ~]$ gsk8capicmd_64 -keydb -create -db "mydbclient.kdb" -pw "myClientPassw0rdpw0" -stash

然后从服务器复制默认的自签名证书

And then copied the default self-signed certificate from the server

# kubectl get pods -n dsx | grep eventstore-tenant-engine | head -1
eventstore-tenant-engine-565d74cfd8-64jv4         1/1       Running     0          21h

# kubectl exec -n dsx eventstore-tenant-engine-565d74cfd8-64jv4 -- cat /eventstorefs/eventstore/db2inst1/sqllib_shared/gskit/certs/eventstore_ascii.cert

(如果您无权访问服务器,也可以使用 REST API)

(if you do not have access to the server, you can also use the REST API)

有了这个,我在客户端上用它创建了一个 server-certificate.cert 文件,然后将证书添加到我之前创建的客户端密钥数据库中:

With this, I created a server-certificate.cert file with it on the client, and then added the certificate to the client key database I created before:

[db2inst1@a33d5b29ffa2 ~]$ gsk8capicmd_64 -cert -add -db "mydbclient.kdb" -pw "myClientPassw0rdpw0"  -label "server" -file "server-certificate.cert" -format ascii -fips

最后更新了客户端的配置以使用我刚刚设置的客户端密钥数据库:

And finally updated the configuration on the client to use that client key database I just set up:

[db2inst1@a33d5b29ffa2 ~]$ db2 update dbm cfg using 
      SSL_CLNT_KEYDB /database/config/db2inst1/sqllib/security/keystore/clientkey.kdb 
      SSL_CLNT_STASH /database/config/db2inst1/sqllib/security/keystore/clientstore.sth

然后我按照文档到 使用 SECURITY SSL 对远程 TCPIP 节点进行编目,因为 Db2 Event Store Enterprise Edition 已默认配置 SSL:

Then I followed the documentation to catalog a remote TCPIP node using SECURITY SSL, as the Db2 Event Store Enterprise Edition has SSL configured by default:

[db2inst1@a33d5b29ffa2 ~]$ db2 catalog tcpip node nova remote 172.16.197.11 server 18730 SECURITY SSL
DB20000I  The CATALOG TCPIP NODE command completed successfully.
DB21056W  Directory changes may not be effective until the directory cache is
refreshed.

最后,我按照文档查看 使用 AUTHENTICATION GSSPLUGIN 对数据库进行编目,这是 Db2 Event Store 所需要的:

And lastly, I followed the documentation to catalog the database using AUTHENTICATION GSSPLUGIN, which is what Db2 Event Store requires:

[db2inst1@a33d5b29ffa2 ~]$ db2 CATALOG DATABASE eventdb AT NODE  nova AUTHENTICATION GSSPLUGIN
DB20000I  The CATALOG DATABASE command completed successfully.
DB21056W  Directory changes may not be effective until the directory cache is
refreshed.

通过我所做的所有设置,我能够建立一个 连接使用用户和密码验证配置.

With all the set up I did, I was able to establish a connection using the user and the password to validate the configuration.

[db2inst1@a33d5b29ffa2 ~]$ db2 CONNECT TO eventdb USER admin USING password

   Database Connection Information

 Database server        = DB2/LINUXX8664 11.1.9.0
 SQL authorization ID   = ADMIN
 Local database alias   = EVENTDB

现在我想更进一步,让 db2 实例同时查看本地表和远程 Db2 Event Store 表.这可能吗?

Now I would like to take one step further and be able to have the db2 instance see both local tables and remote Db2 Event Store tables. Is this possible ?

推荐答案

是的!你实际上非常接近.

Yup! You're actually very close.

假设您已连接到 Db2 Event Store 数据库,您可以运行:

Given you are connected to your Db2 Event Store database, you can run:

db2 列出所有表

或者对于给定的模式:

db2 列出模式的表 <>

现在,由于您使用的是 Db2 11.5 docker 容器,因此您还可以在容器内创建一个数据库.例如:

Now, since you are using Db2 11.5 docker container, you could also create a database inside the container. For example:

db2 create db testdb

之后,您可以连接到容器本地的数据库并列出您的本地"表.例如:

After which you can connect to the database local to the container and list your "local" tables. For example:

> db2 connect to testdb
> db2 list tables for all

这里的关键是您的活跃连接.当创建到远程 Db2 Event Store 数据库时,db2 list tables ... 命令将显示远程数据库的表,当在本地数据库上建立连接时,db2 listtables ... 命令将显示本地数据库的表.

The key thing here is your active connection. When it's made to your remote Db2 Event Store database, the db2 list tables ... command will show tables for the remote database, and when connection is made on the local database, the db2 list tables ... command will show tables for the the local database.

这篇关于如何从远程 Db2 实例连接到 IBM Db2 Event Store 实例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆