Quickly building an Oracle database in OCI

        Bobby Curtis

        Quickly building an Oracle database in OCI

        Like many others I’m normally using Oracle Virtual Box (vbox) for my development environments; however in the last few weeks I’ve been making the switch over to OCI for my Oracle work and other clouds for PostgreSQL or what nots.  In building out these resources, I’m using HashiCorp Terraform to build these resources.  One of the resources I needed to build is an Oracle Database.

        When you look at the documentation for building an Oracle Database, the easiest way is to build a “database system”.  This Terraform resource will create a new database system in the specified compartment and availability domain.  The Oracle database edition that is specify applies to all the databases that are created within the database system.  Basically, meaning that once the database system is created additional databases can be created within the system using the same database edition.

        The example that is provided is a working example but you have to create additional Terraform (tf) files to map out the variables and other items within it.

        ###########################
        # OCI DB System
        ###########################

        resource “oci_database_db_system” “db_system” {
        availability_domain = var.availability_domain
        compartment_id = var.dev_compartment
        db_home {
        database {
        admin_password = “<passowrd>”
        db_name = “rddevdb”
        pdb_name = “devdb1″
        }
        display_name = “rddevdb”
        db_version = “19.12.0.0″
        }
        hostname = “RD-DBSYSTEM”
        shape = “VM.Standard2.4″
        database_edition = “ENTERPRISE_EDITION”
        license_model = “LICENSE_INCLUDED”
        subnet_id = var.devsubnet
        ssh_public_keys = [“${file(“./.ssh/id.pub”)}”]
        node_count = 1
        data_storage_size_in_gb = 256
        display_name = “rd-dev-db”
        time_zone = “America/New_York”
        db_system_options {
        storage_management = “LVM”
        }
        }

        After writing the above code into a main.tf file, it can be ran against your OCI environment by using the standard validate -> plan -> apply process as long as your provider.tf and other files are configured correctly.  During the apply process it can take anywhere from an hour or more to build the database system.  If you find that your database system build is taking longer than 2 hours, then you can increase the amount of time needed by changing the timeouts settings.

        Hope this information has provided a good example to get started.

        Thanks!

        Recent posts

        Related Posts

        Upgrading OCI Modules for Terraform

        Automation is all the rage now; yet I’ve though automation has been the key to a lot of...

        Read more

        Deploying MySQL on Oracle Cloud Infrastructure – MySQL Database Service

        With Oracle’s recent release of MySQL Heatwave, I’ve been looking more into MySQL. I’ve actually...

        Read more

        Moving Terraform State file to OCI Object Store

        When developing with Terraform it is nice to keep everything local on your laptop. Makes for great...

        Read more