Setting Oracle Database Environment Variables after Installation on Linux/OL/Windows

  • Post author:
  • Post category:DBA
  • Post last modified:September 6, 2023

Setting environment parameters after Oracle database installation involves configuring various environment variables and system settings to ensure that the database operates correctly. Here are some steps for Setting oracle database environment variables after installing an Oracle database:

Step1: Oracle User Environment Variables:

  • Log in as the user who installed Oracle (typically, the “oracle” user).
  • Edit the user’s profile file (e.g., ~/.bashrc or ~/.bash_profile) using a text editor like vi or nano.
  • Add or modify the following environment variables:

export TMP=/tmp
export TMPDIR=\$TMP
export ORACLE_HOSTNAME=oractl.a2z.com
export ORACLE_UNQNAME=cdb1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/19c/dbhome_1
export ORA_INVENTORY=/u01/app/oraInventory
export ORACLE_SID=oractl
export PDB_NAME=pdb1
export DATA_DIR=/u01/oradata
export PATH=/usr/sbin:/usr/local/bin:\$PATH
export PATH=\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=\$ORACLE_HOME/jlib:\$ORACLE_HOME/rdbms/jlib

  • Save the file and exit the text editor.
  • Source the profile file to apply the changes immediately:

source ~/.bashrc # or source ~/.bash_profile

[oracle@oractl ~]$ . .bash_profile
or
[oracle@oractl ~]$ source ~/.bash_profile

Step 2: System Environment Variables:

If you haven’t already, set system-wide environment variables in /etc/profile or /etc/environment to make them available to all users. These variables should be similar to those set for the Oracle user, such as ORACLE_HOME, ORACLE_SID, and updating the PATH variable.

  • Open the profile file

[oracle@oractl ~]$ nano /etc/profile

  • Add the following content to the file to set oracle database environment variables.
Setting oracle database environment variables
  • verify the oracle home directory and SID.

[oracle@oractl ~]$ echo $ORACLE_HOME
/u01/app/oracle/product/19c/dbhome_1
[oracle@oractl ~]$ echo $ORACLE_SID
oractl
[oracle@oractl ~]$

Step 3: Listener Configuration (if require)

If you are using Oracle’s listener service, configure it by editing the listener.ora file located in the $ORACLE_HOME/network/admin directory.

Step 4: TNS Names Configuration (if require)

Configure the tnsnames.ora file located in the $ORACLE_HOME/network/admin directory to define your database service names.

Step 5: Start/Stop Oracle Database

Use SQLPlus or another appropriate tool to connect to the database using the configured SID. You can start or stop the database as needed.

Step 6: Testing.

Test the configuration by running SQL*Plus and connecting to the database using the configured SID and credentials.

[oracle@oractl ~]$ sqlplus system/password

SQL*Plus: Release 19.0.0.0.0 – Production on Wed Sep 6 13:08:23 2023
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle. All rights reserved.

Last Successful login time: Wed Sep 06 2023 13:05:13 +05:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 – Production
Version 19.3.0.0.0

SQL>

Step 7: Automatic Environment Setup

To automate the environment setup on system boot, you can create startup scripts or use tools like Oracle’s Database Configuration Assistant (DBCA) or Oracle Restart.

Remember to replace /path/to/oracle_home, your_database_SID, and username/password with the actual values relevant to your Oracle installation and database setup.

Conclusion:

Setting oracle database environment variables after installation completed is a critical step to connect with oracle Database. for in-depth information refer to Oracle documentation and follow best practices specific to your Oracle version and operating system to ensure a proper and secure configuration of your environment parameters after the database installation.

Read More: