Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Using an Oracle Ephemeral Database eliminates the need to manage an additional database on the pipeline. The ephemeral packaging feature creates a pluggable PDB copy when the packager runs, then packages all the changes on it, and drops the PDB copy after itpackaging is complete. If the final deploy is not skipped - it will deploy newly packaged changes on the desired database (this is the DEV database in most cases).

Info

It’s important to note that the database to be copied database should always be the first database in the pipeline.

...

Two new package methods are supported. You can use an internal or external container depending on your needs. If your internal container is secured and permissions do not allow you to make changes within it, the external package method is recommended.

Package Method Name

Description

BackupRestoreOracleEphemeralInternalPdb

This is the same container that holds the dbDef to be copied. Eg. if I want to use the DEV database, the cloned db will be created on the same container as the DEV database.

Info

BackupRestoreOracleEphemeralInternalPdb is the faster and more reliable option. Usually it is 2.5 times faster, but it is important to take into account that BackupRestoreOracleEphemeralExternalPdb depends on the internet speed. BackupRestoreOracleEphemeralInternalPdb can be even faster if your internet speed becomes a bottle neck for BackupRestoreOracleEphemeralExternalPdb

),We strongly recommend

. Liquibase strongly recommends this option.

BackupRestoreOracleEphemeralExternalPdb

This container is different and separate from the cloned dbDef.

Info

If you are using OMF mode it should be same on both databases when the copy is made.

We strongly suggest you have


Both containers must be on the same Oracle

versions if they want

version to use this method.

See: Use the Required deployPackager.properties File

1.

...

Choose the Internal or External Method

First you must decide if you are using the internal or external Ephemeral method.

2. Create ORCLCDB SYSOPER User

Once that is decided, you will create a user. For both BackupRestoreOracleEphemeralInternalPdb AND BackupRestoreOracleEphemeralExternalPdb you You must create a new user on oracle Oracle CDB with the following associated privileges to create an ephemeral copy for both internal and external methods.

Note

Choose option 3a OR 3b

3a. BackupRestoreOracleEphemeralInternalPdb

These are the Internal user privileges:

...

method privileges given to the user on the container.

Code Block
-- connect as SYSDBA to an ORCLCDB to create common user
CREATE USER c##liquibase_ephemeral_user IDENTIFIED BY password;
GRANT CREATE SESSION TO c##liquibase_ephemeral_user CONTAINER=all;
GRANT CREATE PLUGGABLE DATABASE TO c##liquibase_ephemeral_user CONTAINER=all;
GRANT SYSOPER TO c##liquibase_ephemeral_user CONTAINER=all;

External user privileges:

On the external database we will create a new user on oracle CDB with the following privileges. This allows us to create an ephemeral copy and additionally create a link with the source database.

Code Block
CREATE USER c##liquibase_ephemeral_source IDENTIFIED BY password;
GRANT CREATE SESSION TO c##liquibase_ephemeral_source CONTAINER=all;
GRANT SYSOPER TO c##liquibase_ephemeral_source CONTAINER=all;

...

The user name must start with c## to be a correct user type.

...

3b. BackupRestoreOracleEphemeralExternalPdb

These are the external method privileges given to the users for both the source and external containers.

The source database is the first database in a pipeline. The external database will be an ephemeral copy of the source database made on the external container.

Source container user privileges:

Code Block
-- connect as SYSDBA to a Source ORCLCDB to create common user 
CREATE USER c##liquibase_ephemeral_source IDENTIFIED BY password; 
GRANT CREATE SESSION TO c##liquibase_ephemeral_source CONTAINER=all; 
GRANT SYSOPER TO c##liquibase_ephemeral_source CONTAINER=all;

External container user privileges:

On the external database create a new user on oracle CDB with the following privileges. This allows Liquibase to create an ephemeral copy and create a link to the source database.

