如何从远程Db2实例连接到IBM Db2 Event Store实例?

编程入门 行业动态 更新时间:2024-10-28 21:19:49
本文介绍了如何从远程Db2实例连接到IBM Db2 Event Store实例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个Db2实例,我正在尝试将其连接到远程IBM Db2 Event Store集群。我已经能够连接Db2 CLP客户端,是否有可能让Db2实例查看Db2事件存储群集中的表以及它们是否是本地表?

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实例,可以直接从 docker hub 。使用此容器,我可以按照以下步骤配置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

然后,我按照文档操作使用安全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事件存储表。

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 ?

推荐答案

是的!你真的很亲密

鉴于您已连接到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创建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列表表

这里的关键是您的活动连接。对远程Db2事件存储数据库进行创建后, db2列表表... 命令将显示该远程数据库的表,并且在本地数据库上建立连接后, db2列表表... 命令将显示本地数据库的表。

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实例?

本文发布于:2023-11-17 04:02:13,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608756.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实例   连接到   Store   Event   IBM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!