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)
Table of Contents
Introduction
Oracle Database
Oracle" Database is a powerful and widely used relational database" management system (RDBMS) developed and maintained by Oracle" Corporation. It is designed to store, manage, and manipulate large amounts of structured data, and is used by businesses and organizations around the world to support a wide range of applications.
Oracle" Database is based on a client-server architecture, with a central server that manages the data and a number of client applications that connect to the server to access and manipulate the data. Oracle" servers can support multiple clients simultaneously, and can be configured to support high levels of concurrency and performance.
Oracle" Database is a highly scalable and reliable database system, and is well-suited for mission-critical applications that require high availability and performance. It is widely used in a variety of industries, and has a large and active user" community.
Oracle" Database supports a wide range of programming" languages and APIs, including SQL", PL/SQL, Java", C, C++, and Python", and provides a number of tools and utilities for database administration and management.
Oracle Database In Docker
Docker" is a containerization platform that enables you to package and deploy applications in lightweight containers that can be easily moved and run on any supported host. Oracle" Database is available in a Docker" container, which enables you to easily deploy and run Oracle" Database in a containerized environment.
To use Oracle Database" in a Docker" container, you will need to install Docker" on your host machine and then pull the Oracle" Database Docker" image from the Oracle" Technology Network (OTN) or Oracle" Container Registry (OCR). You can then use the docker run
command to start a new container based on the image.
Using Oracle" Database in a Docker" container provides a number of benefits, including the ability to easily deploy and run the database in a consistent environment, the ability to quickly and easily scale the database as needed, and the ability to easily migrate the database to different environments.
Why Oracle database is slow in docker?
Problem
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;
FILESYSTEMIO_OPTIONS=DIRECTIO SCOPE=SPFILE
The FILESYSTEMIO_OPTIONS
parameter in Oracle" Database specifies the file system I/O options that are used for database files. The DIRECTIO
value for this parameter specifies that direct I/O should be used when reading and writing database files.
Direct I/O bypasses the operating system’s file system cache when reading and writing database files, which can improve the performance of certain database operations, such as data loading and index creation. However, it can also increase the CPU and I/O overhead of these operations, and may not always provide a performance benefit.
The SCOPE
parameter in Oracle" Database specifies the scope of the parameter setting. The SPFILE
value for this parameter indicates that the parameter should be set in the server parameter file (SPFILE), which is a persistent server-side configuration file that is used to store initialization parameter settings.
In this case, the FILESYSTEMIO_OPTIONS=DIRECTIO
parameter setting is specifying that direct I/O should be used for database files, and that this setting should be stored in the SPFILE. This means that the setting will take effect every time the database is started, and will remain in effect until it is changed or removed.
DISK_ASYNCH_IO=FALSE SCOPE=SPFILE
The DISK_ASYNCH_IO
parameter in Oracle" Database specifies whether asynchronous I/O should be used for database files. The FALSE
value for this parameter specifies that asynchronous I/O should not be used.
Asynchronous I/O is a technique that allows the database to perform I/O operations in the background, without waiting for the operation to complete before continuing with other tasks. This can improve the performance of certain database operations, especially when the database is accessing files on a remote file system or when there are multiple concurrent I/O operations.
However, asynchronous I/O can also increase the complexity of the database, and may not always provide a performance benefit. In some cases, it may be more efficient to use synchronous I/O, which waits for the I/O operation to complete before continuing with other tasks.
Run Oracle Database Using 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
Summary
I hope it helped you to understand why Oracle database is slow in docker".
Could You Please Share This Post?
I appreciate It And Thank YOU! :)
Have A Nice Day!