db_homes_config:
db1932-si-ee:
readonly_home: true
oracle_home_name: db1932siee
Out-of-Place Patching - Switch ORACLE_HOME
|
Important
|
Out-of-Place Patching is supported for Single Instance primary databases without and with Oracle Restart. The switch of RAC and RAC One Node databases is not supported. The Grid Infrastructure home of Oracle Restart and of Grid Infrastructure (cluster) 26ai can be switched as well, see Switch of the Grid Infrastructure home (Oracle Restart and cluster). Terms (Oracle Restart, Grid Infrastructure, RAC): see Featurelist. The guide describes the concept, all dependencies and the gaps in the current implementation. |
Out-of-Place Patching switches a database from its current ORACLE_HOME to another, already installed and patched ORACLE_HOME.
The installation and patching of the new ORACLE_HOME is not part of Out-of-Place Patching.
It is done before with other roles (oraswdb_install, oraswdb_manage_patches or from a Golden Image).
Advantages compared to In-Place Patching with opatch apply:
-
The new
ORACLE_HOMEis installed and patched before the switch without downtime, because no database is running from it. -
The downtime is reduced to a restart of the database and
datapatch. -
Fallback is easy: the old
ORACLE_HOMEis still available.
|
Note
|
A Golden Image is recommended, but not required. The new ORACLE_HOME can also be installed and patched with ansible-oracle on the database server.
The switch of the database is independent from the way the new ORACLE_HOME was created.
See Preparation of the new ORACLE_HOME.
|
1. Requirements
-
Oracle Database 19c or newer
-
Read-Only Oracle Homes (
readonly_home: true) are recommended, but not required-
Configuration files like SPFile and password file are not part of the
ORACLE_HOMEand are shared between all Read-Only `ORACLE_HOME`s. -
The switch copies SPFile, PFile and password file, when the location differs between old and new
ORACLE_HOME(e.g. switch from a Read-Write into a Read-OnlyORACLE_HOME). -
readonly_homemust not be changed for an installedORACLE_HOME.
-
-
Each Read-Only
ORACLE_HOMEneeds 2 attributes indb_homes_config: -
oracle_home_nameis mandatory:-
It cannot be derived from the key in
db_homes_config. Oracle allows only characters, numbers and_in the name of anORACLE_HOMEin the Oracle Inventory. YAML keys are much less restrictive (e.g.db1932-si-eeis a valid key, but not a validoracle_home_name). -
It must be unique over all
ORACLE_HOME`s on a server. It defines the `ORACLE_BASE_HOME($ORACLE_BASE/homes/<oracle_home_name>), which must not be shared between the old and the newORACLE_HOME.
-
-
Enough disk space for at least 2 `ORACLE_HOME`s at the same time
2. Read-Only Oracle Home
A Read-Only Oracle Home separates the software from the configuration.
The locations are reported by orabasehome and orabaseconfig.
| Location | Path | Shared between ORACLE_HOMEs | Content |
|---|---|---|---|
|
e.g. |
no |
Software only |
|
|
yes |
SPFile, password file, |
|
|
no |
|
|
Important
|
ORACLE_BASE_CONFIG is shared, but ORACLE_BASE_HOME is not.All files in $ORACLE_BASE/homes/<oracle_home_name>/network/admin must exist in the new ORACLE_HOME before the switch.
|
3. Process overview
-
Prepare the new
ORACLE_HOME(no downtime)-
Install the new
ORACLE_HOMEwithoraswdb_install/oraswdb_manage_patches(not part of Out-of-Place Patching), one of:-
from a Golden Image (recommended)
-
from the base release, followed by
opatch applyfor all patches
-
-
Create the network configuration in the new
ORACLE_BASE_HOME
-
-
Switch the database (downtime) - Out-of-Place Patching with
oradb_manage_db-
Stop the database (and listener) from the old
ORACLE_HOME -
Change the
ORACLE_HOMEin/etc/oratabor in Oracle Clusterware (srvctl) -
Start the listener and database from the new
ORACLE_HOME -
Execute
datapatch
-
-
Post tasks
-
APEX, time zone, statistics, etc. (optional)
-
Remove the old
ORACLE_HOMEafter a successful test period
-
4. Preparation of the new ORACLE_HOME
The new ORACLE_HOME can be prepared in 2 ways.
Both are supported by ansible-oracle and both lead to the same result for the switch.
| Topic | Golden Image | Install and patch on the server |
|---|---|---|
Source |
Golden Image ( |
Base release (e.g. 19.3) + patches from |
Patching |
Included in the Golden Image. Additional patches are possible like for the base release. |
|
Duration on the database server |
Short (unzip + |
Long ( |
Identical `ORACLE_HOME`s on all servers |
Guaranteed by the Golden Image |
Depends on identical patch lists in the inventory |
Software needed on the server |
Golden Image only |
Base release, OPatch and all patches |
Relink options (e.g. Unified Auditing, dNFS) |
Included in the Golden Image, checked by |
Set by |
Downtime |
None |
None - no database is running from the new |
Recommendation: download the Golden Image created by Oracle with the role autoupgrade
(gold_image in autoupgrade_download_patches or autoupgrade_download_gold_image).
This is the way with the least effort, because no ORACLE_HOME has to be installed and patched for creating the Golden Image.
Alternative: create the Golden Image once from an ORACLE_HOME installed and patched by ansible-oracle (role oraswdb_golden_image),
e.g. when one-off patches are needed, which are not part of the Golden Image from Oracle.
Use the Golden Image for all servers.
|
Important
|
The implementation of the switch must not depend on the way the new ORACLE_HOME was prepared.The only requirement for the switch is an installed and fully patched ORACLE_HOME.
|
5. Dependencies
5.1. Registration of the ORACLE_HOME
| Environment | Registration | Switch |
|---|---|---|
Single Instance without Oracle Restart |
|
Replace the line |
Oracle Restart |
Oracle Clusterware (OCR/OLR) |
|
Grid Infrastructure (cluster): RAC, RAC One Node |
Oracle Clusterware (OCR) |
Rolling switch node by node. Not supported. |
The following parts of ansible-oracle read the ORACLE_HOME from /etc/oratab and follow the switch automatically:
-
systemd service /
manage_oracle_rdbms_procs.sh(start/stop of databases, without Oracle Restart only) -
ocenv/.profile_<ORACLE_SID> -
rman_backup.shfrom roleoradb_rman(with Oracle Restart from the database resource,crsctl)
5.2. Stop and Start
-
The database must be stopped from the old
ORACLE_HOME. -
With Oracle Restart the stop must be done with
srvctlfrom the oldORACLE_HOME, beforesrvctl modify databaseis executed. -
The start is done from the new
ORACLE_HOME.
5.3. Listener
-
A listener running from the database
ORACLE_HOMEmust be restarted from the newORACLE_HOME. -
All databases served by this listener must be switched together. Recommendation: run the listener from the Grid Infrastructure home of Oracle Restart or from a dedicated
ORACLE_HOME. -
Static registrations in
SID_LIST_<LISTENER>contain theORACLE_HOME:-
Data Guard Broker (
<db_unique_name>_DGMGRL) -
extproc -
Static service entries
-
5.4. Network configuration and wallets
-
sqlnet.ora,tnsnames.oraandlistener.oramust exist in$ORACLE_BASE/homes/<new oracle_home_name>/network/admin. Alternative: a centralTNS_ADMIN. -
WALLET_LOCATIONorENCRYPTION_WALLET_LOCATIONinsqlnet.oramust not point into the oldORACLE_HOME. -
TDE with the init parameter
WALLET_ROOTis independent from theORACLE_HOME. -
local_listenermust not be an alias fromtnsnames.oraof the oldORACLE_HOME. DBCA setslocal_listenertoLISTENER_<DB_NAME>and writes this alias intotnsnames.oraof theORACLE_HOME. The alias is missing in the newORACLE_HOME, the instance does not register at the listener (ORA-12514).orasw_metarequireslocal_listenerwith EZConnect ininit_parametersof Single Instance databases, e.g.//localhost:1521(see breaking_changes.adoc). Other entries from DBCA intnsnames.oraof the oldORACLE_HOMEare not copied.
5.5. datapatch
-
datapatchis mandatory after the start from the newORACLE_HOME. -
datapatchmust be executed for the CDB and all PDBs. -
OJVM patches may need a startup in upgrade mode, depending on the release.
-
Data Guard:
datapatchis executed on the primary database only.
5.6. Directory objects
Directory objects can point into the old ORACLE_HOME.
The OPatch directories are changed by datapatch, own directories are not.
select directory_name, directory_path from dba_directories where directory_path like '/u01/app/oracle/product/19/db19_2601%';
5.7. Content of the ORACLE_HOME
The new ORACLE_HOME must contain all customizations of the old ORACLE_HOME:
-
Relink options (e.g. Unified Auditing, dNFS) - included in a Golden Image or set by
oraswdb_install -
One-off patches - included in a Golden Image or defined in
db_homes_config[].opatchfor the newORACLE_HOME -
oranfstab -
Custom DBCA templates
5.8. Data Guard
-
The standby databases are switched first.
-
The primary database is switched afterwards, followed by
datapatch. -
Static listener registrations for the Data Guard Broker must be changed (see Listener).
5.8.1. Physical Standby
|
Important
|
Not implemented yet. The current implementation opens every database after the switch and executes datapatch.
|
A physical standby database must be handled differently from a primary database:
-
The standby database is started in
MOUNTonly. Opening the database while Redo Apply is running uses Active Data Guard, which needs an extra license. This is valid even when the standby database was openedREAD ONLY WITH APPLYbefore the switch. -
datapatchmust not be executed on a standby database. The SQL changes are applied with Redo Apply from the primary database.
The role of the database is read after startup mount from the controlfile:
startup mount select database_role from v$database;
| DATABASE_ROLE | Open database | datapatch |
|---|---|---|
|
yes (+ all PDBs) |
yes |
|
no, remains in |
no |
Redo Apply after the switch:
-
With Data Guard Broker (
dg_broker_start=TRUE) the broker restarts Redo Apply automatically. -
Without Data Guard Broker Redo Apply must be restarted manually.
ansible-oracledoes not start Redo Apply, because it does not manage Data Guard configurations.alter database recover managed standby database disconnect;
5.9. External dependencies
-
Enterprise Manager and other monitoring targets
-
Scripts and crontabs with a hard coded
ORACLE_HOME -
Applications with a local
ORACLE_HOME(e.g. Bequeath connections)
6. Implementation in ansible-oracle
6.1. Existing features
Out-of-Place Patching itself is the switch of the ORACLE_HOME in oradb_manage_db.
The other features prepare the new ORACLE_HOME and are used before the switch.
| Feature | Role | Comment |
|---|---|---|
Read-Only Oracle Home |
|
|
Install from base release |
|
Without |
Patch the new |
|
|
Download Golden Image from Oracle (recommended) |
|
|
Create Golden Image (optional) |
|
|
Install from Golden Image (optional) |
|
|
Relink options |
|
Enforced for every |
Network configuration |
|
Files are created in |
|
|
|
Remove |
|
|
Switch |
|
Change of |
Switch |
|
Change of |
|
|
|
|
|
An |
|
|
|
|
|
|
Switch Grid Infrastructure home of Oracle Restart |
|
Change of |
6.2. Gaps
| Gap | Location | Description |
|---|---|---|
Incomplete check of |
|
Only the existence of |
6.3. ORACLE_HOME without database
An ORACLE_HOME in db_homes_installed without a database in oracle_databases is a valid configuration:
-
The new
ORACLE_HOMEhas no database before the switch. -
The old
ORACLE_HOMEhas no database after the switch, until it is removed. -
Listeners can run from a dedicated
ORACLE_HOMEwithout database.
The oracle_db_type must still be identical for all databases in the same ORACLE_HOME.
All roles and asserts must support an ORACLE_HOME without database.
7. Switch of the Grid Infrastructure home (Oracle Restart and cluster)
The Grid Infrastructure home of Oracle Restart and of Grid Infrastructure (cluster) is switched by oraswgi_install,
when oracle_home_gi differs from crs_home in /etc/oracle/olr.loc.
The new home is created from oracle_install_image_gi, normally a gold image of the new Release Update.
|
Important
|
Supported for Oracle Restart 26ai and Grid Infrastructure (cluster) 26ai inside the same release (e.g. 23.26.3 ⇒ 23.26.4). Not supported for 19c: -switchGridHome is not supported by Oracle for Oracle Restart 19c (INS-45101, MOS 2764906.1),
19c Grid Infrastructure (cluster) is not implemented.Grid Infrastructure (cluster): tested with 2 nodes and a RAC database (molecule scenario rac, side_effect.yml).
|
| Step | User | Description |
|---|---|---|
Extract |
grid |
Without downtime. |
|
grid |
Software only installation with Oracle base and groups of the old home. Registers the new home in the central inventory. |
|
grid |
Prepares the switch. Without downtime. |
|
root |
Oracle Restart: |
|
grid |
|
gi_ignoreprereq: true adds -ignorePrereqFailure to gridSetup.sh and -ignoreSysPrereqs to runInstaller.
Listeners running from the Grid Infrastructure home (e.g. LISTENER) are moved with the stack, listener.ora is copied into the new home.
Listeners and databases in database homes are not changed.
The old Grid Infrastructure home is not removed by the switch.
Oracle Restart: a switch back to the old home is done in the same way by setting oracle_home_gi to the old home.
Grid Infrastructure (cluster):
-
A switch back into a former home is not implemented: the former running home is locked by
root.sh(e.g.bin/crsctl.binowned byroot),oraswgi_installstops with an assert. Use a neworacle_home_gi. -
When
root.shfails before the switch (e.g. the CVU check ofrootcrs.pl -prepatch), the next run resumes withroot.sh:-switchGridHomeis skipped, whenrootconfig.shof the new home is already owned byroot.
7.1. Removal of obsolete Grid Infrastructure homes
oraswgi_install_remove_obsolete_homes: true removes obsolete Grid Infrastructure homes with deinstall.
Without it, old homes stay for a switch back.
The source is the central inventory only. Obsolete is every home in the central inventory
-
with the component
oracle.crs(1st component in<home>/inventory/ContentsXML/comps.xml), database homes are never removed, -
which is not
crs_homein/etc/oracle/olr.locand notoracle_home_gi.
Homes or directories, which are not registered in the central inventory, are not touched and must be removed manually.
The removal is only done, when Oracle Restart runs from oracle_home_gi (completed switch).
| Step | User | Description |
|---|---|---|
|
grid |
Creates the response file. The role stops with an error, when |
|
root |
Only for a locked home (owner |
|
grid |
Removes the software and the home from the central inventory. No downtime. |
|
root |
Only, when requested in the output of |
|
Note
|
deinstall of an obsolete home prints Oracle Restart is stopped and de-configured successfully and requests
rootdeinstall.sh "to remove the configuration of the Oracle Restart".
This is the standard text of deinstall: the running Oracle Restart in crs_home is not changed
(tested with 23.26.3 ⇒ 23.26.4: resources, /etc/oracle/olr.loc, oracle-ohasd.service, +ASM in /etc/oratab
and listener.ora of the running home unchanged).
|
|
Note
|
Oracle documents deinstall of the home itself (same release) after an unlock for the previous release Grid home
after an upgrade ("Unlocking and Deinstalling the Previous Release Grid Home").
The removal of an old home of the same release after -switchGridHome is not described explicitly.
|
oracle_install_option_gi: HA_CONFIG
oracle_install_version_gi: 26.1.0.0
# 1st installation: gi_goldimage_26_03.zip, /u01/app/oracle/product/26/restart_26.03
oracle_install_image_gi: gi_goldimage_26_04.zip
oracle_home_gi: /u01/app/oracle/product/26/restart_26.04
8. Inventory example
The ORACLE_HOME for each Release Update gets its own entry in db_homes_config with a unique oracle_home and oracle_home_name.
Both ways to prepare the new ORACLE_HOME can be mixed, e.g. the old ORACLE_HOME from a Golden Image and the new one installed and patched on the server.
db_homes_config with Golden Imagedb_homes_config:
db19_2601:
version: 19.3.0.0
oracle_home: /u01/app/oracle/product/19/db19_2601
oracle_home_name: db19_2601
readonly_home: true
edition: EE
imagename: db_home_19.30.zip
db_homes_config installed and patched on the serverdb_homes_config:
db19_2604:
version: 19.3.0.0
oracle_home: /u01/app/oracle/product/19/db19_2604
oracle_home_name: db19_2604
readonly_home: true
edition: EE
opatch_minversion: 12.2.0.1.48
opatch:
- patchid: <RU patch id>
# Database Release Update 19.31
state: present
- patchid: <OJVM patch id>
# Oracle JavaVM Component Release Update 19.31
state: present
|
Note
|
stop_processes is not needed for the patches of the new ORACLE_HOME.
|
ORCL from db19_2601 to db19_2604db_homes_installed:
- home: db19_2601
state: present
- home: db19_2604
state: present
oracle_databases:
- home: db19_2604 # (1)
oracle_db_name: ORCL
state: present
-
Changing
homeis the trigger for the switch. See Existing features.
9. Open questions
-
oraswdb_installderives the type of anORACLE_HOME(SI or cluster installation) from the databases inoracle_databases. AnORACLE_HOMEwithout database is installed asSI. A new RACORACLE_HOMEneeds the cluster installation before the switch ⇒ explicit type indb_homes_config(e.g.oracle_db_type)? -
Handling of a listener shared by databases in different `ORACLE_HOME`s
-
Fallback to the old
ORACLE_HOME(datapatchrollback)