Home arrow Oracle arrow Page 13 - Oracle Application Server 10g Architecture and Administration

Command Line Interface and Scripts - Oracle

Get an overview of the Oracle Application Server 10g architecture, its functional components, the administrative tools for application development, and examples of commands that are used to perform frequent Application Server 10g administrative functions. This chapter is from the book, Oracle Application Server 10g Administration Handbook, by John Garmany and Donald K. Burleson (McGraw-Hill/Osborne, ISBN: 0072229586, 2004).

TABLE OF CONTENTS:
  1. Oracle Application Server 10g Architecture and Administration
  2. Hardware Architecture of Application Server 10g
  3. Client Tier, Web Tier, OHS, and Web Cache
  4. App Server Tier, Partitioning
  5. Application Server 10g Clusters and Farms and Database Tier
  6. Application Server Discoverer
  7. Oracle Application Server Wireless
  8. Single Sign-On (SSO)
  9. Oracle Application Server 10g Administration
  10. Command-Line Interfaces or OEM?
  11. Instance Manager Home Page
  12. Category Command Usage Table
  13. Command Line Interface and Scripts
  14. EM Commands with emctl
  15. Managing Application Server 10gwith dcmctl
  16. Miscellaneous Application Server 10g Commands and Sumary
By: McGraw-Hill/Osborne
Rating: starstarstarstarstar / 66
July 13, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Knowing these commands (in the table on the previous page) and their parameters for Application Server 10g is very useful for automating administrative functions and creating batch scripts. These commands can easily be placed into scripts (shell scripts in Linux and UNIX) that can be executed to automate routine management tasks.

While each product with Application Server 10g has control files, there are three main command-line interfaces:

  • opmnctl -- This is the control interface for the Process Management Notification (OPM) component. The opmnctl interface is located at $ORACLE_HOME/opmn/bin/opmnctl. The opmnctl interface provides a startall and stopall argument that will manage all of the Application Server 10g server processes.

  • dcmctl -- This is the control interface for the Distributed Configuration Manager (DCM) component. The dcmctl interface is located at $ORACLE_HOME/dcm/bin/dcmctl.

  • emctl -- This is the Enterprise Manager console utility. The emctl executable is located in $ORACLE_HOME/bin/emctl. It is used for managing the OEM agents, changing OEM passwords, starting the OEM console, and other miscellaneous tasks.

These command-line interfaces are critical for Application Server 10g administrative scripts. Letís take a look at how command-line interfaces are used as scripts.

Using Scripts to Manage Application Server 10g

You can automate many areas of Application Server 10g administration using scripts. Here is an example of a command list to start the iasdb database, the listener, the infrastructure instance, a midtier instance, and the Enterprise Manager web site on both instances.

echo Setting Env for Infrastructure

source envInfra.sh
echo Starting Listener
$ORACLE_HOME/bin/lsnrctl start
echo Starting Database
$ORACLE_HOME/bin/sqlplus /nolog<<EOF
connect / as sysdba
startup
EOF
echo Starting all opmnctl controlled processes
$ORACLE_HOME/opmn/bin/opmnctl startall
echo Starting the EM website
#$ORACLE_HOME/bin/emctl start em
echo Setting Env for MidTier Instance
source envMidtier.sh
echo Starting all opmnctl controlled processes
$ORACLE_HOME/opmn/bin/opmnctl startall
echo Starting the EM website
#$ORACLE_HOME/bin/emctl start em
echo Startup Completed
 

By themselves, the command list is not very useful, but it becomes very powerful when embedded into a shell script. The source envMidtier.sh statement changes the ORACLE_HOME environmental variable. Each instance of Application Server 10g must be installed in its own ORACLE_HOME. This is covered in the Chapter 2. Because the Application Server 10g commandline utilities exist in many locations, it is critical that you set up your OS environment so that your scripts can locate all of the utilities. Here are examples of the proper PATH commands for UNIX and Windows. These are normally placed in the startup shell script to be executed at sign-on time.

UNIX PATH Setup

ORACLE_HOME=/u01/app/oracle/product/9.2.0
export ORACLE_HOME
PATH=.:$PATH:.;$ORACLE_HOME/dcm/bin/:$ORACLE_HOME
/j2ee/home/:$ORACLE_HOME/ldap/bin/:$ORACLE_
HOME/ldap/odi/admin/:$ORACLE_HOME/oca/bin
/:$ORACLE_HOME/opmn/bin/:$ORACLE_HOME/portal/admin/
plsql/sso/:$ORACLE_HOME/sso/lib/:$ORACLE_HOME/uddi
/lib/:$ORACLE_HOME/upgrade/:$ORACLE_HOME/
wireless/bin/

Windows PATH Setup

Set ORACLE_HOME=c:oracleora92
SETPATH=.;$PATH;%ORACLE_HOME%dcmbin;%ORACLE_HOME%j2eehome;%ORACLE_HOME%ldapbin
;%ORACLE_HOME%ldapodiadmin;%ORACLE_HOME%ocabin;%ORACLE_HOME%opmnbin;%ORACLE_HOME%
portaladminplsqlsso;%ORACLE_HOME%ssolib;%ORACLE_HOME%uddilib;%ORACLE_HOME%upgrade
;%ORACLE_HOME%wirelessbin

Once you have established the PATH variable, you can create shell scripts that can be submitted in batch mode (in UNIX with the nohup command) to automate Application Server 10g administrative tasks. For example, an Application Server 10g management shell script could be scheduled in the UNIX crontab to perform a scheduled shutdown of all services.

