Datapatch and Delphix
Overview
Oracle typically releases a major update yearly, and patch updates quarterly, for their database software. This is in addition to one-off patches for a specific customer (equivalent to a Delphix hotfix). The major releases are identified by the first digit in the release string, i.e. Oracle 18 vs Oracle 19. Patch releases (known as release updates and release update revisions) are identified by the second and third digits, i.e. 18.5.0 vs 18.7.1.
For Oracle 12c, the major version is considered to be 12.2.0.1. Release updates are still produced quarterly for 12c, but they do not change the actual version string.
Moving from one major release to another requires going through the upgrade process, while moving from a patch release requires going through the patch process.
In either the upgrade or patching scenario, following needs to be updated:
Oracle binaries themselves (i.e. the contents of the Oracle home). Oracle provides a tool OPatch for patching Oracle binaries.
database files (i.e. the Oracle data dictionary and built in PL/SQL packages). Oracle provides a tool known as Datapatch to accomplish this.
After the binary patching has been completed (on all nodes for a cluster), the database files are then patched. Oracle provides a tool known as Datapatch to accomplish this. Datapatch can be invoked either for an entire container and all PDBs within it, or a given set of PDBs. The purpose of Datapatch is to bring the SQL patch level in line with the current binary patch level of the database in which it is run. This may involve applying or rolling back patches in SQL depending on the current state of the SQL and binary patch registries.
Datapatch should be invoked whenever the database has been moved from one Oracle home to another, or when the binaries in the existing Oracle home are updated. This also applies to a PDB. In particular, when a PDB is unplugged from a source container, and then plugged into a target container running in a different Oracle home, the SQL patch registry within the PDB will reflect the source container state, rather than the target container state. Oracle detects this when opening the PDB, and generates a plug in violation and prevents the PDB from being opened in normal mode. After running datapatch on the PDB to bring its SQL state in line with the target container state (which should already be in line with the target binary state) the PDB can be closed and reopened in normal mode, clearing the violation.
For more detailed information, please refer to the Oracle Datapatch User Guide.
Delphix Implementation of Datapatch Invocation
Delphix supports customers to run Datapatch against their virtual databases when the databases are created, refreshed, rewound, started, or enabled via Delphix GUI or CLI. Delphix does not support running Datapatch for a database if it’s not managed by Delphix (e.g. linked CDB, PDB, non-multitenant database) or it’s a vCDB with multiple vPDBs, customers can run Datapatch for these databases without Delphix if necessary.
Delphix support for Datapatch has the following requirements:
Binary patching should be completed (on all nodes for a cluster) on the target environment.
Datapatch should be applied to the target Linked CDB or existing vCDB before Datapatch is applied to a vPDB in the CDB.
Delphix can invoke Datapatch against a virtual database in the following scenarios:
Provision an Oracle VDB (Non-multitenant Virtual Database)
When provisioning a VDB, if the Invoke Datapatch option is checked on the Advanced page, Delphix invokes Datapatch for the VDB during provision. After the VDB is provisioned, it’s patched with the same patch level as that of the target Oracle home.
If the Invoke Datapatch option is checked for the VDB, Datapatch is invoked against the VDB when it’s refreshed, rewound, started, or enabled unless the option is unchecked as described in Configuration Settings for Oracle Virtual Databases.
Provision an Oracle vPDB into a linked CDB or existing vCDB
Delphix does not apply Datapatch against a linked CDB or existing vCDB, it’s your responsibility to ensure that the linked CDB or existing vCDB is fully patched (i.e. the root container’s SQL patch level is in line with the binary patch level of the Oracle home) before provisioning a vPDB into the CDB.
If the Invoke Datapatch option is checked in the Advanced page when provisioning an Oracle vPDB into a linked CDB or existing vCDB, after the provision, the provisioned vPDB is patched with the same patch level of the target Oracle home. Delphix only applies Datapatch against the newly provisioned vPDB, any existing PDB/vPDB in the CDB is not impacted.
If the Invoke Datapatch option is checked for the vPDB, Datapatch is invoked against the vPDB when it’s refreshed, rewound, started, or enabled unless the option is unchecked as described in Configuration Settings for Oracle Virtual Databases.
Provision an Oracle vPDB into a new vCDB
If the Invoke Datapatch option is checked in the Advanced page when provisioning an Oracle vPDB into a new vCDB, Delphix patches both the vPDB and vCDB during provision. After the provision, both vPDB and vCDB are patched with the same patch level of the target Oracle home.
If the Invoke Datapatch option is checked for the vPDB, Datapatch is invoked against the vPDB and vCDB when they are refreshed, rewound, started, or enabled unless the option is unchecked as described in Configuration Settings for Oracle Virtual Databases.
Refresh, rewind, start, or enable a VDB or vPDB
If the Invoke Datapatch option is checked for the VDB or vPDB (the option can be switched in as described in Configuration Settings for Oracle Virtual Databases), when the VDB or vPDB is refreshed, rewound, started, or enabled, Delphix applies Datapatch for them.
If a vPDB is the only vPDB in a vCDB, when the vPDB is refreshed, rewound, started, or enabled, Delphix applies Datapatch for both the vPDB and vCDB.
If a vPDB is not the only vPDB in a vCDB, when the vPDB is refreshed, rewound, started, or enabled, Delphix applies Datapatch for the vPDB only. The vCDB and other vPDBs in the vCDB are not impacted.
Start or enable a vCDB
When all vPDBs in a vCDB are stopped/disabled, Delphix allows users to start or enable the vCDB before starting/enabling its vPDBs. In this case, if the Invoke Datapatch option is checked for the vCDB, Delphix runs Datapatch for the vCDB during its start/enable. Its vPDBs are not impacted. But Delphix applies Datapatch against the vPDBs when they are refreshed, rewound, started, or enabled and the Invoke Datapatch option is checked.
For all the scenarios where Datapatch is invoked, Delphix invokes Datapatch in the target environment, that’s to say, the source environment is not impacted by Datapatch.
When to select the Invoke Datapatch option in Delphix?
Datapatch is designed to be idempotent, thus users can run Datapatch against the same database multiple times even if it has been fully patched. If the database is fully patched, running Datapatch is a no-op, it makes no change to the database, although it takes a couple of minutes for Datapatch to check the patch status of the database. Delphix provides users the flexibility to run or not run Datapatch for a virtual database by switching the Invoke Datapatch option for the virtual database as described in Configuration Settings for Oracle Virtual Databases at any time.
When provisioning a VDB or vPDB, if the source database has a different patch level than the target Oracle home, in order to apply Datapatch, users may check the Invoke Datapatch option during provision, so that it’s patched after the provision.
If a new patch is applied to the Oracle home where a VDB, vPDB, or vCDB is already running, in order to apply Datapatch, users may check the Invoke Datapatch option described in Configuration Settings for Oracle Virtual Databases for the VDB, vPDB, or vCDB and refresh, rewind, stop/start, disable/enable it with Delphix.
If a VDB or vPDB is migrated to another environment that has a different patch level than the original environment, to apply Datapatch, users may check the Invoke Datapatch option for the VDB or vPDB before enabling the VDB or vPDB in the new environment.
Required OS Permissions for the Delphix User
Delphix invokes Datapatch within the context of the environment user associated with the virtual database. This user does not have to be an Oracle user, and in fact, often is not. While Datapatch needs to be executed by the Oracle user. Thus the environment user is required to set up the necessary sudo configuration for executing Datapatch as the Oracle user on the target environment where Datapatch is executed, and Delphix verifies this before invoking Datapatch.
For more information, see Sudo Privilege Requirements for Oracle Environments and Sudo File Configuration Examples for Oracle Environments.