Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Get Started With Oracle on Containers

Get Started With Oracle on Containers

Linux containers are fast, efficient, and portable solutions that are well-known for running applications and services. These benefits apply equally to Oracle databases, yet they remain poorly understood in the database community thanks to misconceptions that lead database administrators to overlook them. Even the common explanation, describing containers as "lightweight" virtual machines, suggests they're less capable than legacy technologies. That is hardly the case! In fact, containers are equal to or superior to virtual and physical hosts.

Go from "Zero to Hero" and learn how easy it is to run Oracle databases in containers using nearly any hardware (even laptops) to build environments for performance testing, perfecting disaster recovery procedures, preparing for certifications, evaluating new features, and more. Participants will learn to build and run Oracle databases in containers and gain valuable insight into how containers work and interact with host systems.

Sean Scott

November 04, 2024
Tweet

More Decks by Sean Scott

Other Decks in Technology

Transcript

  1. Database Reliability Engineering MAA ⁘ RAC ⁘ RMAN Data Guard

    ⁘ Sharding ⁘ Partitioning Information Lifecycle Management Exadata & Engineered Systems Database Modernization Upgrades ⁘ Patching ⁘ Migrations Cloud ⁘ Hybrid Automation DevOps ⁘ IaC ⁘ Containers ⁘ Terraform Vagrant ⁘ Ansible Observability AHF ⁘ TFA ⁘ CHA ⁘ CHM
  2. www.viscosityna.com @ViscosityNA Oracle on Docker Running Oracle Databases in Linux

    Containers Free sample chapter: https://oraclesean.com
  3. www.viscosityna.com @ViscosityNA - Oracle Cloud - AWS - Azure -

    Google Cloud Images built on my machine will work in:
  4. www.viscosityna.com @ViscosityNA - Docker - Podman - Kubernetes - Rancher

    - LXD - containerd... Images built on my machine will work in:
  5. @ViscosityNA www.viscosityna.com www.viscosityna.com @ViscosityNA 28 Oracle Databases on a laptop

    2018 MacBook Pro 15", 2.2GHz 6-core Intel Core i7, 32GB, 1TB SSD
  6. www.viscosityna.com @ViscosityNA docker pull container-registry.oracle.com/database/free:23.4.0.0 # docker pull container-registry.oracle.com/database/free:23.4.0.0 23.4.0.0:

    Pulling from database/free 6d6e36f7c9fb: Pull complete 21def9023b6f: Pull complete 5e7b2cfeb7fa: Pull complete b4a24759beff: Pull complete 78bba54e9814: Pull complete 716b489ad5ad: Pull complete c23fd8c6cbee: Pull complete 79dea26b3a5a: Pull complete 5dfbcf799df3: Pull complete 154719a62576: Pull complete Digest: sha256:83edd0756fda0e5faecc0fdf047814f0177d4224d7bf037e4900123ee3e08718 Status: Downloaded newer image for container-registry.oracle.com/database/free:23.4.0.0 container-registry.oracle.com/database/free:23.4.0.0
  7. www.viscosityna.com @ViscosityNA docker images # docker images REPOSITORY TAG IMAGE

    ID CREATED SIZE container-registry.oracle.com/database/free 23.4.0.0 7510f8869b04 3 months ago 8.7GB container-registry.oracle.com/database/enterprise 19.19.0.0 979416fa8cea 12 months ago 6.21GB
  8. www.viscosityna.com @ViscosityNA Create a database/data directory # Create a directory

    for databases and data: ORADATA=~/oradata mkdir -p ${ORADATA}
  9. www.viscosityna.com @ViscosityNA Set variables # Give the container a name:

    CONTAINER_NAME=ORCL # Set the database and PDB names # (not necessary for 23ai): ORACLE_SID=ORCL ORACLE_PDB=ORCLPDB
  10. www.viscosityna.com @ViscosityNA Create subdirectories for the database # Create directories

    for admin/audit, data, and diagnostic files: for dir in admin data diag do mkdir -p ${ORADATA}/${CONTAINER_NAME}/${dir} # Clean up any existing files: rm -fr ${ORADATA}/${CONTAINER_NAME}/${dir}/* done
  11. www.viscosityna.com @ViscosityNA Create subdirectories for the database ├── oradata #

    Base directory for all containers │ └── ORCL # Base directory for the ORCL container │ ├── admin # Admin/audit │ ├── data # Data │ └── diag # diagnostic_dest └── scripts # Shared scripts
  12. www.viscosityna.com @ViscosityNA A useful command for 23ai Free Edition docker

    rm -f ${CONTAINER_NAME} 2>/dev/null docker run -d \ --name ${CONTAINER_NAME} \ --volume ${ORADATA}/${CONTAINER_NAME}/data:/opt/oracle/oradata \ --volume ${ORADATA}/${CONTAINER_NAME}/diag:/opt/oracle/diag \ --volume ${ORADATA}/${CONTAINER_NAME}/admin:/opt/oracle/admin \ --volume ${ORADATA}/scripts:/scripts \ -p 51521:1521 \ container-registry.oracle.com/database/free:23.4.0.0 docker logs -f ${CONTAINER_NAME}
  13. www.viscosityna.com @ViscosityNA Name/IP of the container host The mapped port

    ORACLE_SID localhost 51521 o193 Connect SQL Developer to the container
  14. www.viscosityna.com @ViscosityNA ├── ORCLCDB │ ├── ORCLPDB1 │ │ ├──

    … │ ├── control01.ctl │ ├── pdbseed │ │ ├── … │ ├── redo01.log │ ├── redo02.log │ ├── redo03.log │ ├── sysaux01.dbf │ ├── system01.dbf │ ├── temp01.dbf │ ├── undotbs01.dbf │ └── users01.dbf └── dbconfig └── ORCLCDB ├── listener.ora ├── orapwORCLCDB ├── oratab ├── spfileORCLCDB.ora ├── sqlnet.ora └── tnsnames.ora
  15. www.viscosityna.com @ViscosityNA ├── ORCLCDB │ ├── ORCLPDB1 │ │ ├──

    … │ ├── control01.ctl │ ├── pdbseed │ │ ├── … │ ├── redo01.log │ ├── redo02.log │ ├── redo03.log │ ├── sysaux01.dbf │ ├── system01.dbf │ ├── temp01.dbf │ ├── undotbs01.dbf │ └── users01.dbf └── dbconfig └── ORCLCDB ├── listener.ora ├── orapwORCLCDB ├── oratab ├── spfileORCLCDB.ora ├── sqlnet.ora └── tnsnames.ora
  16. www.viscosityna.com @ViscosityNA Containers save data, metadata, and con fi guration

    under oradata: Why is this important? •Data fi les •Temp fi les •Redo logs •Archive logs •TNS con fi gurations •Wallets •/etc/oratab •p fi le/sp fi le
  17. www.viscosityna.com @ViscosityNA Containers save data, metadata, and con fi guration

    under oradata: Why is this important? •Data fi les •Temp fi les •Redo logs •Archive logs •TNS con fi gurations •Wallets •/etc/oratab •p fi le/sp fi le All database fi les are in a single, local directory: ${ORADATA}/${CONTAINER_NAME}/data
  18. www.viscosityna.com @ViscosityNA We can copy an entire database: cp -rpT

    ${ORADATA}/${OLD_CONTAINER}/data \ ${ORADATA}/${NEW_CONTAINER}/data
  19. www.viscosityna.com @ViscosityNA ...to create an instant database! # Create a

    new container name: OLD_CONTAINER=${CONTAINER_NAME} NEW_CONTAINER=CLONE # Create new directories for admin/audit, data, diag: for dir in admin data diag do mkdir -p ${ORADATA}/${NEW_CONTAINER}/${dir} done # Copy the original container's data directory to the new container: cp -rpT ${ORADATA}/${OLD_CONTAINER}/data \ ${ORADATA}/${NEW_CONTAINER}/data
  20. www.viscosityna.com @ViscosityNA The database starts immediately! docker run -d \

    --name ${NEW_CONTAINER} \ --volume ${ORADATA}/${NEW_CONTAINER}/data:/opt/oracle/oradata \ --volume ${ORADATA}/${NEW_CONTAINER}/diag:/opt/oracle/diag \ --volume ${ORADATA}/${NEW_CONTAINER}/admin:/opt/oracle/admin \ --volume ${ORADATA}/scripts:/scripts \ -p 51522:1521 \ container-registry.oracle.com/database/free:23.4.0.0 docker logs -f ${NEW_CONTAINER}
  21. www.viscosityna.com @ViscosityNA Resources Download Docker Desktop: •https://www.docker.com/products/docker-desktop/ Oracle Container Registry:

    •https://container-registry.oracle.com Oracle Docker Registry on GitHub: •https://github.com/oracle/docker-images My Oracle Cloud Native GitHub Repository: •https://github.com/oraclesean/cloud-native-oracle