【发布时间】:2019-08-01 16:15:59
【问题描述】:
我有一个 Db2 实例,我正在尝试将它连接到远程 IBM Db2 Event Store 集群。我已经能够连接 Db2 CLP 客户端,是否可以让 Db2 实例看到 Db2 Event Store 集群中的表,就像它们是本地表一样?
我使用的容器已经包含最新的 Db2 11.5 实例,并且可以直接从 docker hub 下载。使用此容器,我能够按照这些步骤配置 Db2 客户端以远程访问 IBM Db2 Event Store 实例,因此我知道我有连接。
首先我用 db2 实例启动容器
$ 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"
关注documentation for Configuring Secure Sockets Layer (SSL) support in non-Java Db2 clients
为此,I downloaded the GsKit package within the container and installed it 并使用 GSKCapiCmd 工具创建密钥数据库
[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
然后从服务器复制默认的自签名证书
# 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)
有了这个,我在客户端上用它创建了一个 server-certificate.cert 文件,然后将证书添加到我之前创建的客户端密钥数据库中:
[db2inst1@a33d5b29ffa2 ~]$ gsk8capicmd_64 -cert -add -db "mydbclient.kdb" -pw "myClientPassw0rdpw0" -label "server" -file "server-certificate.cert" -format ascii -fips
最后更新了客户端上的配置以使用我刚刚设置的客户端密钥数据库:
[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
然后我按照文档找到catalog a remote TCPIP node using SECURITY SSL,因为 Db2 Event Store 企业版默认配置了 SSL:
[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.
最后,我按照文档找到了catalog the database using AUTHENTICATION GSSPLUGIN,这是 Db2 Event Store 所需要的:
[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.
通过我所做的所有设置,我能够建立一个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 表。这可能吗?
【问题讨论】:
标签: database ssl db2 ibm-event-store