Saturday, April 16, 2011

Output Post Processor

Concurrent processing uses the Output Post Processor (OPP) to enforce post-processing
actions for concurrent requests.

Post-processing actions are actions taken on concurrent
request output. An example of a post-processing action is that used in publishing
concurrent requests with XML Publisher.

For example, say a request is submitted with
an XML Publisher template specified as a layout for the concurrent request output.
After the concurrent manager finishes running the concurrent program, it will contact
the OPP to apply the XML Publisher template and create the final output.


A concurrent manager contacts an available OPP process when a running concurrent
request needs an OPP processing action. A concurrent manager uses a local OPP
process (that, is, on the same node) by default, but will choose a remote OPP if no local
OPP process is available.

There should always be at least one OPP process active in the system. If no OPP service
is available, completed requests that require OPP processing will complete with a status
of Warning.


An OPP service is multi-threaded and will start a new thread for each concurrent
request it processes. You can control the number of simultaneous threads for an OPP
service instance by adjusting the Threads per Process parameter for the instance.

If all the OPP services have reached their respective maximum number of threads, the
requests waiting to be processed remain in a queue to be processed as soon as threads
become available.

If request throughput has become slow, you may want to increase the
number of threads per process for the OPP. It is recommended that you keep the
number of threads per process between 1 and 20.

Monitoring a Grid Control Installation

agentTZRegion

Question: I installed agent on one of my server but when I start it I get the following error messages:
replica6-replica:</u01/oracle/product/agent/agent10g/bin> $emctl start agent
Oracle Enterprise Manager 10g Release 10.2.0.1.0.
Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.
Starting agent ...... failed.
The agentTZRegion value in /u01/oracle/product/agent/agent10g/sysman/config/emd.properties is not in agreement with what agent thinks it should be.Please verify your environment to
make sure that TZ setting has not changed since the last start of the agent.
If you modified the timezone setting in the environment, please stop the agent and
exectute 'emctl resetTZ agent' and also execute the script
mgmt_target.set_agent_tzrgn(<agent_name>, <new_tz_rgn>) to get the value
propagated to repository.
Consult the log files in: /u01/oracle/product/agent/agent10g/sysman/log

And when I try to reset the time zone, I get the following error message:
replica6-replica:</u01/oracle/product/agent/agent10g/bin> $emctl resetTZ agent
Oracle Enterprise Manager 10g Release 10.2.0.1.0.
Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.
Updating /u01/oracle/product/agent/agent10g/sysman/config/emd.properties...
----- Tue May 8 11:33:29 2007::tzOffset for US/East-Indiana is -300(min), but agent is runnning with tzOffset -240(min)
----- Tue May 8 11:33:29 2007::trying again after waiting for 1 sec to account for daylight transition
----- Tue May 8 11:33:29 2007::tzOffset for US/East-Indiana is -300(min), but agent is runnning with tzOffset -240(min)
-----
resetTZ failed.
The agentTZRegion in:
/u01/oracle/product/agent/agent10g/sysman/config/emd.properties
is not in agreement with what the agent thinks it should be.
Fix your environment.
Pick a TZ value that corresponds to time zone settings listed
in: /u01/oracle/product/agent/agent10g/sysman/admin/supportedtzs.lst

Please help.



Answer:Your agent is not running with the correct time zone or it is not matching what you have in OMS repository.

Please do the following:
Go to the OMS repository and login as sysman and query the following SQL statement.
SQL> SELECT target_name FROM mgmt_targets;
Find exact sever name and then query the following SQL statement.
SQL> SELECT timezone_region FROM mgmt_targets
SQL> WHERE target_name like '<your server-name>';

TIMEZONE_REGION
----------------------------------------------------------------
Etc/GMT+4


No, you should manually change the time zone in the emd.properties file in the sysman/config directory. To do that following the following steps:

1. Stop the agent
# cd $AGENT_HOME
# cd bin
# emctl stop agent

