DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Docker Containers and IBM DB2 Warehouse — An Introduction

Docker Containers and IBM DB2 Warehouse — An Introduction

An introduction to Docker Containers.

Olaf Depper user avatar by
Olaf Depper
·
Aug. 19, 19 · Tutorial
Like (7)
Save
Tweet
Share
9.51K Views

Join the DZone community and get the full member experience.

Join For Free

In my twenty years in IT, the containerization of applications, namely through Docker, is maybe the technology with the fastest adoption rate I have ever seen. The first release of Docker was delivered only five years ago back in 2014. Since then, containers have become the architecture of choice for many IT projects, especially when used together with orchestration through Kubernetes.

IBM has also containerized most of the database offerings, namely the Db2 Warehouse family. IBM Db2 Warehouse is deployed as a Docker container. This allows you to use a variety of platforms, such as Intel x86, IBM Power, and Linux on z. Db2 Warehouse can be also deployed on IBM Cloud Pak for Data, IBM Cloud, or any virtual private cloud like AWS, Microsoft Azure and more.

You can download the free IBM Db2 Warehouse Developer Edition from Docker Hub: https://hub.docker.com/_/ibm-db2-warehouse-dev. Alternatively, try a hands-on lab on Db2 Warehouse and Docker. This lab allows you to work with a Db2 Warehouse deployment and guide you through some of the most common Docker commands.

If you are an experienced Db2 administrator but did not work much with containers yet, there are some (few) things to learn. Some of the hurdles I came across when starting to work with Docker were:

  • Installation/ Deployment of Db2 Warehouse is done using Docker commands rather than  db2_install  or  db2setup  commands.
  • You need to know which environment you are working in: Are you already logged on to the Docker container, or are you still on the host running Docker?
  • How to copy files from the container to the host and vice-versa.

Let’s start with the deployment of Db2 Warehouse. Luckily, this is a very easy process, once you have understood some of the basics of Docker. The deployment is also well documented in the Db2 Warehouse Knowledge Center for all supported platforms, including Kubernetes.

The following command example will use the  docker run  command to deploy a Db2 Warehouse Developer Edition.

docker run -d -it --privileged=true --net=host --name=Db2wh -v /mnt/clusterfs:/mnt/bludata0 -v /mnt/clusterfs:/mnt/blumeta0 store/ibmcorp/db2wh_ce:<version>-db2wh_devc-linux

This command creates a Db2 Warehouse container (using the name Db2whas provided using the
 —name  command option). It will also create and mount the file systems used by the container (specified through the  -v / —volume  command option).

The  docker run  command itself is not very verbose. But you can follow the progress of the deployment using the command

docker logs --follow Db2wh

Once the deployment (which includes creating a Db2 instance and BLUDB database) has finished, you can work with the Db2 warehouse installation.

After the docker run command has completed, the Db2 Warehouse container is started automatically, so you can immediately log on to the container. Starting and stopping of Db2 is done differently in a Docker environment compared to a traditional Db2 installation. To start a Db2 Warehouse container Db2wh issue:

docker start Db2wh

To stop the same container, use:

docker stop Db2wh

Once Db2 Warehouse is started, you can log on to the container. Use the following Docker command:

docker exec -it Db2wh su – bluadmin

This will open an interactive terminal inside the container and log you on as the BLUADMIN user. Once you are logged in to the container, you can run Db2 commands and statements as you would in a “traditional” Db2 environment. Also, tools like  db2pd  or  dsmtop  can be run in the container. If you are used to look at Db2 diagnostic information, you probably have worked with the db2diag.log file before. In Docker environments, you might also want to look at the Db2wh_local.log. This file is located in directory /var/log and provides information on the startup of the Db2 Warehouse container.

In the container itself, you will probably notice the different file system structure, for example when looking for the home directory of the Db2 instance. If you run the docker run command from above, you will find the sqllib directory under the /mnt/blumeta0/home/db2inst1 directory. On the host itself, you will see these directories in the /mnt/clusterfs filesystem.

In addition to the Db2 commands that are available on all form factors, Db2 Warehouse provides support tools. These tools are similar to the commands provided in IBM Netezza appliances. For example, if you are used to the Netezza  nzsql  command, you will probably prefer thedbsql command over the traditional Db2 command line processor.

You can get a list of the available support commands by issuing the following command (from outside the Db2 container):

docker exec -it Db2wh commands 

One of the many useful commands to try is:

docker exec -it Db2wh db_size

This command will provide information on the size of the database and all the tables in it.

One of the tasks that you often need to do within Docker is moving files between the containers and the host system. You can use the  docker cp  command for this. For example, to copy the file Db2wh_local.log from the container (directory /var/log) to the /tmp directory of the local host, issue:

docker cp Db2wh:/var/log/Db2wh_local.log /tmp

The Db2 Warehouse client can be also downloaded from Docker hub: https://hub.docker.com/_/ibm-db2-warehouse-client-container. The deployment of the client is done through the  docker run  command. For example, with the following command, we will deploy the Db2 Warehouse client, call the Docker container “client”, and will already catalog the database we want to connect to (using the  -e /--environment option).

docker run -dit --net=host -v /mnt/tools:/mnt/clientdir -v /mnt/clusterfs/home/db2inst1:/mnt/blumeta0/home/db2inst1 --name=client -e REMOTE_DB=proddb.acme.org:50001 store/ibmcorp/db2wh_ce:<version>-db2wh_client-linux 

Once the Docker deployment has finished, you can work with the Db2 Warehouse client container. To log on to the container, issue:

docker exec -it client cli

You will be logged on to the Db2 command-line interface. You can connect to the database that you cataloged during the deployment. Or catalog additional databases using the  db_catalog  command:

db_catalog --add <DB server>:<port> [--alias <database alias>] [--ssl]
Kubernetes Docker (software) IBM DB2 Command (computing)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Monolithic First
  • Building Microservice in Golang
  • Introduction to Container Orchestration
  • DevOps for Developers: Continuous Integration, GitHub Actions, and Sonar Cloud

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: