LINUXOR.SK ... open source notes ...

Oracle RAC - grid_env of the user oracle

category: solutionz · date: 2016-12-31 · updated: 2026-10-02 · author: LALA

Oracle RAC Solution · Config document · referenced from Database creation and user environments

A small file of environment variables that the user oracle sources to point the current shell at the Grid Infrastructure home and the local ASM instance. It is not run as a script: the alias grid_env in .bash_profile sources it.

ItemValue
Path/home/oracle/grid_env
Shown hereoradb01
Deployed onoradb01 and oradb02, one line differs
Activated withgrid_env, an alias for . /home/oracle/grid_env
Depends onGRID_HOME and BASE_PATH from .bash_profile
Counterpartdb_env

The file

bash
ORACLE_SID=+ASM1; export ORACLE_SID
ORACLE_HOME=$GRID_HOME; export ORACLE_HOME
PATH=$ORACLE_HOME/bin:$BASE_PATH; export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

On the second node the notes show the first line and ... for the rest:

HostLineValue
oradb01ORACLE_SID+ASM1
oradb02ORACLE_SID+ASM2

The lines one by one:

LineWhat it does
ORACLE_SID=+ASM1The local ASM instance instead of the database instance
ORACLE_HOME=$GRID_HOME/data/u01/app/grid11204, taken from the variable the profile exports
PATH=$ORACLE_HOME/bin:$BASE_PATHRebuilt from BASE_PATH, so the bin directory of the database home drops out and the one of the Grid home comes first
LD_LIBRARY_PATH, CLASSPATHThe same two lines as in the profile, evaluated again with the new ORACLE_HOME

The file leaves ORACLE_BASE at /data/u01/app/oracle, the value from the profile of oracle, and it does not change the alias sql, which stays sqlplus / as sysdba. The notes test the switch only by printing ORACLE_HOME; they do not show a connection to the ASM instance made this way.

Oracle ships a switcher of its own: root.sh of both homes put oraenv, coraenv and dbhome into /usr/local/bin, as its output shows. The two hand-written files were used instead; the notes do not say why.

← solutionz