Skip to content

Maintains Bash scripts standardizing Oracle Database, Grid Infrastructure, and OEM agent environments across fleets; replaces oraenv with consistent detection, parameter controls, and server setup; streamlines onboarding via ORACLE_HOME naming rules.

Notifications You must be signed in to change notification settings

marcuoli/Oracle-ENV-Scripts

Repository files navigation

Oracle-ENV-Scripts

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.

Conventions

  • 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, and ORACLE_HOME_SUFFIX are 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.WE8ISO8859P15 for Oracle environments.

File descriptions

  • 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). Sources srvenv.sh and 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. Sources srvenv.sh and 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_profile and grid_.bash_profile are simplified variants that replace the inienv.sh script.

Script naming and parameter file conventions

Script naming

  • oraenv_<version>_<oracle_home_suffix>.sh for Oracle database environments (e.g., oraenv_19_oracle_db_1.sh, oraenv_19_grid_grid.sh)
  • parenv_<version>_<oracle_home_suffix>.sh for parameter definition files (e.g., parenv_19_oracle_db_1.sh, parenv_19_grid_grid.sh)
  • srvenv.sh for server-wide environment settings
  • oemenv.sh for Oracle Enterprise Manager Agent setup

Parameter file variables (parenv_*.sh)

Each parenv_*.sh file should define the following variables:

  • ORACLE_HOME_TYPE (e.g., rdbms or grid)
  • ORACLE_HOME_SUFFIX (e.g., db_1)
  • ORACLE_HOME_VERSION (e.g., 19)
  • ORACLE_HOME_OWNER (e.g., oracle or grid)
  • ORACLE_NLS_LANG (e.g., AMERICAN_AMERICA.WE8ISO8859P15)
  • For Grid environments: ORACLE_GI_SUFFIX, ORACLE_GI_VERSION, ORACLE_GI_OWNER

Relationships

  • The oraenv_*.sh scripts source the corresponding parenv_*.sh file to set environment variables for a specific Oracle Home.
  • The inienv.sh script loops through all parenv_*.sh files, sourcing each to set up the environment for all available Oracle Homes.
  • srvenv.sh is 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.

Example: ORACLE_HOME and variable/file relationships

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.sh must define:
      • ORACLE_HOME_OWNER=oracle
      • ORACLE_HOME_VERSION=19
      • ORACLE_HOME_SUFFIX=db_1
    • The environment script is named oraenv_19_oracle_db_1.sh to mirror version and suffix.
  • The parameter file name parenv_19_oracle_db_1.sh encodes the version (19) and suffix (db_1), matching the directory structure.
  • The environment script oraenv_19_oracle_db_1.sh is named to correspond with its parameter file and the specific Oracle Home.
  • When sourced, oraenv_19_oracle_db_1.sh loads parenv_19_oracle_db_1.sh, setting all required variables, and then exports ORACLE_HOME as /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=19
      • ORACLE_GI_SUFFIX=grid
      • ORACLE_GI_OWNER=grid
    • Set ORACLE_HOME_TYPE=grid in the corresponding parenv_*.sh file.
    • 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.sh and parenv_19_grid_grid.sh).

Quick examples: file name patterns for other versions

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.

Script usage

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)

About

Maintains Bash scripts standardizing Oracle Database, Grid Infrastructure, and OEM agent environments across fleets; replaces oraenv with consistent detection, parameter controls, and server setup; streamlines onboarding via ORACLE_HOME naming rules.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages