8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23ai | Misc | PL/SQL | SQL | RAC | WebLogic | Linux
Read-Only Oracle Homes in Oracle Database 18c
Oracle 18c introduced the concept of a read-only Oracle home, where all configuration and log files can be kept separate from the Oracle binaries.
Read-only Oracle homes are the default in Oracle 21c.
- Why does it matter?
- Prerequisites
- Enable Read-Only Oracle Home
- Create a Database
- Check the File System
- Paths and Navigation
- Miscellaneous
Related articles.
Why does it matter?
For some other products it's a common practice to separate the configuration from the binaries.
- Tomcat has the concept of the
CATALINA_HOME
where the software resides and theCATALINA_BASE
where the config, application files and log files reside. - Best practice for WebLogic installations is to keep the config (domains and applications) outside of the middleware home directory.
- Best practice for Oracle database installations is to keep the datafiles outside of the
ORACLE_HOME
directory.
The concept of a read-only Oracle home is a natural evolution of the database product. It makes it easier to clone and switch between existing Oracle homes during patching and upgrades, without having to seek out all additional config files.
Prerequisites
The article assumes you already have a software-only installation of Oracle database 18c, as described here.
Remember to stop before creating a database instance.
Enable Read-Only Oracle Home
The roohctl
script (Read-Only Oracle Home CTL) is used to enable a read-only Oracle home. There is an example of using it below.
$ cd $ORACLE_HOME/bin $ ./roohctl -enable Enabling Read-Only Oracle home. Update orabasetab file to enable Read-Only Oracle home. Orabasetab file has been updated successfully. Create bootstrap directories for Read-Only Oracle home. Bootstrap directories have been created successfully. Bootstrap files have been processed successfully. Read-Only Oracle home has been enabled successfully. Check the log file /u01/app/oracle/cfgtoollogs/roohctl/roohctl-180728AM112212.log. $
The "homes" and "dbs" directories are created below the ORACLE_BASE
directory.
$ ls $ORACLE_BASE cfgtoollogs checkpoints dbs diag homes product $
The "dbs" directory will be empty until a database is created. The "homes" directory has the following structure.
$ cd $ORACLE_BASE/homes $ tree . └── OraDB18Home1 ├── assistants │ └── dbca │ └── templates ├── dbs ├── install ├── network │ ├── admin │ ├── log │ └── trace └── rdbms ├── audit └── log 13 directories, 0 files $
Create a Database
With the read-only Oracle home enabled, we can now create a database.
lsnrctl start dbca -silent -createDatabase \ -templateName General_Purpose.dbc \ -gdbname ${ORACLE_SID} -sid ${ORACLE_SID} -responseFile NO_VALUE \ -characterSet AL32UTF8 \ -sysPassword SysPassword1 \ -systemPassword SysPassword1 \ -createAsContainerDatabase true \ -numberOfPDBs 1 \ -pdbName ${PDB_NAME} \ -pdbAdminPassword PdbPassword1 \ -databaseType MULTIPURPOSE \ -memoryMgmtType auto_sga \ -totalMemory 2000 \ -storageType FS \ -datafileDestination "${DATA_DIR}" \ -redoLogFileSize 50 \ -emConfiguration NONE \ -ignorePreReqs
Check the File System
Once the database is created, files will be created in the new directories. The contents of the "dbs" directory are displayed below. In a read-write Oracle home we would have expected these files to be under the $ORACLE_HOME/dbs
directory.
$ cd $ORACLE_BASE/dbs $ tree . ├── hc_cdb1.dat ├── initcdb1.ora ├── lkCDB1 ├── orapwcdb1 └── spfilecdb1.ora 0 directories, 5 files $
The contents of the "homes" directory are displayed below.
$ cd $ORACLE_BASE/homes $ tree . └── OraDB18Home1 ├── assistants │ └── dbca │ └── templates ├── dbs ├── install ├── log │ ├── diag │ │ └── adrci_dir.mif │ └── localhost │ └── client │ └── tnslsnr_26425.log ├── network │ ├── admin │ ├── log │ └── trace └── rdbms ├── audit └── log ├── cdb1_ora_26901.trc ├── cdb1_ora_27066.trc ├── cdb1_ora_27164.trc ├── cdb1_ora_27984.trc ├── cdb1_ora_27985.trc ├── cdb1_ora_29244.trc ├── cdb1_ora_29249.trc ├── opatch │ ├── lsinv │ │ ├── lsinventory2018-07-28_11-48-30AM.txt │ │ ├── lsinventory2018-07-28_11-48-34AM.txt │ │ ├── lsinventory2018-07-28_11-53-39AM.txt │ │ ├── lsinventory2018-07-28_11-54-16AM.txt │ │ ├── lsinventory2018-07-28_11-54-20AM.txt │ │ └── lsinventory2018-07-28_11-58-00AM.txt │ ├── opatch2018-07-28_11-48-30AM_1.log │ ├── opatch2018-07-28_11-48-34AM_1.log │ ├── opatch2018-07-28_11-53-39AM_1.log │ ├── opatch2018-07-28_11-54-16AM_1.log │ ├── opatch2018-07-28_11-54-20AM_1.log │ ├── opatch2018-07-28_11-58-00AM_1.log │ └── opatch_history.txt ├── qopatch.log └── qopatch_log.log 19 directories, 24 files $
Paths and Navigation
The "orabasetab" file holds a mapping between the ORACLE_HOME
in the "/etc/oratab" file, the ORACLE_BASE
and the name of the home directory under the "$ORACLE_BASE/homes" directory.
$ cat $ORACLE_HOME/install/orabasetab #orabasetab file is used to track Oracle Home associated with Oracle Base /u01/app/oracle/product/18.0.0/dbhome_1:/u01/app/oracle:OraDB18Home1:Y: $
The orabaseconfig
and orabasehome
commands display the effective locations for configuration. For a read-write Oracle home, both the orabaseconfig
and the orabasehome
commands return the ORACLE_HOME
value. For a read-only Oracle home the orabaseconfig
command returns the ORACLE_BASE
location. For a read-only Oracle home the orabasehome
command returns the relevant path under the "$ORACLE_BASE/homes" directory.
# Read-write Oracle home. $ . oraenv ORACLE_SID = [cdb1] ? The Oracle base remains unchanged with value /u01/app/oracle $ $ORACLE_HOME/bin/orabaseconfig /u01/app/oracle/product/18.0.0/dbhome_1 $ $ORACLE_HOME/bin/orabasehome /u01/app/oracle/product/18.0.0/dbhome_1 $ # Read-only Oracle home. $ . oraenv ORACLE_SID = [cdb1] ? The Oracle base remains unchanged with value /u01/app/oracle $ $ORACLE_HOME/bin/orabaseconfig /u01/app/oracle $ $ORACLE_HOME/bin/orabasehome /u01/app/oracle/homes/OraDB18Home1 $
If the "$ORACLE_HOME/bin" path is part of the PATH
environment variable, we can navigate as follows.
$ cd $(orabaseconfig) $ pwd /u01/app/oracle $ cd $(orabasehome) $ pwd /u01/app/oracle/homes/OraDB18Home1 $
Miscellaneous
The documentation discusses the ORACLE_BASE_HOME
and ORACLE_BASE_CONFIG
paths, but these don't appear to be environment variables that are set or used anywhere. It appears these are just a conceptual thing to help in the description of the paths. Of course, it could also be a misunderstanding on my part.
If you have installed and plan to use any of the demos, you will need to move them out of the read-only Oracle home and replace them with symbolic links. This is described in the documentation here.
For more information see:
- Configuring Read-Only Oracle Homes
- Oracle Database 18c Installation On Oracle Linux 6 (OL6) and 7 (OL7)
Hope this helps. Regards Tim...