IBM Db2 Event Store utilities setup and usage

IBM® Db2® Event Store features a set of utilities and tools that will need to be setup. The Db2 Event Store utilities macro provides and interface for running the Db2 Event Store tooling.

Before you begin

  • Verify that Db2 Event Store is completely installed and running.
  • The eventstore-tools container must be in a running state.

Procedure

  1. Setup the environment variables.
    Note: If you are in a Red Hat OpenShift 4.X (RHOS 4.X) environment, you will need to be logged in to your OpenShift account on the infrastructure node of the cluster before you can run any of the commands.
    1. The environment variables need to be declared for the eventstore-tools pod.
    2. Declare a function that will run as a macro where commands can be passed to the tools container.
    3. Select the deployment that applies to you and run the following commands in command line:
      • Standalone/IBM Watson™ Studio deployment:
        TOOLS_CONTAINER=$(kubectl get pods -n dsx | grep eventstore-tenant-tools | awk {'print $1'}) && ORIGIN_IP=`hostname -i | awk '{print $1}'` 
        eventstoreUtils() { kubectl -n dsx exec -it "${TOOLS_CONTAINER}" -- bash -c 'export ORIGIN_IP="${1}" && eventstore-utils "${@:2}"' bash "${ORIGIN_IP}" "${@}"; }
      • IBM Cloud Pak for Data deployment:
        DEPLOYMENT_ID="<Enter deployment ID here>"
        TOOLS_CONTAINER=$(oc get pods |grep $DEPLOYMENT_ID | grep -E "(eventstore)(.*)(tenant-tools)" | awk {'print $1'}) && ORIGIN_IP=`hostname -i | awk '{print $1}'`
        eventstoreUtils() { oc -it exec "${TOOLS_CONTAINER}" -- bash -c 'export ORIGIN_IP="${1}" && eventstore-utils "${@:2}"' bash "${ORIGIN_IP}" "${@}"; }
  2. Run the Db2 Event Store utilities.
    After subset up the environment variables, you now have access to different Db2 Event Store tooling. You can test if everything has been set up correctly by running the following command:
    eventstoreUtils --help
    When running the command, you should see the following response:
    Usage: /usr/bin/eventstore-utils [OPTIONS] [arg]
    OPTIONS:
    =======
            --tool         The db2 tool you wish to run within the specified target. Ex stop, start, db2set, db2, db2pd. Default: db2
            --command      The command you wish to run for the tool you provided. Surround in quotations For example "list database directory" for the tool db2.
            --connect      Pass this option to run a 'db2 connect to db' before the provided command.
            --interactive  Pass this option to run in interactive mode. 
            --help         print usage
    
    TARGET:
    =======
            --all-engines  Pass this option to run the provided command on all eventstore engine pods.
            --catalog      Pass this option to run the provided command only on the eventstore catalog.
            --member <N>   Pass this option to run the provided command only on the eventstore member number provided.

    If you do not see the previous message, refer back to the beginning of the setup.

  3. Run the Db2 Event Store tooling.

    With the Db2 Event Store utilities macro set up, you can now access the Db2 Event Store tooling.

    This tooling can be run in the following format:
    eventstoreUtils <command> [options] [<subcommand>] [options]

IBM Db2 Event Store utilities commands and tools

