In this short tutorial I will give you the answer to the question: why Oracle database is slow in docker? Recently, when I needed a testing environment, where one of the elements was the Oracle DB, I encountered a problem that caused me a lot of nerves. (Docker Oracle Database Unhealthy)
Problem -> Why Oracle database is slow in docker?
When I started the Oracle 11g Express Edition (XE) database in a container and tried to create a Kafka Connect connector for this database, it turned out that the connection configuration validator could be said to have crashed (I thought at the beginning), but it just turned out waited a long time for a response from the Oracle DB. The validation should last a maximum of a second, and in this case the response was after a few minutes. (Why Oracle database is slow in docker?)
Solution
Because I’m not an Oracle expert, I started looking for help on the internet. I came across a comment where someone wrote that after running the container two SQL commands should be executed and everything will work as it should. These are the commands:
ALTER SYSTEM SET FILESYSTEMIO_OPTIONS=DIRECTIO SCOPE=SPFILE; ALTER SYSTEM SET DISK_ASYNCH_IO=FALSE SCOPE=SPFILE;
Docker-Compose
Below I present a ready YAML script, where the above configuration can be kept in the init.sql file in the “config” folder that will be executed during container launch. (Why Oracle database is slow in docker?)
pawel@pawel:~/Desktop/Blog/oracle-db$ find . ./config ./config/init.sql ./docker-compose.yml
Contents of the docker-compose.yml file:
version: '2.1' services: oracle-db: hostname: oracle-db container_name: oracle-db image: wnameless/oracle-xe-11g-r2 volumes: - ./config:/docker-entrypoint-initdb.d ports: - "1521:1521" - "15080:8080"
We create and launch containers.
pawel@pawel:~/Desktop/Blog/oracle-db$ docker-compose up -d Creating network "oracle-db_default" with the default driver Creating oracle-db ... done
Then we check the logs from the “oracle-db” container. We see two entries in the logs: “System altered.”, Which correspond just to our two commands, which we have in the init.sql file in the “config” directory. (Why Oracle database is slow in docker?)
pawel@pawel:~/Desktop/Blog/oracle-db$ docker logs -f oracle-db Starting Oracle Net Listener. Starting Oracle 11g Express Edition instance. /usr/sbin/startup.sh: running /docker-entrypoint-initdb.d/init.sql SQL*Plus: Release 11.2.0.2.0 Production on Sat Nov 30 14:20:01 2019 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle 11g Express Edition Release 11.2.0.2.0 - 64bit Production System altered. System altered. SQL> Disconnected from Oracle 11g Express Edition Release 11.2.0.2.0 - 64bit Production
If you enjoyed this post please add the comment below and share this post on your Facebook, Twitter, LinkedIn or another social media webpage.
Thanks in advanced!
You can create your custom Docker image like.me.
Herę You have a image which Does not require a additional install step https://github.com/KamilJedrzejuk/oracle18c-xe
Hi Kamil, thanks for comment! Your one good as well 🙂