...
Traditional packaging requires users to maintain a reference database, but often this is expensive and cumbersome to manage. Using an Oracle Ephemeral Database eliminates the need to manage an additional database on the pipeline. A default installation requires the use a Reference Database. You simply configure Liquibase to When using Oracle PDBs, configuration can be setup to have Liquibase create a temporary copy of a database in the pipeline to be used in place of the Reference Database. Once the copy is made, you will ensure that all of your changes work on the copy, implement them on your original database’s changelog, and then destroy the database copy. Follow this guide to learn how to implement this workflow.
Pre-requisites
Use Requires Liquibase Enterprise 8.6 and higher
Based Ephemeral database connection is based on Oracle multi-tenant PDB technology
Ephemeral database connection requires a user on ORCLCDB with SYSOPER privileges and the ability to create pluggable databases
...
Ephemeral database feature works ONLY for PDB databases
Ephemeral database feature works ONLY for Oracle 19c and 21c
Ephemeral database feature does not work for Oracle RDS
You cannot place the temporary copied database in a pipeline or run a status on it because technically it does not exist in the pipeline.
Backup and Restore Package Methods
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. |
BackupRestoreOracleEphemeralExternalPdb | This container is different and separate from the cloned dbDef. |
See: Use the Required deployPackager.properties File
BackupRestoreOracleEphemeralInternalPdb
Create ORCLCDB SYSOPER User
You must create a new user on oracle CDB with the following privileges to create an ephemeral copy.
Code Block |
---|
# Should be created on ORCLCDB
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; |
Info |
---|
The user name must start with
|
BackupRestoreOracleEphemeralExternalPdb
Create ORCLCDB SYSOPER User
On the database A we will to create a new user on oracle CDB with the following privileges to be able to create an ephemeral copy
Usage
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 packaging 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 should always be the first database in the pipeline. |
Backup and Restore Package Methods
In order to implement an Ephemeral Database, the databaseBackupRestoreMethod package method on the deployPackager.properties needs to be configured.
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.
| ||
BackupRestoreOracleEphemeralExternalPdb | This container is different and separate from the cloned dbDef.
|
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. You must create a new user on Oracle CDB with the 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 method privileges given to the user on the container.
Code Block |
---|
-- connect as SYSDBA to aan FIRST DBORCLCDB to create common user CREATE USER c##liquibase_ephemeral_user_a IDENTIFIED BY password; GRANT CREATE SESSION TO c##liquibase_ephemeral_user_a CONTAINER=all; GRANT CREATE PLUGGABLE DATABASE TO c##liquibase_ephemeral_user_a CONTAINER=all; GRANT SYSOPER TO c##liquibase_ephemeral_user_a CONTAINER=all; |
...
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 SECONDSource DBORCLCDB to create common user CREATE USER c##liquibase_ephemeral_user_bsource IDENTIFIED BY password; GRANT CREATE SESSION TO c##liquibase_ephemeral_user_bsource CONTAINER=all; GRANT CREATE PLUGGABLE DATABASE TO c##liquibase_ephemeral_user_b CONTAINER=all; GRANT SYSOPER TO c##liquibase_ephemeral_user_bsource CONTAINER=all; --- you need to know hostname, port and service name of DB2 database instance --- you need to know credetials for database user which has enough priviliges --- to perform copy operation CREATE PUBLIC DATABASE LINK liquibase_db_link CONNECT |
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_user_a IDENTIFIED BY password USING '(DESCRIPTION= (ADDRESS=(PROTOCOL=TCP)(HOST=172.18.0.2)(PORT=1521)) (CONNECT_DATA=(SERVICE_NAME=ORCLCDB)) )'; |
Also there is a possibility to use TNS name during link creation, e.g.
Code Block |
---|
CREATE external CONTAINER=all; |
Info |
---|
The user name must start with
|
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_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 correct.
Code Block |
---|
SELECT * FROM dual@liquibase_db_link; |
If you would like to use another name for database link - please use oracleEphemeralDatabaseLinkName
packager property.
Associated deployPackager.properties
These are packaging properties available specifically for the ephemeral database packaging method.
...
Property Name
...
Description
...
oracleEphemeralSourceName
...
[Optional]
...
oracleEphemeralCopyName
...
[Optional]
...
oracleEphemeralDatabaseLinkName
...
[Optional]
...
oracleEphemeralCopyWithData
...
[Optional] By default we do not copy databases with data. If you would like to copy both the structure and data, you will use this property.
...
oracleEphemeralSkipFinalDeploy
...
[Optional] This property allows you to:
package
run SQL rules
create the ephemeral database copy
package changes onto the ephemeral database
drop the ephemeral database
And then SKIP the final deploy of the ephemeral database changes to the dev database.
See: Use the Required deployPackager.properties File
Changes to the Project Repository and datical.project
Follow these steps to implement the ephemeral database configuration for your workflow.
Create an 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 information. Because this database is transient by definition and only exists during the Deploy Packager operation, it is not eligible on a Liquibase pipeline to have Status run against it.
Info |
---|
Liquibase recommends creating a dbDef definition in the datical.project but not including this dbDef on any Liquibase pipelines/plans. |
Methods for creating the Ephemeral dbDef
In order to create a dbDef without including the dbDef on an existing pipeline Liquibase recommends using ONE of the following methods:
Create the dbDef using the Liquibase Enterprise GUI and then delete the dbDef from the pipeline.
Include the ephemeral dbDef on the Project Creation Script but do not include the dbDef on any pipelines.
Manually copy the dbDef from an existing dbDef in the pipeline.
Follow the instructions below based on the desired method.
Method 1: Create the dbDef with the Liquibase Enterprise GUI
Create the dbDef using instructions from Creating a Liquibase Enterprise project Using the Liquibase Enterprise GUI
Ensure the Name of the database is <dbDef_to_be_cloned>_EPHEMERAL. This can be DEV, QA, STAGE, or PROD.
Enter your Connection Settings.
If you are using a TNSNAMES/LDAP connection, see the section below Using TNSNAMES/LDAP with Oracle Ephemeral Database.
If you are using a BASIC connection Service Name should be ORCLCDB or the name of the container that should house the ephemeral copy. (See Backup and Restore Package Methods section before for more information.)
You will need to enter your container name in the Hostname text box. This entry will depend on if you are using an internal or external backup and restore method. (See Backup and Restore Package Methods section before for more information.)
The username and password should be the ORCLCDB user created in step 1. Create ORCLCDB SYSOPER User above.
Contexts and Labels
Contexts should be left blank or set to the same context as the dbDef to be cloned
Labels should generally be set
To the name of the pipeline that houses the dbDef to be cloned
Or use the same pattern that is in use for the dbDef to be cloned
After creating the dbDef, remove the Step from the Pipeline by selecting Remove Step
Do not select the box to delete the Deployment Step from the Deployment Plan
Method 2: Create the dbDef with the Project Creation Script
Create the project using the instructions from Creating a Liquibase Enterprise Using the Project Creation Script (project_creator.groovy)
Include the ephemeral database on the ProjectNameOracle.dbdefs.tsv.txt. Use name <dbDef_to_be_cloned>_EPHEMERAL
Do not reference the ephemeral database as part of any pipeline on ProjectNameOracle.pipelines.tsv.txt
Method 3: Manually create the dbDef by copying from existing dbDef in datical.project
If you are manually copying the dbDef in the datical.project file from the dbDef to be cloned
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.
Clear out the dbDefsId for the new _EPHEMERAL dbDef.
Do a Test Connection to the DMC Database (under Settings → Configure DMC DB → Test Connection) or perform a Status operation on the project in order to populate the dbDefsId for the new ephemeral dbDef.
Using TNSNAMES/LDAP with Oracle Ephemeral Database
Learn more about traditional LDAP connections here: LDAP Connection to an Oracle Database
If a customer uses TNS names in dbDef, then customer should prepare a TNS name with _eph
postfix him self for the ephemeral copy which we are going to create, as in most cases we are not able to modify TNS files or they can be even stored on remote servers (e.g. OID). So if customer’s dbDefs look like that
Code Block |
---|
<dbDefs xsi:type="dbproject:OracleDbDef" name="DEV" hostname="localhost" driver="oracle.jdbc.OracleDriver" tnsName="dev" />
<dbDefs xsi:type="dbproject:OracleDbDef" name="DEV_EPHEMERAL" driver="oracle.jdbc.OracleDriver" tnsName="admin_sysoper" /> |
then customer should also add dev_eph
entry in TNS config pointing to a PDB which we are going to create. To determine service name or SID for the PDB which this TNS will point to, use the next logic:
If you provided value for
oracleEphemeralCopyName
, then it will be itIf you didn’t provide value for
oracleEphemeralCopyName
, but provided it fororacleEphemeralSourceName
- it will beoracleEphemeralCopyName
value +_eph
postfix, e.g. iforacleEphemeralCopyName
isbucket_01
, then your value will bebucket_01_eph
If you didn’t provide any of these values, just add
_eph
postfix to your source PDB name, e.g if your source PDB name isbucket_01
, then your value will bebucket_01_eph
This is tnsnames.ora file example that contains dev
alias for DEV
DbDef, dev_eph
alias which customer needs to create, and admin_sysoper
alias for DEV_EPHEMERAL
DbDef:
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) ) ) '(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_source 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 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 |
4. Optional: Only for TNSNAMES/LDAP Users
Use TNSNAMES/LDAP with Oracle Ephemeral Database
Note |
---|
This section is necessary for TNSNAMES/LDAP users. |
Learn more about traditional LDAP connections here: LDAP Connection to an Oracle Database
If you use TNS names in your dbDef, then you should prepare a TNS name with _eph
postfix for the ephemeral copy because Liquibase cannot modify TNS files.
If this is what your dbDefs look like:
Code Block |
---|
<dbDefs xsi:type="dbproject:OracleDbDef" name="DEV" hostname="localhost" driver="oracle.jdbc.OracleDriver" tnsName="dev" />
<dbDefs xsi:type="dbproject:OracleDbDef" name="DEV_EPHEMERAL" driver="oracle.jdbc.OracleDriver" tnsName="admin_sysoper" /> |
Then you should add a dev_eph
entry in your TNS configuration that points to a PDB. To determine the service name or SID for the PDB which this TNS will point to, use one of the following methods depending on your situation:
If you provided a value for
oracleEphemeralCopyName
, then this value will be what you add to your TNS configuration.
Tip |
---|
Example: If |
If you didn’t provide a value for
oracleEphemeralCopyName
, but provided it fororacleEphemeralSourceName
- it will be theoracleEphemeralCopyName
value +_eph
postfix.
Tip |
---|
Example: If |
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 bebucket_01_eph
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 (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 how 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.
In order to create a dbDef without including the dbDef on an existing pipeline Liquibase recommends using ONE of the following methods:
Method 1: Create the dbDef using the Liquibase Enterprise GUI and then delete the dbDef from the pipeline.
Method 2: Include the ephemeral dbDef on the Project Creation Script but do not include the dbDef on any pipelines.
Method 3: Manually copy the dbDef from an existing dbDef in the pipeline.
Follow the instructions below based on the desired method.
Info |
---|
Important note for BackupRestoreOracleEphemeralExternalPdb method: If the source dbDef does NOT use TNS, then the ephemeral dbDef should also NOT use TNS. When the PDB copy is created in the external container, the host and port values need to be retrieved in order to connect. If the ephemeral 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 any connection method. As noted above, if the ephemeral dbDef also uses TNS, a TNS entry with |
Method 1: Create the dbDef with the Liquibase Enterprise GUI
Create the dbDef using instructions from Creating a Liquibase Enterprise project Using the Liquibase Enterprise GUI
Ensure the Name of the database is <dbDef_to_be_cloned>_EPHEMERAL. The <dbDef to be cloned> needs to be the first database in the pipeline.
Enter your Connection Settings.
If you are using a TNSNAMES/LDAP connection, see the section above Use TNSNAMES/LDAP with Oracle Ephemeral Database.
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.)
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.)
The username and password are the ORCLCDB user created in step 2. Create ORCLCDB SYSOPER User above.
Contexts and Labels
Contexts are left blank or set to the same context as the dbDef to be cloned.
Set your Labels to either of these:
To the name of the pipeline that houses the dbDef to be cloned
Or use the same pattern that is in use for the dbDef to be cloned
After creating the dbDef, remove the Step from the Pipeline by selecting Remove Step.
Do not select the box to delete the Deployment Step from the Deployment Plan
Method 2: Create the dbDef with the Project Creation Script
Create the project using the instructions from Creating a Liquibase Enterprise Using the Project Creation Script (project_creator.groovy)
Include the ephemeral database on the ProjectNameOracle.dbdefs.tsv.txt.
Use name: <dbDef_to_be_cloned>_EPHEMERAL
Info |
---|
Do not reference the ephemeral database as part of any pipeline on ProjectNameOracle.pipelines.tsv.txt |
Method 3: Manually create the dbDef by copying from the existing dbDef in datical.project
If you are manually copying the dbDef in the datical.project file from the dbDef to be cloned:
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.
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"/>
Do a Test Connection to another database in the pipeline or sync the project to the DMC to populate the dbDefsId field before checking 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.
Property Name | Description |
---|---|
oracleEphemeralSourceName | [Optional] Defines a source name for an Oracle source PDB in the event Liquibase has not been granted the necessary permissions to query for this name. Necessary permissions are included below. If these grants are not present, oracleEphemeralSourceName will be required.
Property Validation: Source name should up to 30 characters long, contain no spaces [ ], slashes [/] and semicolons [;] and cannot begin with a number. |
oracleEphemeralCopyName | [Optional] Defines a name for an Oracle copy PDB in the event the default name is not desired. Default name for the ephemeral copy will be source PDB name with Property Validation: Copy name should be up to 30 characters long, contain no spaces [ ], slashes [/] and semicolons [;] and cannot begin with a number. |
oracleEphemeralDatabaseLinkName | [Optional] Defines a name for a database link which is used with PackageMethod Default link name will be Property Validation: Database link name should up to 128 characters long, contain no spaces [ ], slashes [/] and semicolons [;] and cannot begin with a number. |
oracleEphemeralCopyWithData | [Optional] By default Liquibase will copy databases without data. (*) If you would like to copy both the structure and data, use this boolean property. (*) There is one exception in that the data from the Property Validation: true/false |
oracleEphemeralSkipFinalDeploy | [Optional] The default value for this setting is false. Any changes being packaged are deployed to the first database in the pipeline during the Deploy Packager operation. Setting this value to true allows changes to be packaged and changesets to be created and stored in the changelog.xml, but the deployment to the first database in the pipeline does not occur. Property Validation: true/false |
See: Use the Required deployPackager.properties File
Troubleshooting:
Potential grants issues
If
oracleEphemeralSourceName
packager property is not specified
...
Liquibase attempts to get the PDB name from
...
three different tables on the
...
database. These tables are
v$pdbs
,dba_data_files
...
,
andv$parameter
. If the requested grants are in place as listed on Multi-Schema Projects - Oracle Roles and Permissions,
...
the PDB name can be located. Both
GRANT SELECT ANY DICTIONARY TO DATICAL_ROLE;
andGRANT IMP_FULL_DATABASE TO DATICAL_PACKAGER_ROLE;
...
provide the proper permissions to query the required tables
...
. If these permissions have not been granted, in order to use ephemeral
databaseBackupRestoreMethod
, permissions to queryv$pdbs
...
,
dba_data_files
...
and
v$parameter
tables must be granted.
...
Use Oracle Managed Files (OMF) with Oracle Ephemeral Database
If you are using OMF with BackupRestoreOracleEphemeralExternalPdb, then OMF mode should be the same on both instances of the Oracle database.