2. Open the File emd.properties, put the agentTZRegion=Etc/GMT+4 and save the file. 
List of Oracle Time Zone# cd $AGENT_HOME
# cd sysman/config
# vi emd.properties -- add or change the time zone that you found
from the OMS repository.
All the timezone are in the following place.
# cd sysman/admin
nsupportedtzs.lst
supportedtzs.lst
tzmappings.lst

3 . Now try to start the agent.
# cd $AGENT_HOME
# cd bin
# emctl start agent

-------------- OR --------------------

1. Stop the agent
# cd $AGENT_HOME
# cd bin
# emctl stop agent

2. Open the File emd.properties, make a note of agentTZRegion.

3. The go to the OMS repository and change the timezone to what you have in the emd.properties file.
# sqlplus /nolog
# SQL> connect sysman/<your password>
# SQL> exec mgmt_target.set_agent_tzrgn
# SQL> ('machine name :port number ','timezone that you found in emd.properties');
If you don’t know the port number, you should find it in the emd.properties file.

4 . Now try to start the agent.
# cd $AGENT_HOME
# cd bin
# emctl start agent
If you still getting the same error message:

Do the following:
Set the TZ to your-em-time-zone
Ex: # TZ=GMT; export TZ

Go to agent home/bin
Ex: cd $AGENT_HOME/bin

Reset time zone:
Ex: # emctl resetTZ agent
Oracle Enterprise Manager 10g Release 10.2.0.1.0. 
Copyright (c) 1996, 2005 Oracle Corporation.  All rights reserved.
Updating /u01/oracle/product/agent2/ agent10g/sysman/config/emd. properties...
Successfully updated /u01/oracle/product/agent2/ agent10g/sysman/config/emd. properties.
Login as the em repository user and run the  script:
exec mgmt_target.set_agent_tzrgn(' yourservername:3872','GMT')
This can be done for example by logging into sqlplus and doing
SQL> exec mgmt_target.set_agent_tzrgn(' yourservername:3872','GMT')
oradb1t-serv62: /u01/oracle/product/agent2/ agent10g/bin $emctl start agent
Oracle Enterprise Manager 10g Release 10.2.0.1.0. 
Copyright (c) 1996, 2005 Oracle Corporation.  All rights reserved.
Starting agent ............. started.

Then go to emd.properties to make sure the agentTZRegion parameter was changed.
Ex: # more $AGENT_HOME/sysman/config/ emd.properties
You should see:  agentTZRegion=GMT

Go to sqlplus and login as sysman in em repository and executed the above procedure.
Ex: # sqlplus /nolog
        # SQL> connect  sysman/password
        # SQL> exec mgmt_target.set_agent_tzrgn(' yourservername:3872','GMT');

Upload agent to OEM.
Ex: # emctl clearstate agent
       # emctl upload agent

Purging ADR log and trace files automatically

The following script was put by David Sutton, and shows a way to create a script to tidy up the logs and trace files generated in 11G. Note that the purge time is in seconds and this keep s 30 days online. This is probably too many on some of our systems and this is likely to be reduced to 14 days although we will keep incident history for longer
This is called each day from cron (or it could be run from dbms_scheduler, either directly or via an OEM job)
#!/usr/bin/ksh
#
#
#
# Description
# Shell script to interact with the ADR through ADRCI and purge ADR contents
#
# Tunables
###
LOCKFILE=/tmp/mor_adrci_purge_.lck
###
######
# Start Of Functions
#
# tidyup – common fuction called if error has occured
tidyup () {
        rm -f ${LOCKFILE}
        echo “ERROR: Purge aborted at `date` with exit code ${ERR}”
        exit ${ERR}
}
######
# End Of Functions
### Main Program
# Check user is oracle
USERID=`/usr/bin/id -u -nr`
if [ $? -ne 0 ]
then
        echo “ERROR: unable to determine uid”
        exit 99
