Cataloging the Db2 database
You can remotely catalog the Db2 database by running CLP or CLPPlus commands.
The following variables are used in the catalog commands:
- host_name_or_IP_address – The host name or IP address of the Cloud Pak for Data instance.
- db2_ssl_port – The port number of the Db2 secure sockets layer (SSL) instance.
- db2_port – The port number of the Db2 instance.
- database_name – The name of the Db2 database.
- database_alias_name – The alias name of the remote Db2 database.
- server_alias_name – The alias for the remote server of the Db2 instance.
- authentication_method
– The authentication method for connecting to the remote database:
- For user name and password – SERVER_ENCRYPT
- For access token and API key – GSSPLUGIN
- CLP
- You can catalog the remote database by using the CLP either with or without SSL:
- SSL
-
db2 catalog tcpip node server_alias_name remote host_name_or_IP_address server db2_ssl_port security SSL db2 catalog db database_name as database_alias_name at node server_alias_name authentication authentication_method
- Non-SSL
- (Only supported for user name and
password)
db2 catalog tcpip node server_alias_name remote host_name_or_IP_address server db2_port db2 catalog db database_name as database_alias_name at node server_alias_name authentication authentication_method
- CLPPlus
- For CLPPlus to connect to a Db2 server by using Cloud Pak for Data authentication, you must configure a data source
name (DSN) first in a db2dsdriver.cfg configuration file by running the
following
command:
db2cli writecfg add -dsn dsn_alias -database database_name -host host_name_or_IP_address -port db2_ssl_port -parameter "parameter"
Where parameter is one of the following values:
- Authentication=GSSPLUGIN – Used for non-SSL connections, which require a user name and password
- SecurityTransportMode=SSL – Used for SSL connections
The db2dsdriver.cfg configuration file is an XML file, typically located in the sqllib/cfg directory, that contains a list of DSN aliases and their properties. The following example of a db2dsdriver.cfg configuration file shows the configurations that are used to establish a connection to a database service instance. The configuration file provides the DSN alias, the database name, the host name (or IP address), and the Authentication and SecurityTransportMode parameter values:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <configuration> <dsncollection> <dsn alias="<data_source_name>" name="database_name" host="host_name_or_IP_address" port="db2_ssl_port"> <parameter name="Authentication" value="authentication_method"/> <parameter name="SecurityTransportMode" value="SSL"/> </dsn> </dsncollection> <databases> <database name="database_name" host="host_name_or_IP_address" port="db2_ssl_port"/> </databases> </configuration>
For more details about connecting to DSN aliases with CLPPLUS, see DSN aliases in CLPPlus.