These scripts standardize a common environment for large teams that manage numerous servers and databases. They provide a drop-in replacement for the simple yet effective oraenv.
- All scripts use Bash (
#!/bin/bash) and should be sourced, not executed directly, to ensure environment variables are set in the current shell. - Oracle database software owner:
oracle - Grid Infrastructure software owner:
grid - Environment variables such as
ORACLE_HOME,GRID_HOME,ORACLE_HOME_TYPE,ORACLE_HOME_VERSION, andORACLE_HOME_SUFFIXare set in the scripts for consistency. - Directory structure and script sourcing follow the pattern
/u01/scripts/and/u01/app/. - NLS_LANG is set to
AMERICAN_AMERICA.WE8ISO8859P15for Oracle environments.
-
inienv.sh: Initializes the Oracle and Grid environment variables for all users. Sources the appropriate parameter scripts and sets up environment variables based on the detected Oracle Home type and version. -
srvenv.sh: Sets server-wide environment variables and paths required for Oracle software. Handles OS-specific settings and prepares the environment for Oracle operations. -
oraenv_19_oracle_db_1.sh: Sets up the Oracle environment for a specific database version (19c). Sourcessrvenv.shand the corresponding parameter script, then exports variables for Oracle Home. -
parenv_19_oracle_db_1.sh: Contains parameter definitions for Oracle 19c database environments, such as owner, version, type, and NLS settings. Used by other scripts to standardize environment setup. -
oraenv_19_grid_grid.sh: Sets up the Grid Infrastructure environment for version 19. Sourcessrvenv.shand the corresponding grid parameter script. -
parenv_19_grid_grid.sh: Contains parameter definitions for a 19c Grid Infrastructure environment. -
oemenv.sh: Sets up the environment for Oracle Enterprise Manager (OEM) Agent, configuring the necessary variables and paths for OEM operations. -
oracle_.bash_profileandgrid_.bash_profileare simplified variants that replace theinienv.shscript.
oraenv_<version>_<oracle_home_suffix>.shfor Oracle database environments (e.g.,oraenv_19_oracle_db_1.sh, oraenv_19_grid_grid.sh)parenv_<version>_<oracle_home_suffix>.shfor parameter definition files (e.g.,parenv_19_oracle_db_1.sh, parenv_19_grid_grid.sh)srvenv.shfor server-wide environment settingsoemenv.shfor Oracle Enterprise Manager Agent setup
Each parenv_*.sh file should define the following variables:
ORACLE_HOME_TYPE(e.g.,rdbmsorgrid)ORACLE_HOME_SUFFIX(e.g.,db_1)ORACLE_HOME_VERSION(e.g.,19)ORACLE_HOME_OWNER(e.g.,oracleorgrid)ORACLE_NLS_LANG(e.g.,AMERICAN_AMERICA.WE8ISO8859P15)- For Grid environments:
ORACLE_GI_SUFFIX,ORACLE_GI_VERSION,ORACLE_GI_OWNER
- The
oraenv_*.shscripts source the correspondingparenv_*.shfile to set environment variables for a specific Oracle Home. - The
inienv.shscript loops through allparenv_*.shfiles, sourcing each to set up the environment for all available Oracle Homes. srvenv.shis sourced by other scripts to set server-wide variables and paths.- The naming convention ensures that each environment and its parameters are clearly associated, making it easy to manage multiple Oracle installations.
For an Oracle database installation with:
ORACLE_HOME=/u01/app/oracle/product/19/db_1- The ORACLE_HOME path is the source of truth; it dictates how the scripts must be configured so everything resolves to the same directory:
- The parameter file
parenv_19_oracle_db_1.shmust define:ORACLE_HOME_OWNER=oracleORACLE_HOME_VERSION=19ORACLE_HOME_SUFFIX=db_1
- The environment script is named
oraenv_19_oracle_db_1.shto mirror version and suffix.
- The parameter file
- The parameter file name
parenv_19_oracle_db_1.shencodes the version (19) and suffix (db_1), matching the directory structure. - The environment script
oraenv_19_oracle_db_1.shis named to correspond with its parameter file and the specific Oracle Home. - When sourced,
oraenv_19_oracle_db_1.shloadsparenv_19_oracle_db_1.sh, setting all required variables, and then exportsORACLE_HOMEas/u01/app/oracle/product/19/db_1. - This naming and variable convention ensures clarity and consistency, making it easy to manage multiple Oracle installations and their environments.
For a Grid Infrastructure installation with:
ORACLE_HOME=/u01/app/19/grid- The Grid ORACLE_HOME path is the source of truth; it dictates GI variables and file names so the scripts resolve to the same directory:
- GI variables in the parameter file must reflect the path:
ORACLE_GI_VERSION=19ORACLE_GI_SUFFIX=gridORACLE_GI_OWNER=grid
- Set
ORACLE_HOME_TYPE=gridin the correspondingparenv_*.shfile. - As implemented in
inienv.sh, Grid installations set:GRID_HOME=/u01/app/${ORACLE_GI_VERSION}/${ORACLE_GI_SUFFIX}ORACLE_HOME=${GRID_HOME}
- Grid-specific script names would mirror the components (for example,
oraenv_19_grid_grid.shandparenv_19_grid_grid.sh).
- GI variables in the parameter file must reflect the path:
Examples of ORACLE_HOME paths and their corresponding script names:
# RDBMS homes
/u01/app/oracle/product/11.2.0.4/db_1 -> . /u01/scripts/oraenv_11.2.0.4_oracle_db_1.sh
/u01/app/oracle/product/12.1.0.2/db_1 -> . /u01/scripts/oraenv_12.1.0.2_oracle_db_1.sh
/u01/app/oracle/product/12.2.0.1/db_1 -> . /u01/scripts/oraenv_12.2.0.1_oracle_db_1.sh
/u01/app/oracle/product/18/db_1 -> . /u01/scripts/oraenv_18_oracle_db_1.sh
/u01/app/oracle/product/19/db_1 -> . /u01/scripts/oraenv_19_oracle_db_1.sh
/u01/app/oracle/product/19/db_2 -> . /u01/scripts/oraenv_19_oracle_db_2.sh
/u01/app/oracle/product/19/db_3 -> . /u01/scripts/oraenv_19_oracle_db_3.sh
/u01/app/oracle/product/23/db_1 -> . /u01/scripts/oraenv_23_oracle_db_1.sh
...
# Grid Infrastructure home
/u01/app/11.2.0.4/grid -> . /u01/scripts/oraenv_11.2.0.4_grid_grid.sh
/u01/app/12.1.0.2/grid -> . /u01/scripts/oraenv_12.1.0.2_grid_grid.sh
/u01/app/12.2.0.1/grid -> . /u01/scripts/oraenv_12.2.0.1_grid_grid.sh
/u01/app/18/grid -> . /u01/scripts/oraenv_18_grid_grid.sh
/u01/app/19/grid -> . /u01/scripts/oraenv_19_grid_grid.sh
/u01/app/23/grid -> . /u01/scripts/oraenv_23_grid_grid.sh
...Note: The leading dot (.) runs the script with source semantics so variables are applied to your current session.
Usage tree:
~oracle/.bash_profile
└── /u01/scripts/inienv.sh
├── sources: /u01/scripts/parenv_19_oracle_db_1.sh
│ ├── defines environment variables (owner, version, type, NLS)
│ └── used by: oraenv_19_oracle_db_1.sh
├── sources: srvenv.sh (sets server-wide variables and paths)
├── can source: oemenv.sh (for OEM Agent setup)
└── displays environment info and usage instructions
~grid/.bash_profile
└── /u01/scripts/inienv.sh
├── sources: /u01/scripts/parenv_19_oracle_db_1.sh
│ ├── defines environment variables (owner, version, type, NLS)
│ └── used by: oraenv_19_oracle_db_1.sh
├── sources: srvenv.sh (sets server-wide variables and paths)