Code Block
-- connect as SYSDBA to an External ORCLCDB to create common user
CREATE USER c##liquibase_ephemeral_external IDENTIFIED BY password;
GRANT CREATE SESSION TO c##liquibase_ephemeral_external CONTAINER=all;
GRANT CREATE PLUGGABLE DATABASE TO c##liquibase_ephemeral_external CONTAINER=all;
GRANT SYSOPER TO c##liquibase_ephemeral_external CONTAINER=all;
Info

The user name must start with c## to be a correct user type.

c##liquibase_ephemeral_user is just an example value, you can specify any name you would like. This is the user that connects to the ephemeral dbDef.

This is the database link on the external container to the source database.

Code Block
--- you need to know hostname, port and service name of database instance
--- you need to know credentials for database user which has enough privileges 
--- to perform copy operation 
CREATE PUBLIC DATABASE LINK liquibase_db_link
    CONNECT TO c##liquibase_ephemeral_source IDENTIFIED BY password
    USING '(DESCRIPTION=
            (ADDRESS=(PROTOCOL=TCP)(HOST=172.18.0.2)(PORT=1521))
            (CONNECT_DATA=(SERVICE_NAME=ORCLCDB))
        )';

TNS option
Also there is a possibility to use TNS name during link creation, e.g.

Code Block
CREATE DATABASE LINK liquibase_db_link
 CONNECT TO c##liquibase_ephemeral_user_asource IDENTIFIED BY password
 USING TNS_NAME;

To check if database link has been created correctly please run query below, if you don’t get errors - database link is should be correct.

Code Block
SELECT * FROM dual@liquibase_db_link;
Info

If you would like to use another name for database link - please use oracleEphemeralDatabaseLinkName packager property.

4. Optional: Only for TNSNAMES/LDAP Users
Use TNSNAMES/LDAP with Oracle Ephemeral Database

Note

This section is necessary for TNSNAMES/LDAP users.

...

If you use TNS names in your dbDef, then you should prepare a TNS name with _eph postfix for the ephemeral copy because we are not able to Liquibase cannot modify TNS files in most cases.

If this is what your dbDefs look like:

...

  • If you didn’t provide any of these values, add _eph postfix to your source PDB name.

  • If your source PDB name is bucket_01, then your value will be bucket_01_eph

Then you will create the tnsnames.ora file that contains a dev alias for DEV DbDef, dev_eph alias, and admin_sysoper alias for DEV_EPHEMERAL DbDef.

If you have a dev entry in your TNS file, then you should create an alias for the dev_eph entry which points to the ephemeral copy.copy (admin_sysoper is just an example entry for a connection pointing to ORCLCDB.)

Example tnsnames.ora file:

Code Block
dev =
(DESCRIPTION =
  (ADDRESS =
     (PROTOCOL = TCP)
     (HOST = 172.17.0.3)
     (PORT = 1521)
  )
  (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = bucket_01)
  )
)


dev_eph =
(DESCRIPTION =
  (ADDRESS =
     (PROTOCOL = TCP)
     (HOST = 172.17.0.3)
     (PORT = 1521)
  )
  (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SID = bucket_01_eph)
  )
)

admin_sysoper =
(DESCRIPTION =
  (ADDRESS =
     (PROTOCOL = TCP)
     (HOST = 172.17.0.3)
     (PORT = 1521)
  )
  (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SID = ORCLCDB)
  )
)
Info

Liquibase recommends creating a dbDef definition in the datical.project but not including this dbDef on any Liquibase pipelines/plans.

...

5. Methods for creating the Ephemeral dbDef

An ephemeral dbDef must be created in the datical.project file to instruct Liquibase which database should be cloned for the ephemeral copy and to set the connection string informationhow to connect to the cloned ephemeral copy. Because this database is transient by definition and only exists during the Deploy Packager operation, you are not able to run Status against it.

...

Follow the instructions below based on the desired method.

Info

