dba_setup- Configuring an Efficient Environment
Usually, you will establish a common set of OS variables and aliases in the same manner for every database server. When navigating among servers, you should set these variables and aliases in a consistent and repeatable manner. Doing so helps you (or your team) operate efficiently in every environment. For example, it’s extremely useful to have the OS prompt set in a consistent way when you work with dozens of different servers. This helps you quickly identify what box you’re on, which OS user you’re logged in as, and so on.
One technique is to store these standard settings in a script and then have that script executed automatically when you log in to a server. I usually create a script named dba_setup to set these OS variables and aliases. You can place this script in a directory such as HOME/bin and automatically execute the script via a startup script (see the section “Organizing Scripts” later in this chapter). Here are the contents of a typical dba_setup script:
conn.bsh
You need to be alerted if there are issues with connecting to databases. This script checks to see if a connection can be established to the database. If a connection can’t be established, an e-mail is sent. Place this script in a directory such as HOME/bin. Make sure you modify the script to contain the correct username, password, and e-mail address for your environment.
You also need to establish the required OS variables, such as ORACLE_SID and ORACLE_HOME. You can either hard-code those variables into the script or call a script that sources the variables for you. Like the previous script, this script calls a script (named oraset) that sets the OS variables (see Chapter 2).
The script requires that the ORACLE_SID be passed to it; for example,
If the script can establish a connection to the database, the following message is displayed:
Here are the contents of the conn.bsh script:
This script is usually automated via a utility such as cron. Here is a typical cron entry:
This cron entry runs the script once per hour. Depending on your availability requirements, you may want to run a script such as this on a more frequent basis.