How To Monitor Oracle DBs On Docker Containers With EM 13c

This post continues the thread of DevOps and automation for the Oracle Database. During the last couple of months I’ve seen more interest in deploying Oracle Databases on Docker containers. Even more now that Oracle released full support of RAC Databases running on Docker.



After you deploy your first Oracle Database on Docker, several questions come into mind; like:

  • How do I monitor the status of the Oracle Database?
  • How do I manage the performance of the Oracle Database and the SQL’s being executed on it?
  • How do I alert on issues on a timely manner?

Well, if you have the same questions or concerns… you are not alone!

On this post, I’m trying to explain the process I followed in order to deploy an Oracle Enterprise Manager agent on a Docker container and how I do monitor and manage the Oracle Database running on it.

First things first. Just a quick recap of my environment.

  • Oracle Linux 7 host running Docker 19.03
  • Create a MACVLAN network on Docker. My network adapter is ens3 on the host running Docker.
sudo docker network create -d macvlan --subnet=192.168.56.0/24 --gateway=192.168.56.1 -o parent=ens3 orcl_nw
  • Create a Docker volume type “nfs” using an NFS share named /NFSSHARE
sudo docker volume create --driver local --opt type=nfs --opt o=addr=<nfs server>,rw,bg,hard,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0 --opt device=:/NFSSHARE agentstorage
  • Pull the 19.3 Docker image from container-registry.oracle.com
sudo docker pull container-registry.oracle.com/database/enterprise:19.3.0.0
  • Create the Docker container using the recently pulled image and mounting the volume “agentstorage” into “/u01” inside the container
sudo docker create -t -i \
--name ol7-orcl --hostname ol7-orcl --user oracle --ip 192.168.56.101 \
-e ORACLE_SID=ORCL \
-e ORACLE_PDB=PDB1 \
-v agentstorage:/u01 \
container-registry.oracle.com/database/enterprise:19.3.0.0
  • Disconnect the bridged Docker network from the container
sudo docker network disconnect bridge ol7-orcl
  • Connect the container to the MACVLAN network
sudo docker network connect orcl_nw --ip 192.168.56.101 ol7-orcl
  • Start our Docker container
sudo docker start ol7-orcl
  • Review the startup process and the creation of the database
sudo docker logs -f ol7-orcl

At this point we have our Docker container and the ORCL database up and running. But now I need a way to connect my ORCL database to the external world. Because I’m running a MACVLAN, I can create another Docker container in the same network and install Oracle Enterprise Manager (EM) in order to monitor it. Or I can also install Oracle EM on the host running Docker and setup a network link and a route to my Docker container. Let’s do the second option.

sudo ip link add mydocker-net link ens3 type macvlan mode bridge
sudo ip addr add 192.168.56.1/32 dev mydocker-net
sudo ip link set mydocker-net up
sudo ip route add 192.168.56.0/24 dev mydocker-net

I now have connectivity between my host and the Docker container.

$ ping 192.168.56.101
PING 192.168.56.101 (192.168.56.101) 56(84) bytes of data.
64 bytes from 192.168.56.101: icmp_seq=1 ttl=64 time=0.056 ms
64 bytes from 192.168.56.101: icmp_seq=2 ttl=64 time=0.070 ms
64 bytes from 192.168.56.101: icmp_seq=3 ttl=64 time=0.062 ms
64 bytes from 192.168.56.101: icmp_seq=4 ttl=64 time=0.073 ms
64 bytes from 192.168.56.101: icmp_seq=5 ttl=64 time=0.070 ms

sh-4.2$ ping 192.168.56.1
PING 192.168.56.1 (192.168.56.1) 56(84) bytes of data.
64 bytes from 192.168.56.1: icmp_seq=1 ttl=64 time=0.064 ms
64 bytes from 192.168.56.1: icmp_seq=2 ttl=64 time=0.079 ms
64 bytes from 192.168.56.1: icmp_seq=3 ttl=64 time=0.043 ms
64 bytes from 192.168.56.1: icmp_seq=4 ttl=64 time=0.082 ms
64 bytes from 192.168.56.1: icmp_seq=5 ttl=64 time=0.077 ms

The next step is to have name resolution setup between both hosts. For the Docker container it was easy to setup the full host name into the external DNS service. For the host resolution inside the Docker container you can use static entries in the /etc/hosts file or use the Docker embedded DNS server. For my exercise, I setup an entry in my /etc/hosts file providing the host name and the IP address of the host where EM is running.

The rest of the process is very straight forward. I use the silent install option for the Oracle EM agent. Below link has the steps to download the agent binaries for your specific platform and version.



Once you have the ZIP file of the agent binaries. Then just copy it inside the NFS share and connect to the Docker container.

sudo docker exec -it --user oracle ol7-orcl /bin/sh

After you login to the container just follow the steps in the provided agent install guide. Update the response file with the required information and run agentDeploy.sh. Make sure that the Agent Home resides in the Docker volume created. For this exercise will be inside /u01 directory.

After the agent deploy succeeds disconnect from the Docker session and re-connect as root.

sudo docker exec -it --user root ol7-orcl /bin/sh

Execute root.sh inside the Agent Home directory.

Let’s now verify that our EM has a new host target named ol7-orcl and is up and running.

Docker Container ol7-orcl on Oracle Enterprise Manager

The next step is to discover the ORCL database in EM. You can change the DBSNMP password by logging to the Docker container, then use SQLPlus to change the password and unlock the account.

alter user dbsnmp identified by <password> account unlock;

After the database discovery, verify the database target in the EM console.

ORCL database home page

Now that you have both the host target and the database target you can set metrics, thresholds and notifications on them.

Another important option is that if you have Diagnostics and Tuning packs, you can also monitor performance, get AWR/ASH reports and use EM to graphically analyze performance issues.

ORCL performance information

Hope this post helps understand the options you have in order to setup the required monitoring for the Oracle databases running on Docker containers.

Thanks,
Alfredo