Important note for external methodsBackupRestoreOracleEphemeralExternalPdb method: If the source dbDef does NOT use TNS, then the ephemeral dbDef should also NOT use TNS. When we create a the PDB copy in another database we need to retrieve is created in the external container, the host and port values need to be retrieved in order to connect to it. If the ephemeral database uses TNS, then we don’t know where to connect to. database uses TNS and the source database does not, the connection cannot be made.

If the source dbDef uses TNS, then the ephemeral dbDef can use anything. You also need to create any connection method. As noted above, if the ephemeral dbDef also uses TNS, a TNS entry with _eph postfix to be able to connect to itmust be created for the connection to occur.

Method 1: Create the dbDef with the Liquibase Enterprise GUI

  1. Create the dbDef using instructions from Creating a Liquibase Enterprise project Using the Liquibase Enterprise GUI

  2. Ensure the Name of the database is <dbDef_to_be_cloned>_EPHEMERAL. This can be DEV, QA, STAGE, or PRODThe <dbDef to be cloned> needs to be the first database in the pipeline.

    image-20240311-142341.png
  3. Enter your Connection Settings.

    1. If you are using a TNSNAMES/LDAP connection, see the section above Use TNSNAMES/LDAP with Oracle Ephemeral Database.

    2. If you are using a BASIC connection, the Service Name is ORCLCDB or the name of the container that houses the ephemeral copy. (See Backup and Restore Package Methods section before for more information.)

      1. Enter your container name in the Hostname text box. This entry depends on if you are using an internal or external backup and restore method. (See Backup and Restore Package Methods section before for more information.)

      2. The username and password are the ORCLCDB user created in step 12. Create ORCLCDB SYSOPER User above.

        image-20240311-173432.png

  4. Contexts and Labels

    1. Contexts are left blank or set to the same context as the dbDef to be cloned.

    2. Set your Labels to either of these:

      1. To the name of the pipeline that houses the dbDef to be cloned

      2. Or use the same pattern that is in use for the dbDef to be cloned

  5. After creating the dbDef, remove the Step from the Pipeline by selecting Remove Step.

    image-20240311-143808.png

  6. Do not select the box to delete the Deployment Step from the Deployment Plan

    image-20240311-143908.png

...

  1. If the password is present in the file, please note this value is Base64 encoded. If modifying this value, the new value will also need to be Base64 encoded.

  2. Clear out the dbDefsId for the new _EPHEMERAL dbDef.

    Code Block
        <dbDefs xsi:type="dbproject:OracleDbDef" name="DEV_EPHEMERAL" driver="oracle.jdbc.OracleDriver" hostname="cs-oracledb.liquibase.net" port="1521" username="c##liquibase_ephemeral_user" password="bGlxdWliYXNlX3VzZXI=" labels="current" dbDefsId="" serviceName="ORCLCDB" enableCompression="false" rowsPerBatch="10000"/>
  3. Do a Test Connection to another database in the pipeline or sync the project to the DMC to populate the dbDefsId field before checking it the datical.project changes into source control.

6. Optional Step: Associated deployPackager.properties

These are packaging properties available specifically for the ephemeral database packaging method. They are optional if you would like to override the default values.

...

  • If oracleEphemeralSourceName packager property is not specified we try Liquibase attempts to get the PDB name from 3 three different tables on the DB (v$pdbs and database. These tables are v$pdbs, dba_data_files, or and v$parameter). If you already gave the user required grants according to the requested grants are in place as listed on Multi-Schema Projects - Oracle Roles and Permissions, everything should work because both the PDB name can be located. Both GRANT SELECT ANY DICTIONARY TO DATICAL_ROLE; and GRANT IMP_FULL_DATABASE TO DATICAL_PACKAGER_ROLE; already give us enough permission provide the proper permissions to query the required tables. If you haven’t given such permission to us and want to use the ephemeral databaseBackupRestoreMethod - these permissions have not been granted, in order to use ephemeral databaseBackupRestoreMethod, permissions to query v$pdbs and , dba_data_files is available and v$parameter tables must be granted.

Use Oracle Managed Files (OMF) with Oracle Ephemeral Database

...