fi
if [ "${USERID}" != "oracle" ]
then
        echo “ERROR: This script must be run as oracle”
        exit 98
fi
echo “INFO: Purge started at `date`”
# Check if lockfile exists
if [ -f ${LOCKFILE} ]
then
        echo “ERROR: Lock file already exists”
        echo “       Purge already active or incorrectly terminated”
        echo “       If you are sure tidy isn’t active, please remove “
        echo “       ${LOCKFILE}”
        exit 97
fi
# Create lock file
touch ${LOCKFILE} 2>/dev/null
if [ $? -ne 0 ]
then
        echo “ERROR: Unable to create lock file”
        exit 96
fi
# Purge ADR contents
echo “INFO: adrci purge started at `date`”
/app/oracle/product/11.1.0/db_1/bin/adrci exec=”show homes”|grep -v : | while read file_line
do
  echo “INFO: adrci purging diagnostic destination ” $file_line
  echo “INFO: purging ALERT older than 90 days ….”
  /app/oracle/product/11.1.0/db_1/bin/adrci exec=”set homepath $file_line;purge -age 129600 -type ALERT”
  echo “INFO: purging INCIDENT older than 30 days ….”
  /app/oracle/product/11.1.0/db_1/bin/adrci exec=”set homepath $file_line;purge -age 43200 -type INCIDENT”
  echo “INFO: purging TRACE older than 30 days ….”
  /app/oracle/product/11.1.0/db_1/bin/adrci exec=”set homepath $file_line;purge -age 43200 -type TRACE”
  echo “INFO: purging CDUMP older than 30 days ….”
  /app/oracle/product/11.1.0/db_1/bin/adrci exec=”set homepath $file_line;purge -age 43200 -type CDUMP”
  echo “INFO: purging HM older than 30 days ….”
  /app/oracle/product/11.1.0/db_1/bin/adrci exec=”set homepath $file_line;purge -age 43200 -type HM”
  echo “”
  echo “”
done
echo
echo “INFO: adrci purge finished at `date`”
# All completed
rm -f ${LOCKFILE}
echo “SUCC: Purge completed successfully at `date`”
exit 0

Purging Oracle Database's Alert Log with ADRCI Utility

Oracle Database's ADR purge command is superior for purging alert log entries. Just be forewarned on how to actually use it since the desired or perceived outcome is not always apparent.
Alert Log Scraping with Oracle’s ADRCI Utility looks at extracting Oracle alert errors from the alert log and Rotating Oracle’s Alert Log with ADRCI discussed taking those extracted errors and making backup copies of them by day in separate directories. However, we still have a bunch of alert log information lying around, either in the log.xml file or in separate files under the diag directory structure. Towards the end of the second article there was mention of purging the old data from the alert log with a “PURGE –AGE” command that took the form of:

PURGE –AGE 7200 –TYPE ALERT;

While the syntax is correct the desired or perceived outcome is not always apparent. For this reason, let’s examine a simple example, looking what the alert log (log.xml) contains, issuing the purge command, and then looking again at the alert log.

1.  First, we can access the ADRCI utility, set our homepath.

[root@ludwig ~]# adrci
ADRCI: Release 11.1.0.6.0 - Beta on Thu Apr 8 17:32:07 2010
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
ADR base = "/opt/app/oracle"
 
adrci> show homes
ADR Homes: 
diag/rdbms/db11/db11
diag/tnslsnr/ludwig/listener
 
adrci> set homepath diag/rdbms/db11/db11
2.  Now look at the alert log at the top and bottom to get an idea of what dates are contained within it.
adrci> show alert
2010-03-28 22:08:27.498000 -06:00
Thread 1 advanced to log sequence 105
  Current log# 3 seq# 105 mem# 0: /opt/app/oracle/oradata/db11/redo03.log
2010-03-29 02:00:00.112000 -06:00
Clearing Resource Manager plan via parameter
 
