Overview

Skill Level: Beginner

This recipe describes how to deploy Db2, IBM’s multi-workload database, into IBM Cloud private, IBM's new Kubernetes based private cloud, by using helm charts and persistent volumes.

Ingredients

  • IBM Cloud private 1.2
  • Kubectl command line (optional...get it here)
  • Persistent volume
  • IBM Db2 Server 11.1.2.2 - Developer-C Edition Helm chart
  • JDBC client for validation (optional)

A couple things to note: This recipe deploys the developer edition and should be used for development purposes only, and is a stand-alone Db2 (and not HA).

 

Note: For an updated recipe that focuses on Production Db2 on IBM Cloud Private 2.1, read about it here.

Step-by-step

  1. Install IBM Cloud private 1.2

    First, you will need to install IBM Cloud private 1.2. Detailed instructions are here. Once you have it installed, then the steps will be:

    • Create a persistent volume
    • Install Db2 with advanced options
    • Validate with a JDBC client

     

    OK, let’s continue…

  2. Create Persistent Volume

    To deploy Db2, you need to create a persistent volume that uses the ReadWriteMany (RWX) access mode. When you assign this access mode to the volume, many nodes can mount it with read/write permissions. This can be done in the UI, and should ideally be created before the deployment.

    Log into IBM Cloud private, and use the upper left menu to navigate to the Storage page

    Navigate-to-Storage-1

     

    On the storage page, click “Create Storage”

    Create-Storage-3-s

    In this example, I created a 10GB NFS volume, that uses the ReadWriteMany access mode, and it will be retained if the pod is removed. In your case, you would probably want to use NFS or other shared storage so that if a node drops the Db2 pod will come back up onto a different node and reconnect to the same volume. However, if you do not want to manage an NFS server, you can use HostPath as an easy solution for initial testing.

    You will soon see that the default volume size for the Db2 deployment specified in the helm chart is 5GB, so if you need more, go ahead and create a larger volume first, then match the size in the Advanced Installation fields that you will see shortly.

     

  3. Get to the Db2 Helm Chart

    Next install Db2 itself. With IBM Cloud private, you have 2 ways to install IBM Db2.

    1. IBM Cloud private’s App Center UI
    2. From the command line using “Helm” commands

     

    For this example, we will use the App Center. However, if you want to use the command line, you can directly access the helm charts here: https://github.com/IBM/charts. Either path is fine, and as we both know, if you love kubectl and helm commands, then using the helm charts directly is a great option.

    For the UI path, open IBM Cloud private 1.2, and navigate to the App Center.

    Once you log in, you’ll see the dashboard view.

    ICp-Dashboard-s

    Select the upper left menu and see the dropdown options, scroll to the bottom and select, “App Center”

    Navigate-s

    Scroll until you see “ibm-charts/db2”, and click “Install Package”.

    App-Center-s

    As a general rule, most all services have important fields you need to fill in before you can properly install, which is why you’ll see the advanced installation options. Db2 is no different, but since we need you to accept the license agreement, the license agreement will appear first (2 pages for your reading pleasure), and then the advanced options will appear.

    Once you see advanced options, go to the next step.

  4. Specify Advanced Settings

    There are quite a few advanced settings, but I’ll just highlight the ones you really need to worry about.

    Install Options 1 of 3:

    Install-1

    The first section you can leave all defaults, but if you want to customize the “instname” (user ID you’ll log into the database with) and password, this is where you do it. As you can see, the default user ID and password is db2inst1/password.

    Install options 2 of 3:

    Install-2

    Pay attention to these fields. They are essential to succeed:

    image.secret

    Depending on when you download IBM Cloud private, you may see this field.

    If you see the field, you need to go to the web site specified in this field (http://ibm.biz/db2-license) to accept the license agreement. Once you accept the agreement, you’ll see the image secret to paste into this field.

    NOTE: make sure you include the full secret (it’s long), including the two equal signs at the end, and if you are running from the command line, you’ll want to customize this so go to the web link above to get the key.

    If you don’t see the field, then the key is already embedded into your install and you are good to go.

     

    license

    To confirm you accepted the license, type in ‘accept’ (no quotes) in the license field.

     

    Install Options 3 of 3:

    Install-3

    There are 2 optional fields you should consider in this last section.

    service.type

    If you keep it ‘ClusterIP’, then only apps running inside the IBM Cloud local cluster will be able to access the Db2 service. However, if you change it to ‘NodePort’, then you will be able to call into the Db2 service from anywhere in the network (your data center, or wherever your firewalls allow).

    storage.size

    This is where you can customize how large you want your storage to be, but remember, it can’t be bigger than the storage volume you created earlier.

  5. Deploy the DB2 Helm Chart

    Once you are ready (you have accepted the license, created your persistent volume, and filled in all the advanced installation details) click “Review and Install”, then “Install”, and you are installing!

    Depending on compute and storage speeds, it may take several minutes to install and set up the sample database (which is creates by default). To monitor the progress, you have two options:

    From the UI, click on “Workloads”, select the db2 application (it’s actually a ‘deployment’ in Kubernetes terms), locate the pod and select it, then select the Logs tab.

    From the command line: find the pod name and monitor its log:

     

    kubectl get pods

    kubectl logs <podname> -f

     

     

  6. Start Using Db2

    Once Db2 is installed, you are ready to use it. For those like me that just want a simple JDBC UI to validate it, you will need to find the IP address and port to run JDBC calls from.

    To find the to use, find the service name for your Db2:

     

    kubectl get svc

     

    then copy the service name into this command (replace the <service name>:

     

    export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services <service name>)

     

    then run these two commands:

     

    export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")

    echo http://$NODE_IP:$NODE_PORT

     

     

    This will get you the IP address:port to use, and just amend that into the JDBC call (the default userID and password is db2inst1/password)

    jdbc:db2://IPAddress:port/sample 

    Then, find your favorite JDBC UI. There are many simple client tools you can use to validate. Additionally, I suggest you consider downloading IBM Data Server Manager (DSM). It can run SQL, but since you’ll need a database monitoring tool anyway, DSM is fantastic for monitoring multiple databases. Get DSM here.

     

  7. Conclusion

    Using this recipe, you can get IBM Db2 running in IBM Cloud private 1.2. While it’s not quite as simple as it should be, these steps will get you a great database to use as you try out IBM Cloud private 1.2.

    Good luck and happy Databasing!

Join The Discussion