(English) How to setup Docker container Oracle Database 12c for Liferay Development Environment

Ci spiace, ma questo articolo è disponibile soltanto in Inglese Americano. Per ragioni di convenienza del visitatore, il contenuto è mostrato sotto nella lingua alternativa. Puoi cliccare sul link per cambiare la lingua attiva.

When we start a new project using Liferay and the project involves the development of new entities, I suggest to set up your own local development environment as closely as possible to the customer’s development environment, particularly as regards the database.

In this article I will explain how to use Docker to setup the Oracle 12c container for use with Liferay. I also recommend reading the article How to build a Docker Liferay 7.2 image with the Oracle Database support.

1. What are the requirements

Before proceeding with the Docker container setup, let’s see what the requirements are.

  1. You need an account on Docker, which you can create from Docker – Signup;
  2. You need to install or update Docker on your PC. Refer to this article for how to install Docker on Windows.

The docker versions on which I have successfully run the Oracle Docker container are: 17.x, 18.x and 19.x. The version of Docker Engine (Community Edition) that I will refer to in this article is 19.03.1 (you can check version with command docker version).

What is shown in this article can be performed on Windows, Unix-like operating systems. In my case I use macOS. However, always refer to the documentation of Docker and Oracle for what concerns the minimal requirements that the target system must have.

2. Oracle Database 12c Docker Image

For some years now, Oracle Database Enterprise Edition 12c is available as an image in Docker Store. From the Docker Store you need to checkout and accept the terms. After accepting the terms you should find yourself on the page that explains the instructions for use.

The following figures show the checkout, acceptance of the terms and get Oracle Database Enterprise Edition. The latest version available is 12c Release 2, this release is the version supported by Liferay (you can see Liferay Digital Experience Platform 7.2 Compatibility Matrix).

 

Figure 1 - Checkout Oracle Database Enterprise Edition

Figure 1 – Checkout Oracle Database Enterprise Edition

 

Figure 2 - Get Oracle Database Enterprise Edition Developer Tier

Figure 2 – Get Oracle Database Enterprise Edition Developer Tier

 

Figure 3 - Setup instruction

Figure 3 – Setup instructions

3. How to starting an Oracle Database Server instance

The next steps to start the Oracle Database container are as follows:

  1. Docker login
  2. Pull Oracle Database Enterprise Edition 12.2.0.1
  3. Run Docker container from image

Following the sequence of commands needed to start the container.

The pull of the Oracle image may take several minutes due to the size of about 4GByte. Following the output of the pull operation.

Figure 4 - Output of the Docker Pull command

Figure 4 – Output of the Docker Pull command

This Oracle database server image uses Docker data volumes to store data files, redo logs, audit logs, alert logs and trace files. The data volume is mounted inside the container at /ORCL. To use a directory on the host system for the data volume, I created the oracle-db-data directory.

The docker run command starts the database with the following features:

  1. Assign the container the name oracle-db-12c
  2. Exposes the TCP/IP SQL Net port 1521
  3. Through the environment variables
    1. Set the SID to ORALFR
    2. Set the PDB to ORALFRPDB
    3. Set the DB Domain to oracledb.liferay.local
  4. Configure volume usage

Obviously you can customize the values of the start parameters to your liking, these are the ones I usually use for my development environment.

You can monitor the start of the container by viewing the logs or using the docker command below.

The figure below shows the output of the docker ps command. You can see the status of the container indicating that it is ready (healthy) for use and port 1521 is exported.

Figure 5 - Output of the Docker ps command for checking status of the oracle-db-12c container

Figure 5 – Output of the Docker ps command for checking status of the oracle-db-12c container

4. Oracle Database Setup for Liferay

We are almost there! Now that our Oracle Database container is up, we need:

  1. Check the block size which should be 8KByte, as requested by Liferay;
  2. Check the character set which should be AL32UTF8, as requested by Liferay;
  3. Creating tablespaces for Liferay data;
  4. User creation and grant assignment

All database operations will be performed via SQLPlus after connecting to the container. The default password to connect to the database with sys user is Oradoc_db1.

The following command executes the SQLPlus on the container.

The figure below shows the size of the block size.

Figure 6 - Check Oracle Block Size

Figure 6 – Check Oracle Block Size

The figure below shows the character set which in this case is correctly configured with AL32UTF8.

Figure 7 – Check character set MUST be AL32UTF8

At this point we proceed with the creation of the tablespaces, one for the data and one for the temporary data. Usually in the development environment, for each Liferay project I prefer to create ad hoc tablespaces and avoid using the default USERS and TEMP tablespaces in order to make database management easier, especially when we have multiple Liferay projects.

Exact recommended size for tablespaces cannot be given because every deployment is different and might be used in various scenarios. Here are a few best practices:

  • Do not start with too large initial size, becuase it can waste space.
  • Do not allow individual data files grow large (beyond 8-10Gb) – it is impractical from a maintenance point of view. Rather add multiple data files (with 8-10Gb maximal size each) instead.
  • Use a single block-size (8K) for the whole DB to avoid buffer pool management pitfalls for non-standard tablespaces (whose block size is different from DB_BLOCK_SIZE).

As a last step we have to create user and assign him the correct grants.

At this point we are in a position to perform a connection test to the new scheme using a tool such as Oracle SQLDeveloper. The following figures show the configuration of the database connection, the view of the Liferay tables and the status of the tablespaces created for Liferay.

The parameters to connect to the new Liferay scheme are:

  • Username/password: liferay_myproject/liferay_myproject
  • Hostname: localhost
  • Service Name: ORALFRPDB.oracledb.liferay.local

 

Figure 8 - Configuring connection to the Oracle database via SQL Developer

Figure 8 – Configuring connection to the Oracle database via SQL Developer

 

Figure 9 - View Liferay Tables

Figure 9 – View Liferay Tables

 

Figure 10 - Overview on the status of the Oracle Database

Figure 10 – Overview on the status of the Oracle Database

Now we can connect our Liferay instance to the Oracle database we have just configured 😉

The figure below also shows the status of the Docker Liferay container that uses the Oracle Database instance that we configured during this article.

Figure 11 - Status of the docker container Liferay and Oracle

Figure 11 – Status of the docker container Liferay and Oracle

Conclusions

In this article I wanted to show you how I usually configure my development environment when I need to have an Oracle Database to be later connected to Liferay.

As you have seen, using Docker makes this all very simple and fast.

Do not hesitate to contact me with any questions and I hope this article has been helpful.

Liferay Portal Security AuditCos'è e come funzione il framework di Security Audit

Vi siete mai chiesti cos'è e come funziona il sistema di Security Audit di Liferay? Ho cercato di rispondere alla domanda non soffermandomi solo al "cosè e come funziona", sono andato ben oltre. Non vi resta che leggere questo EBook per scoprire.

Ottieni il tuo EBook

Antonio Musarra

I began my journey into the world of computing from an Olivetti M24 PC (http://it.wikipedia.org/wiki/Olivetti_M24) bought by my father for his work. Day after day, quickly taking control until … Now doing business consulting for projects in the enterprise application development using web-oriented technologies such as J2EE, Web Services, ESB, TIBCO, PHP.

Potrebbero interessarti anche...

Liferay SSL/TLS SecurityCome configurare il bundle Liferay per abilitare il protocollo SSL/TLS

Sei curioso di scoprire come configurare il bundle Liferay per funzionare in modalità sicura tramite protocollo SSL/TLS? In questo eBook ( #LFRDEPGUIDE ) ti spiego come farlo step-by-step; per il bundle Apache Tomcat e WildFly. Ricorda di lasciare un tuo feedback dopo averlo letto.