adrci> show alert –tail
2010-04-08 17:31:50.373000 -06:00
Successfully onlined Undo Tablespace 2.
Verifying file header compatibility for 11g tablespace encryption...
Verifying 11g file header compatibility for tablespace encryption completed
SMON: enabling tx recovery
Database Characterset is WE8MSWIN1252
2010-04-08 17:31:51.758000 -06:00
Opening with internal Resource Manager plan
Starting background process FBDA

3.  Issue the purge command to attempt to remove data from the alert log. As the manuals state, purging is done for diagnostic data that is older than the amount of time (minutes) given in the purge command. So let’s attempt purging for diagnostic data that is over 1 day old (1440 minutes).
adrci> PURGE -age 1440 -type ALERT

4.  Now all we need to do is look again at the alert log to see if there are any changes.
adrci> show alert
2010-03-28 22:08:27.498000 -06:00
Thread 1 advanced to log sequence 105
  Current log# 3 seq# 105 mem# 0: /opt/app/oracle/oradata/db11/redo03.log
2010-03-29 02:00:00.112000 -06:00
Clearing Resource Manager plan via parameter
 
adrci> show alert –tail
2010-04-08 17:31:50.373000 -06:00
Successfully onlined Undo Tablespace 2.
Verifying file header compatibility for 11g tablespace encryption...
Verifying 11g file header compatibility for tablespace encryption completed
SMON: enabling tx recovery
Database Characterset is WE8MSWIN1252
2010-04-08 17:31:51.758000 -06:00
Opening with internal Resource Manager plan
Starting background process FBDA

Very quickly, from the show alert command, we can see that the purge did not do what we might have expected or wished for--that it would remove data from the alert log for us. After all, the manuals state that the purge command will purge diagnostic data in the current ADR home according to purging policies (1440 minutes). So what is really happening here is the question that needs to be answered. In a nutshell, the purge command only acts upon diagnostic data at the file level; not looking inside any file and the data it contains. Just because the alert log contains diagnostic data older than 1440 minutes, the file itself has been accessed and updated within one day so it is not purged.

Granted, if we changed our purge command to purge data that is older than one minute, clearly our alert log (log.xml) will be purged (removed). We can see this in another very simple example by looking at the files in the alert diagnostic data before and then after issuing the purge command:

1.  Look at the timestamp on the current alert log (log.xml).
[root@ludwig ~]# ls -l /opt/app/oracle/diag/rdbms/db11/db11/alert/log.xml
-rw-r----- 1 root root 2047 Apr  8 20:10 /opt/app/oracle/diag/rdbms/db11/db11/alert/log.xml

2.  Check the current timestamp.
[root@ludwig ~]# date
Thu Apr  8 20:12:00 MDT 2010

3.  Access the ADRCI utility and issue the purge command for purging anything older than one minute.
[root@ludwig ~]# adrci
ADRCI: Release 11.1.0.6.0 - Beta on Thu Apr 8 20:12:04 2010
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
ADR base = "/opt/app/oracle"
adrci> show homes
ADR Homes: 
diag/rdbms/db11/db11
diag/tnslsnr/ludwig/listener
adrci> set homepath diag/rdbms/db11/db11
 
adrci> PURGE -age 1 -type ALERT
adrci> exit

4.  Look and see if the alert log (log.xml) file still exists.
[root@ludwig ~]# ls -l /opt/app/oracle/diag/rdbms/db11/db11/alert/log.xml
ls: /opt/app/oracle/diag/rdbms/db11/db11/alert/log.xml: No such file or directory
Since there wasn’t any diagnostic data written to the alert log (log.xml) during the time of our little example, when we issue the purge command the whole alert log is removed from disk.
This may or may not be the desired result we want depending on how we rotate or want to clean alert logs from our system. Before I offer a suggestion, or you conclude there is really one additional piece of information you need to know.
Since many of us like to rotate alert logs or save alert information, it is good to know, since ADRCI works on the file level, what files are affected by the purge command. We know that the log.xml file (the default alert log file) is affected but let’s perform a little experiment to nail this down a bit.
Here we will create four additional alert log files; simulating typical naming conventions that I’ve often seen used when rotating alert log files; and see how they are affected by the purge command. Again we will list the files within the diag/alert area, check the date, issue the purge command, and then see what has happened to the files.