The Db2 Event Store utilities are run in the following format:
eventstoreUtils --tool <TOOL_NAME> [-command "<commands>"]
These are the commands and tools you can run:
  • start
    The start tool allows you to start the Db2 Event Store engine pods:
    eventstoreUtils --tool start
  • stop
    The stop tool allows you to stop the Db2 Event Store engine pods:
    eventstoreUtils --tool stop
  • db2 command line processor

    The command line processor is used to run database utilities, SQL statements and online help:

    # eventstoreUtils --tool db2 --connect --command "list tables"
    
       Database Connection Information
    
     Database server        = DB2/LINUXX8664 11.1.9.0
     SQL authorization ID   = DB2INST1
     Local database alias   = EVENTDB
    
    
    Table/View                      Schema          Type  Creation time
    ------------------------------- --------------- ----- --------------------------
    IOT.                            DB2INST1        T     2020-01-09-02.07.20.947055
    
      1 record(s) selected.
    
    DB20000I  The SQL command completed successfully.
    DB20000I  The TERMINATE command completed successfully.

    For more information, refer to db2 - Command line processor invocation command.

  • collect-engine-diagnostics
    The collect-engine-diagnostics command allows you to collect engine diagnostics and stores the results locally:
    $ eventstoreUtils --tool collect-engine-diagnostics --command "--help"
       Usage: /usr/bin/collect-engine-diagnostics [OPTIONS] [arg]
    
       DESCRIPTION:
       ===========
       This script is used to collect engine diagnostics using various diagnostics tools.
    
       OPTIONS:
       =======
       --nodeid | -l        Required Node number to query. Can be a single node or multiple
                            nodes separated by commas. Eg. --nodeid 1,2,3
       --ip-address | -i    Required Host machine IP is needed to run systemctl and journalctl. This
                            can be a single IP or multiple IPs separated by commas.
                            Eg. --host-ip 10.30.00.000,10.30.00.001,10.30.00.002
       --path | -P          Optional override for path where to store the output files.
                            Default is current working directory.
       --suffix | -s        Optional override for suffix for the output files.
                            Default is current timestamp.
       --config | -c        Optional include collection of current configuration.
    
    For example, if you are collecting engine diagnostics for nodes 1 and 2, you would run the following:
    $ eventstoreUtils --tool collect-engine-diagnostics --command "--nodeid 1,2"
  • db2_engine

    The db2_engine tool allows you to run a command within a single engine pod.

    For example, if you want to run pwd from a single engine pod:
    $ eventstoreUtils --tool db2_engine --command "pwd"
    /home/db2inst1/sqllib
  • db2support
    The db2support tool is run on all the engine pods and catalog pods, and saves the results locally:
    $ eventstoreUtils --tool db2support
  • replace_SSL_files
    The replace_SSL_files tool allows you to replace the default key database and SSL certificate with your own key database and SSL certificate generated by the IBM GSKit library:
    Note: For more information, refer to User-provided SSL certificate
    $ eventstoreUtils --tool replace_SSL_files --command "<replace_SSL_files options>"
    For example, if you want to call the replace_SSL_files tool with the --help option, run the following:
    $ eventstoreUtils --tool replace_SSL_files --command "--help"
    Usage: /eventstore/tools/hooks/post-install/user_ssl_cert.sh [OPTIONS] [arg]
    OPTIONS:
    =======
    [ Mandatory ]
    --stash-file       Path of the GSKit generated engine keystore's stash file.
    --keystore         Path of the GSKit generated engine keystore file.
    --certificate      Path of the GSKit generated digital certificate file in the format of 'ascii'.
    --node-ip          IP address of the node where the SSL keystore and certificates are located.
    --password         SSH Password of the root user on the node where the SSL files are located.
    
    Note: The keystore and certificate replacement operation must be executed as the [ root ] user.
          The provided certificate must be already inserted in the provided GSKit generated keystore file.

Additional options

These additional options do not require arguments, but they must be used with a tool or command (with the exception of --help).
$ eventstoreUtils [--<additional_options>] [--<command> <options> [--<subcommand>] ["options"]]
  • --connect

    Runs db2 connect to db before the provided command.

  • --help

    Prints the usage of the command or tool.

  • --interactive
    Runs the interactive mode, for example:
    # eventstoreUtils --tool db2 --interactive
    (c) Copyright IBM Corporation 1993,2007
    Command Line Processor for DB2 Client 11.1.9.0
    
    You can issue database manager commands and SQL statements from the command
    prompt. For example:
        db2 => connect to sample
        db2 => bind sample.bnd
    
    For general help, type: ?.
    For command help, type: ? command, where command can be
    the first few keywords of a database manager command. For example:
     ? CATALOG DATABASE for help on the CATALOG DATABASE command
     ? CATALOG          for help on all of the CATALOG commands.
    
    To exit db2 interactive mode, type QUIT at the command prompt. Outside
    interactive mode, all commands must be prefixed with 'db2'.
    To list the current command option settings, type LIST COMMAND OPTIONS.
    
    For more detailed help, refer to the Online Reference Manual.
    
    db2 =>
  • --member <N>
    This allows users to invoke the command on a specific member, such as using the Db2 problem determination tool to show the applications running on a specific member. For example:
    # eventstoreUtils --tool db2pd --member 2 --command '-applications -db EVENTDB'
    
    Database Member 2 -- Database EVENTDB -- Active -- Up 1 days 17:50:32 -- Date 2020-01-10-20.12.31.850619
    
    Applications:
    Address            AppHandl [nod-index] NumAgents  CoorEDUID  Status                  C-AnchID C-StmtUID  L-AnchID L-StmtUID  Appid                                                            WorkloadID  WorkloadOccID CollectActData          CollectActPartition     CollectSectionActuals
    0x000000020DCB0080 65470592 [999-00128] 0          0          Decoupled               0        0          0        0          *N999.DB2200109022225                                            0           0             n/a                     n/a                     n/a
    0x000000020F4EECA0 131217   [002-00145] 1          219        ConnectCompleted        0        0          0        0          *N2.DB2.200109022313                                             0           0             N                       C                       N
    ...
    

    For more information on using the Db2 problem determination tool, refer to Monitoring and troubleshooting using db2pd command.