Showing posts with label MAS. Show all posts
Showing posts with label MAS. Show all posts

Thursday, December 28, 2023

Connecting to a Local MAS Database

It's been a busy year.  I have been programming a custom Maximo application in Kotlin.

I have recently managed to get a local MAS up and running using mas-local.  It's a series of scripts written by Alex Donatelli to bring up a local MAS Manage instance.  It's perfect for development.  It requires some hefty hardware though.  I'm running a 12-core, 3.3 GHz machine with 64 GB of RAM (49 GB assigned to MAS) and SSD drives.  The script did not work when I had HDD's; it would timeout during installation.  I'm running with a Slim UDS. 

The remainder of this blog will be specific to running this local MAS instance.

The OpenShift Console web site is pretty good.  You can do a lot of things through it, but I'm not crazy about the terminal window.  I find I get logged out quickly.  What follows will be command-line focused, but it's not the only way to get the information.  It is assumed you can run the oc command.

Getting List of Projects

$ oc projects
You have access to the following projects and can switch between them with ' project <projectname>':

  * db2u
    mas-masdemo-manage
    ...

The list has many other entries in it, but the two of most interest to me are db2u and mas-masdemo-manage.

db2u is the project with the database pod in it.

mas-masdemo-manage is the project that has Maximo Manage in it.

Getting List of Running PODs 

$ oc project mas-masdemo-manage
Now using project "mas-masdemo-manage" on server "https://api.crc.testing:6443".

$ oc get pods
NAME                                                     READY   STATUS      RESTARTS        AGE
admin-build-config-2-build                               0/1     Completed   0               23h
all-build-config-1-build                                 0/1     Completed   0               22h
ibm-mas-manage-operator-6fdc56c84f-w8p5r                 2/2     Running     4               23h
ibm-truststore-mgr-controller-manager-7d9f7845cd-x759v   1/1     Running     2               23h
masdemo-entitymgr-appstatus-5fb844fbcd-bhdpp             1/1     Running     2               23h
masdemo-entitymgr-bdi-5b455f6b4b-q5xpf                   1/1     Running     2               23h
masdemo-entitymgr-ws-78d9b46ddb-6blw5                    1/1     Running     2               23h
masdemo-groupsyncagent-c69574896-wvwp6                   1/1     Running     3 (4h11m ago)   23h
masdemo-maslocal-all-8568f8bccb-ncbpr                    2/2     Running     2               4h36m
masdemo-maslocal-manage-maxinst-7d98c96744-fj4cd         1/1     Running     2               22h
masdemo-maslocal-truststore-worker-f7hlv                 0/1     Completed   0               23h
masdemo-monitoragent-6875cbb7c6-48p4w                    1/1     Running     2               23h
masdemo-usersyncagent-844744fc7f-lgs5k                   1/1     Running     4 (4h9m ago)    23h

$ oc project db2u
Now using project "db2u" on server "https://api.crc.testing:6443".

$ oc get pods
NAME                            READY   STATUS      RESTARTS   AGE
c-db2mas-db2u-0                 1/1     Running     2          24h
c-db2mas-etcd-0                 1/1     Running     57         24h
c-db2mas-instdb-n29pb           0/1     Completed   0          24h
c-db2mas-ldap-fff4bfdd8-jfwxz   1/1     Running     4          24h
c-db2mas-restore-morph-k4mkx    0/1     Completed   0          24h

The Maximo SMP directory is in  masdemo-maslocal-manage-maxinst-7d98c96744-fj4cd.

The running Maximo instance is in masdemo-maslocal-all-8568f8bccb-ncbpr.

The database is running in c-db2mas-db2u-0.

Connect with Remote Shell

oc rsh will connect to a running pod. 

$ oc rsh masdemo-maslocal-manage-maxinst-7d98c96744-fj4cd
sh-4.4$ cat /opt/IBM/SMP/maximo/applications/maximo/properties/maximo.properties 

mxe.name=MXServer
mxe.db.url=jdbc:db2://c-db2mas-db2u-engn-svc.db2u.svc:50001/BLUDB:sslConnection=true;sslVersion=TLSv1.2;
mxe.db.driver=com.ibm.db2.jcc.DB2Driver
mxe.db.user=maximo
mxe.db.password=maximo
mxe.db.schemaowner=maximo
...
sh-4.4$ exit

In this case, we are displaying the contents of the maximo.properties file.   We are interested in the database name (BLUDB) and the database user and password properties.

Connect to the Database

To connect to the database, we will forward a local port to the database port running within OpenShift using the oc port-forward command.

$ oc project db2u
Now using project "db2u" on server "https://api.crc.testing:6443".

$ oc get pod c-db2mas-db2u-0  -o=jsonpath='{.spec.containers[0].ports}'
[{"containerPort":50000,"name":"db2-server","protocol":"TCP"},{"containerPort":50001,"name":"db2-ssl-server","protocol":"TCP"},{"containerPort":50052,"name":"db2uapi","protocol":"TCP"}]

$ oc port-forward c-db2mas-db2u-0 50000:50000
Forwarding from 127.0.0.1:50000 -> 50000
Forwarding from [::1]:50000 -> 50000

From here, use whatever database tool you like.  I used dbeaver with these settings:

  • host: localhost
  • port: 50000
  • database: bludb
  • username: maximo
  • password: maximo