1.  Look at the timestamp on the current simulated alert log files created. Here you can see that I’ve created an alert<date>.log, alert<date>.xml, a log<date>.xml, and anyfilename for the file names.
[root@ludwig alert]# ls -lar
total 40
-rw-r----- 1 oracle oinstall 2047 Apr  8 21:44 log.xml
-rw-r----- 1 oracle oinstall 2047 Apr  8 21:44 log.2010-04-10.xml
-rw-r----- 1 oracle oinstall 2047 Apr  8 21:44 any.file.name
-rw-r----- 1 oracle oinstall 2047 Apr  8 21:44 alert.2010-04-10.xml
-rw-r----- 1 oracle oinstall 2047 Apr  8 21:44 alert.2010-04-10.log

2.  Check the current timestamp.
[root@ludwig ~]# date
Thu Apr  8 21:48:42 MDT 2010

3.  Access the ADRCI utility and issue the purge command for purging anything older than one minute.
[root@ludwig ~]# adrci
ADRCI: Release 11.1.0.6.0 - Beta on Thu Apr 8 20:12:04 2010
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
ADR base = "/opt/app/oracle"
adrci> show homes
ADR Homes: 
diag/rdbms/db11/db11
diag/tnslsnr/ludwig/listener
adrci> set homepath diag/rdbms/db11/db11
 
adrci> PURGE -age 1 -type ALERT
adrci> exit

4.  Take a look and see if the alert log (log.xml) file still exists.
-rw-r-----  1 oracle oinstall 2047 Apr  8 21:44 any.file.name
-rw-r-----  1 oracle oinstall 2047 Apr  8 21:44 alert.2010-04-10.xml
-rw-r-----  1 oracle oinstall 2047 Apr  8 21:44 alert.2010-04-10.log

Very plainly you can see that three of the files were not affected by the purge command. The only files that were affected had a format where they were prefixed with “log” and had a suffix of “xml”. In my simple example I specifically used “log.” and “.xml” but you can have any file name that begins with “log” and ends with “xml”. For instance all of the following filenames work with the purge command.

-rw-r----- 1 oracle oinstall 2047 Apr  8 21:56 logabcxml
-rw-r----- 1 oracle oinstall 2047 Apr  8 21:56 log.abcxml
-rw-r----- 1 oracle oinstall 2047 Apr  8 21:56 logabc.xml
-rw-r----- 1 oracle oinstall 2047 Apr  8 21:56 logxml

And, as a warning, it probably isn’t advisable to name any file or directory under the diag alert directory structure with the log/xml pattern. For instance, if you were to create a directory, call it logxml, and then ran the purge command you’d get the following error:

adrci> PURGE -age 1 -type ALERT
DIA-48119: error encountered when attempting to remove a file [/opt/app/oracle/diag/rdbms/db11/db11/alert/logxml] [0]
DIA-48190: OS unlink system call failure
Linux Error: 21: Is a directory
Additional information: 1

The purge command within the ADRCI utility is very powerful and can help aid in the rotation of alert logs. Just remember that it only works at the file level and if that file has been accessed in the number of minutes you specify in the purge command. Also remember that since it acts on the file level do not, at least at this time, create structures that match the pattern the purge command is looking for--in particular anything prefixed with log and suffixed with xml

Ex:
the below command for purging with 2 days retension

Before
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-u0190lv
                       30G   27G  1.5G  95% /u0190

adrci exec="purge -age 2880"
After:
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-u0190lv
                       30G   24G  5.1G  83% /u0190


--To Purge 7 days old incidents

purge -age 10080 -type incident


--To Purge 7 days old trace

purge -age 10080 -type trace