Of course, the PATH variable is only a part of an Application Server 10gscript, and the complete environment, including ORACLE_BASE, ORACLE_HOME, and ORACLE_SID, must be enabled. The env.ksh script shows a common environmental setting for Application Server 10g command scripts. Note that $ORACLE_HOME is set to ORACLE_BASE/midtier for midtier command scripts and ORACLE_BASE/infra for infrastructure command scripts. Every Application Server 10g instance must be installed in a unique ORACLE_HOME, and startup/shutdown scripts must set the environment variables for that instance.

env.sh

#!/bin/ksh
export ORACLE_BASE=/private/ias
# Use this ORACLE_HOME for midtier applications
#export ORACLE_HOME=$ORACLE_BASE/midtier
# Use this ORACLE_HOME for infra applications
export ORACLE_HOME=$ORACLE_BASE/infra
SETPATH=.;$PATH;%ORACLE_HOME%dcmbin;%ORACLE_HOME%j2eehome;%ORACLE_HOME%ldapbin
;%ORACLE_HOME%ldapodiadmin;%ORACLE_HOME%ocabin;%ORACLE_HOME%opmnbin;%ORACLE_HOME%
portaladminplsqlsso;%ORACLE_HOME%ssolib;%ORACLE_HOME%uddilib;%ORACLE_HOME%upgrade
;%ORACLE_HOME%wirelessbin
export ORACLE_SID=iasdb
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
#export DISPLAY=tor:2.0
echo ORACLE_HOME : $ORACLE_HOME
echo ORACLE_SID : $ORACLE_SID
echo DISPLAY : $DISPLAY
echo Set PATH and LD_LIBRARY_PATH

Here is a script to submit when there is a problem with OHS and you need to restart it. Some Application Server 10g administrators place Apache user-exit code to automate the bouncing of the OHS. For example, if an external connection fails to attach to an OHS listener, after ten seconds, the following code could be automatically invoked to bounce OHS.

bounce_ohs.ksh

#**************************************************
# Copyright (c) 2003 by Donald K. Burleson
#
#**************************************************
# Exit if no first parameter $1
if [ -z "$1" ]
then
echo "ERROR: Please pass a valid ORACLE_SID to this script"
exit 99
fi
# Validate Oracle
TEMP=`cat /etc/oratab|grep ^$1:|cut -f1 -d':'|wc -l`
tmp=`expr TEMP` # Convert string to number
if [ $tmp -ne 1 ]
then
echo
echo "ERROR: Your input parameter $1 is invalid. Please Retry"
echo
exit 99
fi
if [ `whoami` != 'oracle' ]
then
echo "Error: You must be oracle to execute the script. Exiting."
exit
fi
# First, we must set the environment . . . .
export ORACLE_BASE=/private/ias
# Use this ORACLE_HOME for midtier applications
#export ORACLE_HOME=$ORACLE_BASE/midtier
# Use this ORACLE_HOME for infra applications
export ORACLE_HOME=$ORACLE_BASE/infra
SETPATH=.;$PATH;%ORACLE_HOME%dcmbin;%ORACLE_HOME%j2eehome;%ORACLE_HOME%ldapbin
;%ORACLE_HOME%ldapodiadmin;%ORACLE_HOME%ocabin;%ORACLE_HOME%opmnbin;%ORACLE_HOME%
portaladminplsqlsso;%ORACLE_HOME%ssolib;%ORACLE_HOME%uddilib;%ORACLE_HOME%upgrade
;%ORACLE_HOME%wirelessbin
export ORACLE_SID=iasdb
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
#export DISPLAY=tor:2.0
#********************************************
# Execute the DCM commands to bounce the OHS
#*********************************************
$ORACLE_HOME/dcm/bin/dcmctl stop -ct ohs
$ORACLE_HOME/dcm/bin/dcmctl start -ct ohs
$ORACLE_HOME/dcm/bin/dcmctl start -co OC4J_Portal

As you can see, these shell scripts with embedded Application Server 10g commands are extremely useful for automatic administration. As each component is discussed in later chapters, detailed scripts will be introduced to assist with the administration of that component.

The next few sections give examples of commands that are used to perform frequent Application Server 10g administrative functions.

This chapter is from Oracle Application Server 10g Administration Handbook, by Garmany and Burleson. (McGraw-Hill/Osborne, 2004, ISBN: 0072229586). Check it out at your favorite bookstore today. Buy this book now.



 
 
>>> More Oracle Articles          >>> More By McGraw-Hill/Osborne
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

ORACLE ARTICLES

- Oracle Java Security Woes Continue
- Oracle's New IaaS Cloud Option: There's a Ca...
- Oracle Acquires Eloqua to Boost Cloud Presen...
- Choosing Innovation: Oracle Survey Insights
- Oracle Fixes Privilege Escalation Bug
- Oracle`s Communications Service Availability...
- Oracle Releases Exalytics, Taleo Plans
- Oracle Releases Communications Network Integ...
- Oracle Releases Communications Data Model 11...
- Oracle Releases PeopleSoft PeopleTools 8.52
- Oracle Integrates Cloudera Apache Distro, My...
- Oracle Releases MySQL 5.5.18
- Oracle Announces NoSQL Database Availability
- Sorting Database Columns With the SELECT Sta...
- Retrieving Table Data with the LIKE Operator

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: