diff --git a/OracleDatabase/SingleInstance/COPYRIGHT b/OracleDatabase/SingleInstance/COPYRIGHT index 8adb7c4b5a..1b68add2ed 100644 --- a/OracleDatabase/SingleInstance/COPYRIGHT +++ b/OracleDatabase/SingleInstance/COPYRIGHT @@ -1,4 +1,4 @@ -Copyright (c) 1982 - 2016, Oracle Corporation. All rights reserved. +Copyright (c) 1982 - 2024, Oracle Corporation. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/OracleDatabase/SingleInstance/README.md b/OracleDatabase/SingleInstance/README.md index 9e720e2bae..3d0f099588 100644 --- a/OracleDatabase/SingleInstance/README.md +++ b/OracleDatabase/SingleInstance/README.md @@ -9,15 +9,19 @@ Sample container build files to facilitate installation, configuration, and envi * [Running Oracle Database in a container](#running-oracle-database-in-a-container) * [Running Oracle Database Enterprise and Standard Edition 2 in a container](#running-oracle-database-enterprise-and-standard-edition-2-in-a-container) * [Securely specifying the password when using Podman (Supported from 19.3.0 onwards)](#securely-specifying-the-password-when-using-podman-supported-from-1930-onwards) + * [Encrypting the database password (Supported from 23.4.0 onwards))](#encrypting-the-database-password-supported-from-2340-onwards) * [Selecting the Edition (Supported from 19.3.0 release)](#selecting-the-edition-supported-from-1930-release) * [Setting the SGA and PGA memory (Supported from 19.3.0 release)](#setting-the-sga-and-pga-memory-supported-from-1930-release) * [Setting the CPU_COUNT and PROCESSES (Supported from 19.3.0 release)](#setting-the-cpu_count-and-processes-supported-from-1930-release) * [Changing the admin accounts passwords](#changing-the-admin-accounts-passwords) - * [Enabling archive log mode while creating the database](#enabling-archive-log-mode-while-creating-the-database) + * [Enabling archive log mode and/or force logging mode while creating the database](#enabling-archive-log-mode-andor-force-logging-mode-while-creating-the-database) * [Configuring TCPS connections for Oracle Database (Supported from version 19.3.0 onwards)](#configuring-tcps-connections-for-oracle-database-supported-from-version-1930-onwards) - * [Running Oracle Database 23c FREE in a container](#running-oracle-database-23c-free-in-a-container) + * [Running Oracle Database 23ai Free in a container](#running-oracle-database-23ai-free-in-a-container) * [Running Oracle Database 21c/18c Express Edition in a container](#running-oracle-database-21c18c-express-edition-in-a-container) * [Running Oracle Database 11gR2 Express Edition in a container](#running-oracle-database-11gr2-express-edition-in-a-container) + * [Running Oracle True Cache in a container (Supported from version 23.4.0 onwards)](#running-oracle-true-cache-in-a-container-supported-from-version-2340-onwards) + * [Setting Up the Network for Communication Between the Primary Database and the True Cache Container](#setting-up-the-network-for-communication-between-the-primary-database-and-the-true-cache-container) + * [Running Oracle Database Free True Cache in a Container](#running-oracle-database-free-true-cache-in-a-container) * [Containerizing an on-premise database (Supported from version 19.3.0 release)](#containerizing-an-on-premise-database-supported-from-version-1930-release) * [Deploying Oracle Database on Kubernetes](#deploying-oracle-database-on-kubernetes) * [Running SQL*Plus in a container](#running-sqlplus-in-a-container) @@ -32,7 +36,7 @@ Sample container build files to facilitate installation, configuration, and envi This project offers sample Dockerfiles for: -* Oracle Database 23c (23.3.0) Free +* Oracle Database 23ai (23.4.0) Free * Oracle Database 21c (21.3.0) Enterprise Edition, Standard Edition 2 and Express Edition (XE) * Oracle Database 19c (19.3.0) Enterprise Edition and Standard Edition 2 * Oracle Database 18c (18.4.0) Express Edition (XE) @@ -47,7 +51,7 @@ The `buildContainerImage.sh` script is just a utility shell script that performs ### Building Oracle Database container images -**IMPORTANT:** You will have to provide the installation binaries of Oracle Database (except for Oracle Database 18c XE, 21c XE and 23c FREE) and put them into the `dockerfiles/` folder. +**IMPORTANT:** You will have to provide the installation binaries of Oracle Database (except for Oracle Database 18c XE, 21c XE and 23ai Free) and put them into the `dockerfiles/` folder. You only need to provide the binaries for the edition you are going to install. The binaries can be downloaded from the [Oracle Technology Network](http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html), make sure you use the linux link: *Linux x86-64*. The needed file is named *linuxx64_\_database.zip*. **Linux ARM64 Support:** Oracle Database 19c Enterprise Edition is now supported on ARM64 platforms. You will have to provide the installation binaries of [Oracle Database 19c](https://www.oracle.com/database/technologies/oracle19c-linux-arm64-downloads.html) and put them into the dockerfiles/19.3.0 folder. The needed file is named *LINUX.ARM64_1919000_db_home.zip*. @@ -63,7 +67,7 @@ Before you build the image make sure that you have provided the installation bin Parameters: -v: version to build - Choose one of: 11.2.0.2 12.1.0.2 12.2.0.1 18.3.0 18.4.0 19.3.0 21.3.0 23.3.0 + Choose one of: 11.2.0.2 12.1.0.2 12.2.0.1 18.3.0 18.4.0 19.3.0 21.3.0 23.4.0 -t: image_name:tag for the generated docker image -e: creates image based on 'Enterprise Edition' -s: creates image based on 'Standard Edition 2' @@ -78,7 +82,7 @@ Before you build the image make sure that you have provided the installation bin LICENSE UPL 1.0 - Copyright (c) 2014,2023 Oracle and/or its affiliates. + Copyright (c) 2014,2024 Oracle and/or its affiliates. **IMPORTANT:** The resulting images will be an image with the Oracle binaries installed. On first startup of the container a new database will be created, the following lines highlight when the database is ready to be used: @@ -133,9 +137,10 @@ To run your Oracle Database image use the `docker run` command as follows: -e ORACLE_EDITION= \ -e ORACLE_CHARACTERSET= \ -e ENABLE_ARCHIVELOG=true \ + -e ENABLE_FORCE_LOGGING=true \ -e ENABLE_TCPS=true \ -v [:]/opt/oracle/oradata \ - oracle/database:21.3.0-ee + oracle/database:21.3.0-ee Parameters: --name: The name of the container (default: auto generated). @@ -172,6 +177,9 @@ To run your Oracle Database image use the `docker run` command as follows: -e ENABLE_ARCHIVELOG: To enable archive log mode when creating the database (default: false). Supported by Oracle Database 19.3 onwards. + -e ENABLE_FORCE_LOGGING: + To enable force logging mode when creating the database (default: false). + Supported by Oracle Database 23.4 onwards. -e ENABLE_TCPS: To enable TCPS connections for Oracle Database. Supported by Oracle Database 19.3 onwards. @@ -180,7 +188,7 @@ To run your Oracle Database image use the `docker run` command as follows: Supported by Oracle Database 19.3 onwards. -v /opt/oracle/oradata The data volume to use for the database. - Has to be writable by the Unix "oracle" (uid: 54321) user inside the container! + Has to be writable by the Unix "oracle" (uid: 54321) user inside the container. If omitted the database will not be persisted over container recreation. -v /opt/oracle/scripts/startup | /docker-entrypoint-initdb.d/startup Optional: A volume with custom scripts to be run after database startup. @@ -211,6 +219,34 @@ The Oracle Database inside the container also has Oracle Enterprise Manager Expr # Running the Oracle Database 21c XE image with the secret podman run -d --name= --secret=oracle_pwd oracle/database:21.3.0-xe +##### Encrypting the database password (Supported from 23.4.0 onwards) + +Users can generate public-private key pair and pass database password (encrypted) and decryption (private) key to the container securely. + +* Generate public-private key pair. + + openssl genrsa -out key.pem + openssl rsa -in key.pem -out key.pub -pubout + +* Create an Oracle Database password file. + + echo "" > pwd.txt + +* Encrypt the password file using the public key (key.pub) + + openssl pkeyutl -in pwd.txt -out encrypted_pwd.txt -pubin -inkey key.pub -encrypt + + You should make sure you delete the pwd.txt once done + +* Create a podman secret for both the encrypted password file and the decrytion key (key.pem). + + podman secret create oracle_pwd encrypted_pwd.txt + podman secret create oracle_pwd_privkey key.pem + +* Run the Oracle Database 23ai Free image with the secrets + + podman run -td --name= --secret=oracle_pwd --secret=oracle_pwd_privkey oracle/database:23.4.0-free + #### Selecting the Edition (Supported from 19.3.0 release) The edition of the database can be changed during runtime by passing the ORACLE_EDITION parameter to the `docker run` command. Therefore, an enterprise container image can be used to run standard edition database and vice-versa. You can find the edition of the running database in the output line: @@ -241,11 +277,11 @@ The password for those accounts can be changed via the `docker exec` command. ** This new password will be used afterwards. -#### Enabling archive log mode while creating the database +#### Enabling archive log mode and/or force logging mode while creating the database -Archive mode can be enabled during the first time when database is created by setting ENABLE_ARCHIVELOG to `true` and passing it to `docker run` command. Archive logs are stored at the directory location: `/opt/oracle/oradata/$ORACLE_SID/archive_logs` inside the container. +Archive mode and/or force logging mode can be enabled during the first time when database is created by setting ENABLE_ARCHIVELOG and/or ENABLE_FORCE_LOGGING to `true` and passing them to `docker run` command. Archive logs are stored at the directory location: `/opt/oracle/oradata/$ORACLE_SID/archive_logs` inside the container. -In case this parameter is set `true` and passed to `docker run` command while reusing existing datafiles, even though this parameter would be visible as set to `true` in the container environment, this would not be set inside the database. The value used at the time of database creation will be used. +In case these parameter are set `true` and passed to `docker run` command while reusing existing datafiles, even though these parameter would be visible as set to `true` in the container environment, these would not be set inside the database. The values used at the time of database creation will be used. #### Configuring TCPS connections for Oracle Database (Supported from version 19.3.0 onwards) @@ -319,32 +355,38 @@ To configure wallet password, please use the following command: After certificate renewal, the client wallet should be updated by downloading it again. * Supports Oracle Database XE version 21.3.0 onwards. -#### Running Oracle Database 23c FREE in a container +#### Running Oracle Database 23ai Free in a container -To run your Oracle Database 23c FREE container image use the `docker run` command as follows: +To run your Oracle Database 23ai Free container image use the `podman run` command as follows: podman run --name \ -p :1521 \ -e ORACLE_PWD= \ -e ORACLE_CHARACTERSET= \ + -e ENABLE_ARCHIVELOG=true \ + -e ENABLE_FORCE_LOGGING=true \ -v [:]/opt/oracle/oradata \ - oracle/database:23.3.0-free + oracle/database:23.4.0-free Parameters: --name: The name of the container (default: auto generated) -p: The port mapping of the host port to the container port. - Two ports are exposed: 1521 (Oracle Listener), 5500 (EM Express) + Only one port is exposed: 1521 (Oracle Listener) -e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated) -e ORACLE_CHARACTERSET: The character set to use when creating the database (default: AL32UTF8) + -e ENABLE_ARCHIVELOG: + To enable archive log mode when creating the database (default: false) + -e ENABLE_FORCE_LOGGING: + To enable force logging mode when creating the database (default: false) -v /opt/oracle/oradata The data volume to use for the database. - Has to be writable by the Unix "oracle" (uid: 54321) user inside the container! + Has to be writable by the Unix "oracle" (uid: 54321) user inside the container. If omitted the database will not be persisted over container recreation. - -v /opt/oracle/scripts/startup | /docker-entrypoint-initdb.d/startup + -v /opt/oracle/scripts/startup Optional: A volume with custom scripts to be run after database startup. For further details see the "Running scripts after setup and on startup" section below. - -v /opt/oracle/scripts/setup | /docker-entrypoint-initdb.d/setup + -v /opt/oracle/scripts/setup Optional: A volume with custom scripts to be run after database setup. For further details see the "Running scripts after setup and on startup" section below. @@ -359,7 +401,7 @@ On the first startup of the container a random password will be generated for th podman exec /opt/oracle/setPassword.sh **Important Note:** -The ORACLE_SID for Oracle Database 23c FREE is always `FREE` and cannot be changed, hence there is no ORACLE_SID parameter provided for the FREE build. +The ORACLE_SID for Oracle Database 23ai Free is always `FREE` and cannot be changed, hence there is no ORACLE_SID parameter provided for the Free build. #### Running Oracle Database 21c/18c Express Edition in a container @@ -456,6 +498,79 @@ Once the container has been started you can connect to it just like to any other sqlplus sys/@//localhost:1521/XE as sysdba sqlplus system/@//localhost:1521/XE +### Running Oracle True Cache in a container (Supported from version 23.4.0 onwards) + +Oracle True Cache is an in-memory, consistent, and automatically managed cache for Oracle Database. For more information about Oracle True Cache please see the [Oracle True Cache Online Documentation](https://docs.oracle.com/en/database/oracle/oracle-database/23/odbtc/overview-oracle-true-cache.html). + +#### Setting Up the Network for Communication Between the Primary Database and the True Cache Container + +* Oracle Database Free True Cache container (True Cache container) and the Oracle Database Free Primary Database container (Primary Database container) must be on the same podman network to communicate with each other.\ +Set up a podman network for inter-container communication using the following command which creates a bridge connection enabling communication between containers on the same host. + + podman network create tc_net + + Fetch the default subnet assigned to above network by running the following command: + + podman inspect tc_net | grep -iw 'subnet' + + Pick any two IP addresses from the preceding subnet and assign one for the Primary Database container (say, PRI_DB_FREE_IP) and the other for the True Cache container (say, TRU_CC_FREE_IP). + + For communication across hosts, create a macvlan or ipvlan connection per [documentation](https://docs.podman.io/en/latest/markdown/podman-network-create.1.html). \ + Specify the preceding podman network using the --net option to the podman run command of both the Primary Database container and the True Cache container as shown in following sections. + +#### Running Oracle Database Free True Cache in a Container + +* Launch the Oracle Database Free Primary Database container using the `podman run` command as follows: + + podman run -td --name pri-db-free \ + --hostname pri-db-free \ + --net=tc_net \ + --ip \ + -p :1521 \ + --secret=oracle_pwd \ + -e ENABLE_ARCHIVELOG=true \ + -e ENABLE_FORCE_LOGGING=true \ + -v [:]/opt/oracle/oradata \ + oracle/database:23.4.0-free + + Ensure that your Primary Database container is up and running and in a healthy state. + + **Note:** Enable archive logging and optionally force logging in the Primary Database to support True Cache. These are not enabled by default in the prebuilt database image. +You need to run the preceding podman run command with the host mount point (empty directory) so that a new database setup will start with these options enabled. Otherwise, you must run sql commands manually from the pri-db-free container to enable these options. + +* Launch the Oracle Database Free True Cache container using the `podman run` command as follows: + + podman run -td --name tru-cc-free \ + --hostname tru-cc-free \ + --net=tc_net \ + --ip \ + -p :1521 \ + --secret=oracle_pwd \ + -e TRUE_CACHE=true \ + -e PRIMARY_DB_PWD_FILE=/var/tmp/orapwFREE \ + -e PRIMARY_DB_CONN_STR=:1521/FREE \ + -v [:]/opt/oracle/oradata \ + oracle/database:23.4.0-free + + **Note:** If a common host mount point is used for both pri-db-free and tru-cc-free containers, then you may skip the podman cp step by specifying the location of pri-db-free password file directly using \ + -e PRIMARY_DB_PWD_FILE=/opt/oracle/product/23ai/dbhomeFree/dbs/orapwFREE + +* For different host mount points, copy password file (example 'orapwFREE') from the Primary Database container to the True Cache container at location $PRIMARY_DB_PWD_FILE (/var/tmp/orapwFREE) using podman cp command as follows: + + podman cp pri-db-free:/opt/oracle/product/23ai/dbhomeFree/dbs/orapwFREE tru-cc-free:/var/tmp/ + +* Once the True Cache container turns healthy, create database application services (sales_tc and sales_pdb_tc) for the True Cache by running the following commands from the pri-db-free container: + + podman exec -it pri-db-free bash + + $ORACLE_HOME/bin/dbca -configureDatabase -configureTrueCacheInstanceService -sourceDB FREE \ + -trueCacheConnectString :1521/FREE -trueCacheServiceName sales_tc -serviceName FREE \ + -sysPassword $(cat /run/secrets/oracle_pwd) -silent + + $ORACLE_HOME/bin/dbca -configureDatabase -configureTrueCacheInstanceService -sourceDB FREE \ + -trueCacheConnectString :1521/FREE -trueCacheServiceName sales_pdb_tc -serviceName FREEPDB1 \ + -pdbName FREEPDB1 -sysPassword $(cat /run/secrets/oracle_pwd) -silent + ### Containerizing an on-premise database (Supported from version 19.3.0 release) To containerize an on-premise database, please follow the steps mentioned below: @@ -534,4 +649,4 @@ All scripts and files hosted in this project and GitHub [docker-images/OracleDat ## Copyright -Copyright (c) 2014,2023 Oracle and/or its affiliates. +Copyright (c) 2014,2024 Oracle and/or its affiliates. diff --git a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/createDB.sh b/OracleDatabase/SingleInstance/dockerfiles/23.3.0/createDB.sh deleted file mode 100644 index 0ed3cb0c0d..0000000000 --- a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/createDB.sh +++ /dev/null @@ -1,305 +0,0 @@ -#!/bin/bash -# LICENSE UPL 1.0 -# -# Copyright (c) 1982-2023 Oracle and/or its affiliates. All rights reserved. -# -# Since: November, 2016 -# Author: gerald.venzl@oracle.com -# Description: Creates an Oracle Database based on following parameters: -# $ORACLE_SID: The Oracle SID and CDB name -# $ORACLE_PDB: The PDB name -# $ORACLE_PWD: The Oracle password -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. -# - -set -e - -############## Setting up network related config files (sqlnet.ora, listener.ora) ############## -function setupNetworkConfig { - mkdir -p "$ORACLE_HOME"/network/admin - - # sqlnet.ora - echo "NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, HOSTNAME) -DISABLE_OOB=ON" > "$ORACLE_HOME"/network/admin/sqlnet.ora - - # listener.ora - echo "LISTENER = -(DESCRIPTION_LIST = - (DESCRIPTION = - (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1)) - (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521)) - ) -) - -DEDICATED_THROUGH_BROKER_LISTENER=ON -DIAG_ADR_ENABLED = off -" > "$ORACLE_HOME"/network/admin/listener.ora - -} - -function setupTnsnames { - mkdir -p "$ORACLE_HOME"/network/admin - - # tnsnames.ora - echo "$ORACLE_SID=localhost:1521/$ORACLE_SID" > "$ORACLE_HOME"/network/admin/tnsnames.ora - echo "$ORACLE_PDB= -(DESCRIPTION = - (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521)) - (CONNECT_DATA = - (SERVER = DEDICATED) - (SERVICE_NAME = $ORACLE_PDB) - ) -)" >> "$ORACLE_HOME"/network/admin/tnsnames.ora - -} - -function setupNetworkConfigFREE { - # sqlnet.ora - echo "NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, HOSTNAME) -DISABLE_OOB=ON" > "$ORACLE_HOME"/network/admin/sqlnet.ora - - # listener.ora - echo "# listener.ora Network Configuration File: - -SID_LIST_LISTENER = - (SID_LIST = - (SID_DESC = - (SID_NAME = PLSExtProc) - (ORACLE_HOME = $ORACLE_HOME) - (PROGRAM = extproc) - ) - ) - -LISTENER = - (DESCRIPTION_LIST = - (DESCRIPTION = - (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_FREE)) - (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521)) - ) - ) - -DEFAULT_SERVICE_LISTENER = (FREE))" > "$ORACLE_HOME"/network/admin/listener.ora - -# TNS Names.ora - echo "# tnsnames.ora Network Configuration File: - -FREE = - (DESCRIPTION = - (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521)) - (CONNECT_DATA = - (SERVER = DEDICATED) - (SERVICE_NAME = FREE) - ) - ) - -LISTENER_FREE = - (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521)) - -FREEPDB1 = - (DESCRIPTION = - (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521)) - (CONNECT_DATA = - (SERVER = DEDICATED) - (SERVICE_NAME = FREEPDB1) - ) - ) - -EXTPROC_CONNECTION_DATA = - (DESCRIPTION = - (ADDRESS_LIST = - (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_FREE)) - ) - (CONNECT_DATA = - (SID = PLSExtProc) - (PRESENTATION = RO) - ) - ) -" > "$ORACLE_HOME"/network/admin/tnsnames.ora -} - -function dbSetupSQL { - # Remove second control file, fix local_listener, make PDB auto open, enable EM global port - # Create externally mapped oracle user for health check - sqlplus / as sysdba << EOF -ALTER SYSTEM SET control_files='$ORACLE_BASE/oradata/$ORACLE_SID/control01.ctl' scope=spfile; -ALTER SYSTEM SET local_listener=''; -ALTER PLUGGABLE DATABASE $ORACLE_PDB SAVE STATE; - -ALTER SESSION SET "_oracle_script" = true; -CREATE USER OPS\$oracle IDENTIFIED EXTERNALLY; -GRANT CREATE SESSION TO OPS\$oracle; -GRANT SELECT ON sys.v_\$pdbs TO OPS\$oracle; -GRANT SELECT ON sys.v_\$database TO OPS\$oracle; -ALTER USER OPS\$oracle SET container_data=all for sys.v_\$pdbs container = current; - -exit; -EOF - -} - -################################### -# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # -############# MAIN ################ -# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # -################################### - -# Creating database for FREE edition -if [ "${ORACLE_SID}" = "FREE" ]; then - # Auto generate ORACLE PWD if not passed on - export ORACLE_PWD=${ORACLE_PWD:-"$(openssl rand -hex 8)"} - - # Set character set - su -c "sed -i -e \"s|^CHARSET=.*$|CHARSET=$ORACLE_CHARACTERSET|g\" /etc/sysconfig/\"$CONF_FILE\"" - - # Creating Database - su -c "/etc/init.d/oracle-free-23c configure << EOF -${ORACLE_PWD} -${ORACLE_PWD} -EOF -" -# Setting up network config for FREE database -setupNetworkConfigFREE; - -# Setting up database -dbSetupSQL; - -exit 0 -fi; - -# Check whether ORACLE_SID is passed on -export ORACLE_SID=${1:-ORCLCDB} - -# Check whether ORACLE_PDB is passed on -export ORACLE_PDB=${2:-ORCLPDB1} - -# Setting up file creation mask for newly created files (dbca response templates) -umask 177 - -# Checking if only one of INIT_SGA_SIZE & INIT_PGA_SIZE is provided by the user -if [[ "${INIT_SGA_SIZE}" != "" && "${INIT_PGA_SIZE}" == "" ]] || [[ "${INIT_SGA_SIZE}" == "" && "${INIT_PGA_SIZE}" != "" ]]; then - echo "ERROR: Provide both the values, INIT_SGA_SIZE and INIT_PGA_SIZE or neither of them. Exiting."; - exit 1; -fi; - -# If wallet is present for database credentials then prepare dbca options to use -if [[ -n "${WALLET_DIR}" ]] && [[ -f $WALLET_DIR/ewallet.p12 ]]; then - # Oracle Wallet is present - export DBCA_CRED_OPTIONS="-useWalletForDBCredentials true -dbCredentialsWalletLocation ${WALLET_DIR}" -else - if [[ "${CLONE_DB}" == "true" ]] || [[ "${STANDBY_DB}" == "true" ]]; then - # Validation: Checking if ORACLE_PWD is provided or not - if [[ -z "$ORACLE_PWD" ]]; then - echo "ERROR: Please provide sys password of the primary database as ORACLE_PWD env variable. Exiting..." - exit 1 - fi - - # Creating temporary response file containing sysPassword for clone/standby cases - cat > "$ORACLE_BASE"/dbca.rsp <:/ format to connect with primary database. Exiting..." - exit 1 - fi - - # Primary database parameters extration - PRIMARY_DB_NAME=$(echo "${PRIMARY_DB_CONN_STR}" | cut -d '/' -f 2) - - # Creating the database using the dbca command - if [ "${STANDBY_DB}" = "true" ]; then - # Creating standby database - dbca -silent -createDuplicateDB -gdbName "$PRIMARY_DB_NAME" -primaryDBConnectionString "$PRIMARY_DB_CONN_STR" "${DBCA_CRED_OPTIONS}" -sid "$ORACLE_SID" -createAsStandby -dbUniquename "$ORACLE_SID" ORACLE_HOSTNAME="$ORACLE_HOSTNAME" || - cat /opt/oracle/cfgtoollogs/dbca/"$ORACLE_SID"/"$ORACLE_SID".log || - cat /opt/oracle/cfgtoollogs/dbca/"$ORACLE_SID".log - else - # Creating clone database after duplicating a primary database; CLONE_DB is set to true here - dbca -silent -createDuplicateDB -gdbName "$ORACLE_SID" -primaryDBConnectionString "$PRIMARY_DB_CONN_STR" "${DBCA_CRED_OPTIONS}" -sid "$ORACLE_SID" -databaseConfigType SINGLE -useOMF true -dbUniquename "$ORACLE_SID" ORACLE_HOSTNAME="$ORACLE_HOSTNAME" || - cat /opt/oracle/cfgtoollogs/dbca/"$ORACLE_SID"/"$ORACLE_SID".log || - cat /opt/oracle/cfgtoollogs/dbca/"$ORACLE_SID".log - fi - - # Setup tnsnames.ora after execution of DBCA command to prevent getting overwritten - setupTnsnames; - - # Stopping the Listener - lsnrctl stop; - - # Setup network related configuration - setupNetworkConfig; - - # Starting Listener - lsnrctl start; - - # Remove temporary response file - if [ -f "$ORACLE_BASE"/dbca.rsp ]; then - rm "$ORACLE_BASE"/dbca.rsp - fi - - exit 0 -fi - -# Replace place holders in response file -cp "$ORACLE_BASE"/"$CONFIG_RSP" "$ORACLE_BASE"/dbca.rsp -# Reverting umask to original value -umask 022 -sed -i -e "s|###ORACLE_SID###|$ORACLE_SID|g" "$ORACLE_BASE"/dbca.rsp -sed -i -e "s|###ORACLE_PDB###|$ORACLE_PDB|g" "$ORACLE_BASE"/dbca.rsp -sed -i -e "s|###ORACLE_CHARACTERSET###|$ORACLE_CHARACTERSET|g" "$ORACLE_BASE"/dbca.rsp -if [[ -n "${WALLET_DIR}" ]] && [[ -f $WALLET_DIR/ewallet.p12 ]] || [[ -z "$ORACLE_PWD" ]]; then - # Deleting password options from dbca response file as wallet will be used for credentials or ORACLE_PWD is not provided (i.e. password auto-generation intended) - sed -i -e "/###ORACLE_PWD###/d" "$ORACLE_BASE"/dbca.rsp -else - sed -i -e "s|###ORACLE_PWD###|$ORACLE_PWD|g" "$ORACLE_BASE"/dbca.rsp -fi - -# If both INIT_SGA_SIZE & INIT_PGA_SIZE aren't provided by user -if [[ "${INIT_SGA_SIZE}" == "" && "${INIT_PGA_SIZE}" == "" ]]; then - # If AUTO_MEM_CALCULATION isn't set to false and a given amount of memory is allocated, - # we set the total memory with the amount of memory allocated for the container. - # Otherwise, we keep the default of 2GB. - if [[ "${AUTO_MEM_CALCULATION}" != "false" && "${ALLOCATED_MEMORY}" -le 655360 ]]; then - sed -i -e "s|totalMemory=.*|totalMemory=${ALLOCATED_MEMORY?}|g" "$ORACLE_BASE"/dbca.rsp - fi -else - sed -i -e "s|totalMemory=.*||g" "$ORACLE_BASE"/dbca.rsp - sed -i -e "s|initParams=.*|&,sga_target=${INIT_SGA_SIZE}M,pga_aggregate_target=${INIT_PGA_SIZE}M|g" "$ORACLE_BASE"/dbca.rsp -fi; - -# Create network related config files (sqlnet.ora, tnsnames.ora, listener.ora) -setupNetworkConfig; - -# Directory for storing archive logs -export ARCHIVELOG_DIR=$ORACLE_BASE/oradata/$ORACLE_SID/$ARCHIVELOG_DIR_NAME - -# Start LISTENER and run DBCA -lsnrctl start && -dbca -silent -createDatabase -enableArchive "$ENABLE_ARCHIVELOG" -archiveLogDest "$ARCHIVELOG_DIR" "${DBCA_CRED_OPTIONS}" -responseFile "$ORACLE_BASE"/dbca.rsp || - cat /opt/oracle/cfgtoollogs/dbca/"$ORACLE_SID"/"$ORACLE_SID".log || - cat /opt/oracle/cfgtoollogs/dbca/"$ORACLE_SID".log - -# Setup tnsnames.ora after execution of DBCA command to prevent getting overwritten -setupTnsnames; - -# Setting up database -dbSetupSQL; - -# Remove temporary response file -rm "$ORACLE_BASE"/dbca.rsp diff --git a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/Containerfile.free b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/Containerfile.free similarity index 80% rename from OracleDatabase/SingleInstance/dockerfiles/23.3.0/Containerfile.free rename to OracleDatabase/SingleInstance/dockerfiles/23.4.0/Containerfile.free index c1727c4dca..e98c80c14f 100644 --- a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/Containerfile.free +++ b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/Containerfile.free @@ -1,10 +1,10 @@ # LICENSE UPL 1.0 # -# Copyright (c) 2022-2023 Oracle and/or its affiliates. +# Copyright (c) 2022-2024 Oracle and/or its affiliates. # # ORACLE DOCKERFILES PROJECT # -------------------------- -# This is the Contatinerfile for Oracle Database 23c Free +# This is the Contatinerfile for Oracle Database 23ai Free # # REQUIRED FILES TO BUILD THIS IMAGE # ---------------------------------- @@ -13,7 +13,7 @@ # HOW TO BUILD THIS IMAGE # ----------------------- # Run: -# $ podman build -t oracle/database:23.3.0-free -f Containerfile.free . +# $ podman build -t oracle/database:23.4.0-free -f Containerfile.free . # # # Pull base image @@ -31,22 +31,23 @@ LABEL "provider"="Oracle" \ "volume.startup.location2"="/docker-entrypoint-initdb.d/startup" \ "port.listener"="1521" -ARG INSTALL_FILE_1="https://download.oracle.com/otn-pub/otn_software/db-free/oracle-database-free-23c-1.0-1.el8.x86_64.rpm" +ARG INSTALL_FILE_1="https://download.oracle.com/otn-pub/otn_software/db-free/oracle-database-free-23ai-1.0-1.el8.x86_64.rpm" # Environment variables required for this build (do NOT change) # ------------------------------------------------------------- ENV ORACLE_BASE=/opt/oracle \ - ORACLE_HOME=/opt/oracle/product/23c/dbhomeFree \ + ORACLE_HOME=/opt/oracle/product/23ai/dbhomeFree \ ORACLE_SID=FREE \ INSTALL_FILE_1=$INSTALL_FILE_1 \ RUN_FILE="runOracle.sh" \ PWD_FILE="setPassword.sh" \ CREATE_DB_FILE="createDB.sh" \ USER_SCRIPTS_FILE="runUserScripts.sh" \ - CONF_FILE="oracle-free-23c.conf" \ + CONF_FILE="oracle-free-23ai.conf" \ CHECK_SPACE_FILE="checkSpace.sh" \ CHECK_DB_FILE="checkDBStatus.sh" \ SETUP_LINUX_FILE="setupLinuxEnv.sh" \ + DECRYPT_PWD_FILE="decryptPassword.sh" \ CONFIG_TCPS_FILE="configTcps.sh" \ INSTALL_DIR="$HOME/install" \ ORACLE_DOCKER_INSTALL="true" \ @@ -57,13 +58,13 @@ ENV PATH=$ORACLE_HOME/bin:$PATH # Copy binaries # ------------- -COPY $CHECK_SPACE_FILE $CONF_FILE $SETUP_LINUX_FILE $RUN_FILE $PWD_FILE $CHECK_DB_FILE $CREATE_DB_FILE $USER_SCRIPTS_FILE $CONFIG_TCPS_FILE $INSTALL_DIR/ +COPY $CHECK_SPACE_FILE $CONF_FILE $SETUP_LINUX_FILE $RUN_FILE $PWD_FILE $CHECK_DB_FILE $CREATE_DB_FILE $USER_SCRIPTS_FILE $CONFIG_TCPS_FILE $DECRYPT_PWD_FILE $INSTALL_DIR/ WORKDIR $INSTALL_DIR # hadolint ignore=DL3003,DL3033,SC2035 RUN mkdir -p "$ORACLE_BASE" && \ - mv "$RUN_FILE" "$PWD_FILE" "$CHECK_DB_FILE" "$CREATE_DB_FILE" "$USER_SCRIPTS_FILE" "$CONFIG_TCPS_FILE" "$ORACLE_BASE"/ && \ + mv "$RUN_FILE" "$PWD_FILE" "$CHECK_DB_FILE" "$CREATE_DB_FILE" "$USER_SCRIPTS_FILE" "$CONFIG_TCPS_FILE" "$DECRYPT_PWD_FILE" "$ORACLE_BASE"/ && \ chmod ug+x *.sh && \ sync && \ ./"$CHECK_SPACE_FILE" && \ @@ -82,10 +83,11 @@ RUN mkdir -p "$ORACLE_BASE" && \ FROM base AS builder -# Install DB software binaries -RUN yum -y install expect && \ - unbuffer yum -y install "$INSTALL_FILE_1" +# Copy DB install file +ADD $INSTALL_FILE_1 $INSTALL_DIR/ +# Install DB software binaries +RUN unbuffer yum -y localinstall "$INSTALL_DIR/$(basename $INSTALL_FILE_1)" ############################################# # ------------------------------------------- @@ -98,8 +100,8 @@ FROM base USER oracle COPY --chown=oracle:oinstall --from=builder $ORACLE_BASE $ORACLE_BASE COPY --chown=oracle:oinstall --from=builder /etc/oratab /etc/oratab -COPY --from=builder /etc/init.d/oracle-free-23c /etc/init.d/oracle-free-23c -COPY --from=builder /usr/share/doc/oracle-free-23c/LICENSE /usr/share/doc/oracle-free-23c/LICENSE +COPY --from=builder /etc/init.d/oracle-free-23ai /etc/init.d/oracle-free-23ai +COPY --from=builder /usr/share/doc/oracle-free-23ai/LICENSE /usr/share/doc/oracle-free-23ai/LICENSE USER root # To enforce ORACLE_SID as FREE, adding it to .bashrc diff --git a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/checkDBStatus.sh b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/checkDBStatus.sh old mode 100644 new mode 100755 similarity index 81% rename from OracleDatabase/SingleInstance/dockerfiles/23.3.0/checkDBStatus.sh rename to OracleDatabase/SingleInstance/dockerfiles/23.4.0/checkDBStatus.sh index fcf93702a2..e66feeb655 --- a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/checkDBStatus.sh +++ b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/checkDBStatus.sh @@ -1,7 +1,7 @@ #!/bin/bash # LICENSE UPL 1.0 # -# Copyright (c) 1982-2023 Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1982-2024 Oracle and/or its affiliates. All rights reserved. # # Since: May, 2017 # Author: gerald.venzl@oracle.com @@ -27,7 +27,7 @@ EOF # Store return code from SQL*Plus ret=$? - if [ $ret -eq 0 ] && [ "$DB_ROLE" != "PRIMARY" ] && [ "$DB_ROLE" != "PHYSICAL STANDBY" ]; then + if [ $ret -eq 0 ] && [ "$DB_ROLE" != "PRIMARY" ] && [ "$DB_ROLE" != "PHYSICAL STANDBY" ] && [ "$DB_ROLE" != "TRUE CACHE" ]; then exit 1 elif [ $ret -ne 0 ]; then exit 3 @@ -48,10 +48,14 @@ EOF # Store return code from SQL*Plus ret=$? - if [ $ret -eq 0 ] && [ "$DB_ROLE" = "PRIMARY" ] && ! echo "$PDB_OPEN_MODE" | grep -q "READ WRITE"; then + if [ $ret -eq 0 ] && echo "$PDB_OPEN_MODE" | grep -q "MOUNTED"; then + exit 5 + elif [ $ret -eq 0 ] && [ "$DB_ROLE" = "PRIMARY" ] && ! echo "$PDB_OPEN_MODE" | grep -q "READ WRITE"; then exit 2 elif [ $ret -eq 0 ] && [ "$DB_ROLE" = "PHYSICAL STANDBY" ] && [ "$PDB_OPEN_MODE" != "READ ONLY" ]; then exit 2 + elif [ $ret -eq 0 ] && [ "$DB_ROLE" = "TRUE CACHE" ] && [ "$PDB_OPEN_MODE" != "READ ONLY" ]; then + exit 2 elif [ $ret -ne 0 ]; then exit 3 fi @@ -73,11 +77,8 @@ EOF ################ MAIN ####################### ############################################# -# Setting up ORACLE_PWD if podman secret is passed on -if [ -e '/run/secrets/oracle_pwd' ]; then - ORACLE_PWD="$(cat '/run/secrets/oracle_pwd')" - export ORACLE_PWD -fi +ORACLE_PWD=$($ORACLE_BASE/$DECRYPT_PWD_FILE) +export ORACLE_PWD # Sanitizing env for FREE Database if [ "${ORACLE_SID}" = "FREE" ]; then diff --git a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/checkSpace.sh b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/checkSpace.sh old mode 100644 new mode 100755 similarity index 93% rename from OracleDatabase/SingleInstance/dockerfiles/23.3.0/checkSpace.sh rename to OracleDatabase/SingleInstance/dockerfiles/23.4.0/checkSpace.sh index 5ff5d3fe8c..cf730ce4a7 --- a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/checkSpace.sh +++ b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/checkSpace.sh @@ -1,7 +1,7 @@ #!/bin/bash # LICENSE UPL 1.0 # -# Copyright (c) 1982-2023 Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1982-2024 Oracle and/or its affiliates. All rights reserved. # # Since: January, 2017 # Author: gerald.venzl@oracle.com diff --git a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/configTcps.sh b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/configTcps.sh old mode 100644 new mode 100755 similarity index 96% rename from OracleDatabase/SingleInstance/dockerfiles/23.3.0/configTcps.sh rename to OracleDatabase/SingleInstance/dockerfiles/23.4.0/configTcps.sh index ea80110532..16d07b4f7b --- a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/configTcps.sh +++ b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/configTcps.sh @@ -1,7 +1,7 @@ #!/bin/bash # LICENSE UPL 1.0 # -# Copyright (c) 1982-2023 Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1982-2024 Oracle and/or its affiliates. All rights reserved. # # Since: August, 2022 # Author: abhishek.by.kumar@oracle.com @@ -96,6 +96,9 @@ SSL_CLIENT_AUTHENTICATION = FALSE" | tee -a "$ORACLE_BASE"/oradata/dbconfig/"$OR # Disable OOB in sqlnet.ora of DB wallet echo "DISABLE_OOB=ON" >> "$ORACLE_BASE"/oradata/dbconfig/"$ORACLE_SID"/sqlnet.ora + # To prevent Oracle from running out of processes because of abnormal client terminations + echo "SQLNET.EXPIRE_TIME=3" >> "$ORACLE_BASE"/oradata/dbconfig/"$ORACLE_SID"/sqlnet.ora + # Add listener for TCPS sed -i "/TCP/a\ \ \ \ \ (ADDRESS = (PROTOCOL = TCPS)(HOST = 0.0.0.0)(PORT = ${TCPS_PORT})) diff --git a/OracleDatabase/SingleInstance/dockerfiles/23.4.0/createDB.sh b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/createDB.sh new file mode 100755 index 0000000000..baf4cd696d --- /dev/null +++ b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/createDB.sh @@ -0,0 +1,348 @@ +#!/bin/bash +# LICENSE UPL 1.0 +# +# Copyright (c) 1982-2024 Oracle and/or its affiliates. All rights reserved. +# +# Since: November, 2016 +# Author: gerald.venzl@oracle.com +# Description: Creates an Oracle Database based on following parameters: +# $ORACLE_SID: The Oracle SID and CDB name +# $ORACLE_PDB: The PDB name +# $ORACLE_PWD: The Oracle password +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. +# + +set -e + +############## Setting up network related config files (sqlnet.ora, listener.ora) ############## +function setupNetworkConfig { + mkdir -p "$ORACLE_HOME"/network/admin + + # sqlnet.ora + echo "NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, HOSTNAME) +DISABLE_OOB=ON +SQLNET.EXPIRE_TIME=3" > "$ORACLE_HOME"/network/admin/sqlnet.ora + + #listener.ora +echo "DEDICATED_THROUGH_BROKER_LISTENER=ON +DIAG_ADR_ENABLED = off +" >> "$ORACLE_HOME"/network/admin/listener.ora + + #tnsnames.ora + #Update PDB Alias names in tnsnames.ora till the DBCA code add entry for the same. + echo "$ORACLE_PDB= +(DESCRIPTION = + (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521)) + (CONNECT_DATA = + (SERVER = DEDICATED) + (SERVICE_NAME = $ORACLE_PDB) + ) +)" >> "$ORACLE_HOME"/network/admin/tnsnames.ora + +} + +function setupNetworkConfigFREE { + # sqlnet.ora + echo "NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT, HOSTNAME) +DISABLE_OOB=ON +SQLNET.EXPIRE_TIME=3" > "$ORACLE_HOME"/network/admin/sqlnet.ora + +# TNS Names.ora + echo "FREEPDB1 = + (DESCRIPTION = + (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521)) + (CONNECT_DATA = + (SERVER = DEDICATED) + (SERVICE_NAME = FREEPDB1) + ) + ) +" >> "$ORACLE_HOME"/network/admin/tnsnames.ora +} + +function dbSetupSQL { + # Remove second control file, fix local_listener, make PDB auto open, enable EM global port + # Create externally mapped oracle user for health check + sqlplus / as sysdba << EOF +ALTER SYSTEM SET local_listener=''; +ALTER PLUGGABLE DATABASE $ORACLE_PDB SAVE STATE; +EXEC DBMS_XDB_CONFIG.SETGLOBALPORTENABLED (TRUE); + +ALTER SESSION SET "_oracle_script" = true; +CREATE USER OPS\$oracle IDENTIFIED EXTERNALLY; +GRANT CREATE SESSION TO OPS\$oracle; +GRANT SELECT ON sys.v_\$pdbs TO OPS\$oracle; +GRANT SELECT ON sys.v_\$database TO OPS\$oracle; +ALTER USER OPS\$oracle SET container_data=all for sys.v_\$pdbs container = current; + +exit; +EOF + +} + +function enableLoggingSQL { + + if [ "$ENABLE_ARCHIVELOG" = "true" ]; then + enableArchiveLogCmd="ALTER DATABASE ARCHIVELOG;" + fi + + if [ "$ENABLE_FORCE_LOGGING" = "true" ]; then + enableForceLoggingCmd="ALTER DATABASE FORCE LOGGING;" + fi + + sqlplus / as sysdba << EOF +SHUTDOWN IMMEDIATE; +STARTUP MOUNT; +$enableArchiveLogCmd +$enableForceLoggingCmd +ALTER DATABASE OPEN; + +exit; +EOF + +} + +################################### +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # +############# MAIN ################ +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # +################################### + +# Creating Primary database/True Cache for FREE edition +if [ "${ORACLE_SID}" = "FREE" ]; then + + if [ "${TRUE_CACHE}" == "true" ]; then + + # Validation: Checking if ORACLE_PWD is provided or not + if [[ -z "$ORACLE_PWD" ]]; then + echo "ERROR: Please provide sys password of the primary database as ORACLE_PWD env variable. Exiting..." + exit 1 + fi + + # Validation: Check if PRIMARY_DB_CONN_STR is provided or not + if [[ -z "${PRIMARY_DB_CONN_STR}" ]] || [[ $PRIMARY_DB_CONN_STR != *:*/* ]]; then + echo "ERROR: Please provide PRIMARY_DB_CONN_STR in :/ format to connect with primary database. Exiting..." + exit 1 + fi + + # Check for password file existence before we start the dbca command for TrueCache instance creation. + echo "Check and wait for the existence of $PRIMARY_DB_PWD_FILE..." + while [ ! -e "$PRIMARY_DB_PWD_FILE" ] + do + sleep 1 + done + echo "$PRIMARY_DB_PWD_FILE found!" + + dbca -silent -createTrueCacheInstance -gdbName "$ORACLE_SID" -sid "$ORACLE_SID" -sourceDBConnectionString "$PRIMARY_DB_CONN_STR" -passwordFileFromSourceDB "$PRIMARY_DB_PWD_FILE" ORACLE_HOSTNAME="$ORACLE_HOSTNAME" < "$ORACLE_BASE"/dbca.rsp <:/ format to connect with primary database. Exiting..." + exit 1 + fi + + # Primary database parameters extration + PRIMARY_DB_NAME=$(echo "${PRIMARY_DB_CONN_STR}" | cut -d '/' -f 2) + + # Creating the database using the dbca command + if [ "${STANDBY_DB}" = "true" ]; then + # Creating standby database + dbca -silent -createDuplicateDB -gdbName "$PRIMARY_DB_NAME" -primaryDBConnectionString "$PRIMARY_DB_CONN_STR" ${DBCA_CRED_OPTIONS} -sid "$ORACLE_SID" -createAsStandby -datafileDestination $ORACLE_BASE/oradata -useOMF true -dbUniquename "$ORACLE_SID" ORACLE_HOSTNAME="$ORACLE_HOSTNAME" || + cat /opt/oracle/cfgtoollogs/dbca/"$ORACLE_SID"/"$ORACLE_SID".log || + cat /opt/oracle/cfgtoollogs/dbca/"$ORACLE_SID".log + elif [ "${CLONE_DB}" = "true" ]; then + # Creating clone database or Duplicate database (No -createAsStandby) after duplicating a primary database; CLONE_DB is set to true here + dbca -silent -createDuplicateDB -gdbName "$ORACLE_SID" -primaryDBConnectionString "$PRIMARY_DB_CONN_STR" ${DBCA_CRED_OPTIONS} -sid "$ORACLE_SID" -databaseConfigType SINGLE -datafileDestination $ORACLE_BASE/oradata -useOMF true -dbUniquename "$ORACLE_SID" ORACLE_HOSTNAME="$ORACLE_HOSTNAME" || + cat /opt/oracle/cfgtoollogs/dbca/"$ORACLE_SID"/"$ORACLE_SID".log || + cat /opt/oracle/cfgtoollogs/dbca/"$ORACLE_SID".log + elif [ "$TRUE_CACHE" = "true" ]; then + if [ -n "$TRUE_CACHE_BLOB" ]; then + SOURCE_DB_BASED_ARGS="-trueCacheBlobFromSourceDB $TRUE_CACHE_BLOB"; + # Check for BLOB file existence before we start the dbca command for TrueCache instance creation. + echo "Check and wait for the existence of $TRUE_CACHE_BLOB..." + while [ ! -e "$TRUE_CACHE_BLOB" ] + do + sleep 1 + done + echo "$TRUE_CACHE_BLOB found!" + else + SOURCE_DB_BASED_ARGS="-passwordFileFromSourceDB $PRIMARY_DB_PWD_FILE"; + # Check for password file existence before we start the dbca command for TrueCache instance creation. + echo "Check and wait for the existence of $PRIMARY_DB_PWD_FILE..." + while [ ! -e "$PRIMARY_DB_PWD_FILE" ] + do + sleep 1 + done + echo "$PRIMARY_DB_PWD_FILE found!" + + if [ -n "$PRIMARY_DB_TDE_WALLET" ]; then + SOURCE_DB_BASED_ARGS="$SOURCE_DB_BASED_ARGS -tdeWalletFromSourceDB $PRIMARY_DB_TDE_WALLET" + # Check for TDE wallet existence before we start the dbca command for TrueCache instance creation. + echo "Check and wait for the existence of $PRIMARY_DB_TDE_WALLET..." + while [ ! -e "$PRIMARY_DB_TDE_WALLET" ] + do + sleep 1 + done + echo "$PRIMARY_DB_TDE_WALLET found!" + fi; + fi; + + # Creating TRUE CACHE database instance; TRUE_CACHE is set to true here + # Checking if INIT_SGA_SIZE & INIT_PGA_SIZE is provided by the user + SGA_TARGET_IN_MB=""; + PGA_AGGREGATE_TARGET_IN_MB=""; + if [[ "${INIT_SGA_SIZE}" != "" && "${INIT_PGA_SIZE}" != "" ]]; then + SGA_TARGET_IN_MB="-sgaTargetInMB $INIT_SGA_SIZE"; + PGA_AGGREGATE_TARGET_IN_MB="-pgaAggregateTargetInMB $INIT_PGA_SIZE"; + fi; + dbca -silent -createTrueCacheInstance -gdbName "$ORACLE_SID" -sid "$ORACLE_SID" -sourceDBConnectionString "$PRIMARY_DB_CONN_STR" ${DBCA_CRED_OPTIONS} $SOURCE_DB_BASED_ARGS $SGA_TARGET_IN_MB $PGA_AGGREGATE_TARGET_IN_MB ORACLE_HOSTNAME="$ORACLE_HOSTNAME" < /etc/oratab rm -f oratab.bkp - rm -rf "$ORACLE_BASE"/cfgtoollogs/dbca/"$ORACLE_SID" - rm -rf "$ORACLE_BASE"/admin/"$ORACLE_SID" + rm -rf "$ORACLE_BASE"/cfgtoollogs/dbca/$ORACLE_SID + rm -rf "$ORACLE_BASE"/admin/$ORACLE_SID # clean up zombie shared memory/semaphores ipcs -m | awk ' /[0-9]/ {print $2}' | xargs -n1 ipcrm -m 2> /dev/null ipcs -s | awk ' /[0-9]/ {print $2}' | xargs -n1 ipcrm -s 2> /dev/null # Create database - "$ORACLE_BASE"/"$CREATE_DB_FILE" "$ORACLE_SID" "$ORACLE_PDB" "$ORACLE_PWD" || exit 1; - - # Check whether database is successfully created - if "$ORACLE_BASE"/"$CHECK_DB_FILE"; then - # Create a checkpoint file if database is successfully created - # Populate the checkpoint file with the current date to avoid timing issue when using NFS persistence in multi-replica mode - date -Iseconds > "$ORACLE_BASE"/oradata/."${ORACLE_SID}""${CHECKPOINT_FILE_EXTN}" - fi - + "$ORACLE_BASE"/"$CREATE_DB_FILE" $ORACLE_SID "$ORACLE_PDB" "$ORACLE_PWD" || exit 1; + + for i in 1 2 4 8; do + "$ORACLE_BASE"/"$CHECK_DB_FILE"; + ret=$? + # Check whether database is successfully created + if [ $ret -eq 0 ]; then + # Create a checkpoint file if database is successfully created + # Populate the checkpoint file with the current date to avoid timing issue when using NFS persistence in multi-replica mode + echo "$(date -Iseconds)" > "$ORACLE_BASE"/oradata/.${ORACLE_SID}"${CHECKPOINT_FILE_EXTN}" + break + elif [ $ret -eq 5 ]; then + # PDB is in mounted state + echo "PDB is in mounted state. Waiting for $i seconds." + sleep $i + else + break + fi + done + # Move database operational files to oradata moveFiles; @@ -300,9 +306,18 @@ else fi; -# Check whether database is up and running -"$ORACLE_BASE"/"$CHECK_DB_FILE" -status=$? +for i in 1 2 4 8; do + # Check whether database is up and running + "$ORACLE_BASE"/"$CHECK_DB_FILE" + status=$? + if [ $status -eq 5 ]; then + # PDB is in mounted state + echo "PDB is in mounted state. Waiting for $i seconds." + sleep $i + else + break + fi +done # Check whether database is up and running if [ $status -eq 0 ]; then diff --git a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/runUserScripts.sh b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/runUserScripts.sh old mode 100644 new mode 100755 similarity index 82% rename from OracleDatabase/SingleInstance/dockerfiles/23.3.0/runUserScripts.sh rename to OracleDatabase/SingleInstance/dockerfiles/23.4.0/runUserScripts.sh index ddd72da9c9..6b2db24f14 --- a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/runUserScripts.sh +++ b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/runUserScripts.sh @@ -1,7 +1,7 @@ #!/bin/bash # LICENSE UPL 1.0 # -# Copyright (c) 1982-2023 Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1982-2024 Oracle and/or its affiliates. All rights reserved. # # Since: July, 2017 # Author: gerald.venzl@oracle.com @@ -26,10 +26,9 @@ if [ -d "$SCRIPTS_ROOT" ] && [ -n "$(ls -A "$SCRIPTS_ROOT")" ]; then for f in "$SCRIPTS_ROOT"/*; do case "$f" in - *.sh) - echo "$0: running $f"; - # shellcheck source=/dev/null - . "$f" ;; + *.sh) echo "$0: running $f"; + # shellcheck source=/dev/null + . "$f" ;; *.sql) echo "$0: running $f"; echo "exit" | "$ORACLE_HOME"/bin/sqlplus -s "/ as sysdba" @"$f"; echo ;; *) echo "$0: ignoring $f" ;; esac diff --git a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/setPassword.sh b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/setPassword.sh old mode 100644 new mode 100755 similarity index 79% rename from OracleDatabase/SingleInstance/dockerfiles/23.3.0/setPassword.sh rename to OracleDatabase/SingleInstance/dockerfiles/23.4.0/setPassword.sh index d8f7e0df0a..e8dcb8c8de --- a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/setPassword.sh +++ b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/setPassword.sh @@ -1,7 +1,7 @@ #!/bin/bash # LICENSE UPL 1.0 # -# Copyright (c) 1982-2023 Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1982-2024 Oracle and/or its affiliates. All rights reserved. # # Since: November, 2016 # Author: gerald.venzl@oracle.com @@ -17,10 +17,13 @@ fi ORACLE_PWD=$1 ORACLE_SID="$(grep "$ORACLE_HOME" /etc/oratab | cut -d: -f1)" -ORACLE_PDB="$(find "$ORACLE_BASE"/oradata/"$ORACLE_SID"/*/ -type d | grep -v -e pdbseed -e "${ARCHIVELOG_DIR_NAME:-archive_logs}" | cut -d/ -f6)" +if [ "$ORACLE_SID" == "FREE" ]; then + ORACLE_PDB="FREEPDB1" +fi +ORACLE_PDB=${ORACLE_PDB:-ORCLPDB1} +ORACLE_PDB=${ORACLE_PDB^^} # shellcheck disable=SC2034 ORAENV_ASK=NO -# shellcheck source=/dev/null source oraenv sqlplus / as sysdba << EOF diff --git a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/setupLinuxEnv.sh b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/setupLinuxEnv.sh old mode 100644 new mode 100755 similarity index 62% rename from OracleDatabase/SingleInstance/dockerfiles/23.3.0/setupLinuxEnv.sh rename to OracleDatabase/SingleInstance/dockerfiles/23.4.0/setupLinuxEnv.sh index caa5ee8e24..7aafbea319 --- a/OracleDatabase/SingleInstance/dockerfiles/23.3.0/setupLinuxEnv.sh +++ b/OracleDatabase/SingleInstance/dockerfiles/23.4.0/setupLinuxEnv.sh @@ -1,7 +1,7 @@ #!/bin/bash # LICENSE UPL 1.0 # -# Copyright (c) 1982-2023 Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1982-2024 Oracle and/or its affiliates. All rights reserved. # # Since: December, 2016 # Author: gerald.venzl@oracle.com @@ -10,6 +10,14 @@ # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. # +## Use OCI yum repos on OCI instead of public yum +region=$(curl --noproxy '*' -sfm 3 -H "Authorization: Bearer Oracle" http://169.254.169.254/opc/v2/instance/ | sed -nE 's/^ *"regionIdentifier": "([^"]+)".*/\1/p') +if [ -n "$region" ]; then + echo "Detected OCI Region: $region" + for proxy in $(printenv | grep -i _proxy | cut -d= -f1); do unset $proxy; done + echo "-$region" > /etc/yum/vars/ociregion +fi + # Setup filesystem and oracle user # Adjust file permissions, go to /opt/oracle as user 'oracle' to proceed with Oracle installation # ------------------------------------------------------------ @@ -21,8 +29,8 @@ ln -s "$ORACLE_BASE"/scripts /docker-entrypoint-initdb.d && \ mkdir -p "$ORACLE_BASE"/oradata /home/oracle && \ mkdir -p "$ORACLE_HOME" && \ chmod ug+x "$ORACLE_BASE"/*.sh && \ -dnf install -y oraclelinux-developer-release-el8 && \ -dnf -y install oracle-database-preinstall-23c openssl hostname && \ +dnf install -y oraclelinux-developer-release-el8 && \ +dnf -y install oracle-database-preinstall-23ai openssl hostname file expect && \ rm -rf /var/cache/yum && \ ln -s "$ORACLE_BASE"/"$PWD_FILE" /home/oracle/ && \ echo oracle:oracle | chpasswd && \ diff --git a/OracleDatabase/SingleInstance/dockerfiles/buildContainerImage.sh b/OracleDatabase/SingleInstance/dockerfiles/buildContainerImage.sh index 0239f69860..1e4efa78eb 100755 --- a/OracleDatabase/SingleInstance/dockerfiles/buildContainerImage.sh +++ b/OracleDatabase/SingleInstance/dockerfiles/buildContainerImage.sh @@ -229,7 +229,7 @@ cd "${VERSION}" || { } # Which Dockerfile should be used? -if [ "${VERSION}" == "12.1.0.2" ] || [ "${VERSION}" == "11.2.0.2" ] || [ "${VERSION}" == "18.4.0" ] || [ "${VERSION}" == "23.3.0" ] || { [ "${VERSION}" == "21.3.0" ] && [ "${EDITION}" == "xe" ]; }; then +if [ "${VERSION}" == "12.1.0.2" ] || [ "${VERSION}" == "11.2.0.2" ] || [ "${VERSION}" == "18.4.0" ] || [ "${VERSION}" == "23.4.0" ] || { [ "${VERSION}" == "21.3.0" ] && [ "${EDITION}" == "xe" ]; }; then DOCKERFILE=$( if [[ -f "Containerfile.${EDITION}" ]]; then echo "Containerfile.${EDITION}"; else echo "${DOCKERFILE}.${EDITION}";fi ) fi; diff --git a/OracleDatabase/SingleInstance/extensions/prebuiltdb/Dockerfile b/OracleDatabase/SingleInstance/extensions/prebuiltdb/Dockerfile index bcfac33752..53e90be313 100644 --- a/OracleDatabase/SingleInstance/extensions/prebuiltdb/Dockerfile +++ b/OracleDatabase/SingleInstance/extensions/prebuiltdb/Dockerfile @@ -1,6 +1,6 @@ # LICENSE UPL 1.0 # -# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1982-2024 Oracle and/or its affiliates. All rights reserved. # # ORACLE DOCKERFILES PROJECT # -------------------------- @@ -25,10 +25,12 @@ ARG ORACLE_SID ARG ORACLE_PDB ARG ORACLE_PWD ARG ENABLE_ARCHIVELOG +ARG ENABLE_FORCE_LOGGING ARG AUTO_MEM_CALCULATION # Option to enable archivelog in pre-built database ENV ENABLE_ARCHIVELOG=${ENABLE_ARCHIVELOG:-false} +ENV ENABLE_FORCE_LOGGING=${ENABLE_FORCE_LOGGING:-false} ENV ORACLE_SID=${ORACLE_SID} ENV ORACLE_PDB=${ORACLE_PDB} ENV ORACLE_PWD=${ORACLE_PWD} diff --git a/OracleDatabase/SingleInstance/extensions/prebuiltdb/README.md b/OracleDatabase/SingleInstance/extensions/prebuiltdb/README.md index 09f8f9d826..9909ac53ed 100644 --- a/OracleDatabase/SingleInstance/extensions/prebuiltdb/README.md +++ b/OracleDatabase/SingleInstance/extensions/prebuiltdb/README.md @@ -1,6 +1,6 @@ # Pre-built Database (prebuiltdb) Extension -This extension extends [the base Oracle Single Instance Database image](../../README.md) in such a way that the resultant image has a pre-built database. So, when a container is started using this extended image, the start-up time is quite fast. +This extension extends [the base Oracle Single Instance Database image](../../README.md) in such a way that the resultant image has a pre-built database. So, when a container is started using this extended image, the start-up time is quite fast. The configurable parameters while building this extension are as follows: @@ -8,29 +8,30 @@ The configurable parameters while building this extension are as follows: - ORACLE_PDB - ORACLE_PWD - ENABLE_ARCHIVELOG +- ENABLE_FORCE_LOGGING - AUTO_MEM_CALCULATION Example command for building this extension is as: -``` -./buildExtensions.sh -b -t -x 'prebuiltdb' -o '--build-arg ORACLE_SID= --build-arg ENABLE_ARCHIVELOG=true --build-arg ORACLE_PWD=' -``` + + ./buildExtensions.sh -b -t -x 'prebuiltdb' -o '--build-arg ORACLE_SID= --build-arg ENABLE_ARCHIVELOG=true --build-arg ENABLE_FORCE_LOGGING=true --build-arg ORACLE_PWD=' + The detailed instructions for building extensions are [here](../README.md). This extended image can be run as follows: -``` -docker run -dt --name -p :1521 -p :5500 oracle/database:ext -``` + + docker run -dt --name -p :1521 -p :5500 oracle/database:ext + **NOTE:** - This extension supports Oracle Single Instance Database container image from version 19.3.0 onwards. - The user should override 'persistence' to 'null' explicitly while deploying this image on Kubernetes. For example, -``` -helm install db21c --set image=,persistence=null oracle-db-1.0.0.tgz -``` + + helm install db21c --set image=,persistence=null oracle-db-1.0.0.tgz + ## Advantages