July 23, 2008

Linux "find" command examples.

I use to use the following linux command serveral times for searching old files and delete it, like old backup files.

$ find . -mtime +7 -exec rm -f {} \;

The following url document enlighten me the FULL usage and understanding each options usage in detail.

http://www.radialsoftware.co.uk/index.php?option=com_content&view=article&id=12&catid=10&Itemid=14

.

July 21, 2008

OEM Agent failed after the server crashed.

Production box - 9.2.0.6 database
Suse Linux 9

Agent not started up. $ORACLE_HOME/sysman/log/emagent.trc files error shows " ORA-12541: TNS:no listener" error.

The Listener port for the prod database is 1531, the above error shows that the port is configured in targets.xml is 1521.

=> Edit $ORACLE_HOME/sysman/emd/targets.xml

-> changed port value, save and exit.

=> Stop and start the agent. Failed again with Timezone error.

---------
2008-07-21 09:54:02 Thread-1098714528 ERROR pingManager: OMS does not understand the timezone region of the agent. Either start the OMS using the extended list of time zones supported by the database or pick a value of time zone from /oracle/oem_agent/agent10g/sysman/admin/nsupportedtzs.lst , update the property 'agentTZRegion' in the file /oracle/oem_agent/agent10g/sysman/config/emd.properties and restart the agent.A value which is around an offset of -04:00 from GMT should be picked.
---------

Solution
===========
1. edit the file - Agent $ORACLE_HOME/sysman/config/emd.properties
from
agentTZRegion=-04:00
to
agentTZRegion= Etc/GMT+4

oracle@nsororacle:config>env agentTZRegion emd.properties
#agentTZRegion=US/Eastern
agentTZRegion=Etc/GMT+4
oracle@nsororacle:config>

2. on the command line set -
export TZ=Etc/GMT+4

oracle@nsororacle:/oracle/oem_agent/agent10g/sysman/emd> env | grep TZ
TZ=Etc/GMT+4

NB: Steps 1 and 2 are only required to set the correct timezone

3. Log in to the repository database as SYSMAN and run (again) -
SQL> select timezone_region from mgmt_targets where target_name like '%nsororacle%';

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

4. If all three match (i.e. Etc/GMT+4) - then go to the next step

NB: Step 3 sets the timezone in the repository database - if you have done this ignore steps 1-4

5. Clean out "pending" the files in -
$AGENT ORACLE_HOME/sysman/emd

eg.
rm -r $ORACLE_HOME/sysman/emd/state/*
rm -r $ORACLE_HOME/sysman/emd/collection/*
rm -r $ORACLE_HOME/sysman/emd/upload/*
rm $ORACLE_HOME/sysman/emd/lastupld.xml
rm $ORACLE_HOME/sysman/emd/agntstmp.txt

oracle@nsororacle: emd> ls
agntstmp.txt collection lastupld.xml protocol.ini recv state targets.xml upload

oracle@nsororacle: state> rm -f *
oracle@nsororacle: state> cd ../collection
oracle@nsororacle: collection> rm -f *
oracle@nsororacle: collection> cd ../upload
oracle@nsororacle: upload> rm -f *
oracle@nsororacle: emd> rm -f lastupld.xml agntstmp.txt

6. Start the agent
$AGENT_HOME/bin/emctl start agent

oracle@nsororacle:/oracle/oem_agent/agent10g/sysman/emd> 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.

7. Issue an agent clearstate from the agent home
$AGENT_HOME/bin/emctl clearstate agent

oracle@nsororacle:/oracle/oem_agent/agent10g/sysman/emd>emctl clearstate agent Oracle Enterprise Manager 10g Release 10.2.0.1.0.
Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.
EMD clearstate completed successfully

8. Force an upload to the OMS
$AGENT_HOME/bin/emctl upload agent

oracle@nsororacle:/oracle/oem_agent/agent10g/sysman/emd> emctl upload agent
Oracle Enterprise Manager 10g Release 10.2.0.1.0.
Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.
---------------------------------------------------------------
EMD upload completed successfully.

The agent should stop crashing now.

oracle@nsororacle:/oracle/oem_agent/agent10g/sysman/emd> emctl status agent
Oracle Enterprise Manager 10g Release 10.2.0.1.0.
Copyright (c) 1996, 2005 Oracle Corporation. All rights reserved.
---------------------------------------------------------------
Agent Version : 10.2.0.1.0
OMS Version : 10.2.0.1.0
Protocol Version : 10.2.0.0.0
Agent Home : /oracle/oem_agent/agent10g
Agent binaries : /oracle/oem_agent/agent10g
Agent Process ID : 24811
Parent Process ID : 24796
Agent URL : https://nsororacle.corp.nsoro.com:3872/emd/main/
Repository URL : https://nsororacle2.corp.nsoro.com:1159/em/upload
Started at : 2008-07-21 12:28:55
Started by user : oracle
Last Reload : 2008-07-21 12:28:55
Last successful upload : 2008-07-21 12:30:44
Total Megabytes of XML files uploaded so far : 6.10
Number of XML files pending upload : 0
Size of XML files pending upload(MB) : 0.00
Available disk space on upload filesystem : 39.77%
Last successful heartbeat to OMS : 2008-07-21 12:30:03
---------------------------------------------------------------
Agent is Running and Ready
oracle@nsororacle:/oracle/oem_agent/agent10g/sysman/emd>


=============================
Reference: Note:452481.1 - Problem: Agent Stops: The Agent Starts but crashes shortly afterwards - timezone change
=============================

July 10, 2008

Concurrent Request Details Query for Printing issue

Run the Following Query from SQL as apps user. You have to provide the Concurrent request ID as input.

set long 5000
set pagesize 5000
SELECT r.request_id, a.application_name,
t.user_concurrent_program_name, p.concurrent_program_name,
p.execution_method_code, p.execution_options,
p.output_file_type, p.save_output_flag, p.print_flag,
p.output_print_style, p.required_style, p.printer_name,
TO_CHAR(r.actual_completion_date, 'DD-MON-RR HH24:MI:SS'),
r.logfile_node_name, r.logfile_name, r.outfile_name,
r.nls_language, r.nls_territory, r.nls_codeset,
r.is_sub_request, r.phase_code, r.status_code,
r.completion_text, r.output_file_type, r.number_of_copies,
r.printer, n.printer_type, r.print_style,
i.printer_style, i.printer_driver, d.srw_driver,
printer_driver_method_code, spool_flag, stdin_flag,
d.command_name, d.arguments, d.initialization
FROM apps.fnd_concurrent_programs_tl t,
apps.fnd_concurrent_programs p, apps.fnd_application_tl a,
apps.fnd_concurrent_requests r, apps.fnd_printer n,
apps.fnd_printer_information i, apps.fnd_printer_drivers d,
apps.fnd_languages l
WHERE a.application_id = t.application_id
and r.concurrent_program_id = t.concurrent_program_id
and t.concurrent_program_id = p.concurrent_program_id
and n.printer_name = r.printer
and (n.printer_type = i.printer_type)
and (i.printer_driver = d.printer_driver_name)
and d.platform_code is NULL
and i.printer_style = r.print_style
AND r.nls_language = l.nls_language
AND l.language_code = t.language
AND l.language_code = a.language
and r.request_id = &REQ_ID;


The following is the sample output,

REQUEST_ID
----------
APPLICATION_NAME
--------------------------------------------------------------------------------
USER_CONCURRENT_PROGRAM_NAME
--------------------------------------------------------------------------------
CONCURRENT_PROGRAM_NAME E
------------------------------ -
EXECUTION_OPTIONS
--------------------------------------------------------------------------------
OUTP S P OUTPUT_PRINT_STYLE R PRINTER_NAME
---- - - ------------------------------ - ------------------------------
TO_CHAR(R.ACTUAL_C LOGFILE_NODE_NAME
------------------ ------------------------------
LOGFILE_NAME
--------------------------------------------------------------------------------
OUTFILE_NAME
--------------------------------------------------------------------------------
NLS_LANGUAGE NLS_TERRITORY
------------------------------ ------------------------------
NLS_CODESET I P S
------------------------------ - - -
COMPLETION_TEXT
--------------------------------------------------------------------------------
OUTP NUMBER_OF_COPIES PRINTER
---- ---------------- ------------------------------
PRINTER_TYPE PRINT_STYLE
------------------------------ ------------------------------
PRINTER_STYLE PRINTER_DRIVER
------------------------------ ------------------------------
SRW_DRIVER
--------------------------------------------------------------------------------
PRINTER_DRIVER_METHOD_CODE S S
------------------------------ - -
COMMAND_NAME
--------------------------------------------------------------------------------
ARGUMENTS
--------------------------------------------------------------------------------
INITIALIZATION
--------------------------------------------------------------------------------
669776
Payables
Invoice Register
APXINRIR P

TEXT Y Y LANDSCAPE N
26-FEB-08 16:47:57 NSORORACLE2
$COMMON_TOP//l669776.req
$COMMON_TOP//o669776.out
AMERICAN AMERICA
US7ASCII N C C
Normal completion
TEXT 1 Ricoh2228-Houston-FrontArea
HPLJ4SI LANDSCAPE
LANDSCAPE LANDSCAPEHPLJ4SI
HPL
C N N

lpr -P$PROFILES$.PRINTER -#$PROFILES$.CONC_COPIES -T"$PROFILES$.TITLE" $PROFILES
$.FILENAME
/eE/e&l1o2a5.45C/e(s0p16.66H/e&k6.75H


SQL> spool off;

This helped me for getting initial understanding towards fixing the printing issue.

.... ...

July 4, 2008

Fix data block corruption in 7.3.4

The database is in 7.3.4 running on HP box with a size of 9GB. This is a very old database and the box too.

After expected power failure, the Instance came up. However the application cannot access as data block was corrupted for certain data blocks.


SVRMGR> analyze table oem.invoice_file validate structure cascade;
analyze table oem.invoice_file validate structure cascade
*
ORA-01578: ORACLE data block corrupted (file # 3, block # 863317)
ORA-01110: data file 3: '/u03/oradata/js/data1a.dbf'

We are not able to do export/query or any activity with this table.

The following was resolved the issue from the metalink.

"The event 10231 allows Oracle to skip certain types of corrupted blocks on full table scans ONLY hence allowing export or "create table as select" type operations to retrieve rows from the table which are not in the corrupt block. Data in the corrupt block is lost.Set this event at session level:"

SQL> ALTER SESSION SET EVENTS '10231 TRACE NAME CONTEXT FOREVER, LEVEL 10';

Now the select * from query works and created new table using "create table as select" and drop original table.

This was fixed the data block corruption.

Reference:
28814.1 "Handling Oracle Block Corruptions in Oracle7/8/8i/9i/10g".

Database Block Corruption - Deduction

RMAN's BACKUP command with the VALIDATE and CHECK LOGICAL clauses allow a Database Adminstrator to quickly check for both physical and logical corruption. If the initialization parameter DB_BLOCK_CHECKSUM=TRUE, specifying CHECK LOGICAL detects all types of corruption that are possible to detect.

The following rman commands will deduct for physical/logical database corruption for the database and logs into db_validate.log file.

$ rman target / catalog rman/@rcat
RMAN> spool log to '/home/oracle/Scripts/db_validate.log';
RMAN>allocate channel for maintenance device type disk;
RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 4;

RMAN> run {
1 backup validate database;
2 backup check logical validate database;
}

To monitor this process, issue the following sql statement from SQLPLUS.

SQL> select sid, serial#, context, sofar, totalwork, round(sofar/totalwork*100,2) "%_complete"
from v$session_longops where opname like 'RMAN%' and opname not like '%aggregate%'
and totalwork != 0 and sofar <> totalwork
/

After this process completed, look for "block corruption" string in alert.log file, also query the v$database_block_corruption dynamic view, which will retrun records if there is a corruption in the database.

Reference:
Note:283053.1 - How To Use RMAN To Check For Logical & Physical Database Corruption

July 1, 2008

Transfer Concurrent Program Definitions - FNDLOAD

1) Log into the UNIX box
2) Go to $FND_TOP/patch/115/import/
3) Verify that the control file (lct) is in this directory – in the case of the concurrent program load it is afcpprog.lct
NOTE: Obviously you can do the execution from a different directory, e.g. there is US directory under the import directory, but I chose to keep it simple and do it under the import directory
4) Type FNDLOAD apps/simple4u@dfrwei 0 Y DOWNLOAD afcpprog.lct prog.ldt PROGRAM APPLICATION_SHORT_NAME=XBOL
5) FTP the ldt file to the server it is to be uploaded to
6) Upload the file in this order:
FNDLOAD apps/simple4u@tfrwei 0 Y UPLOAD_PARTIAL afcpprog.lct prog.ldt EXECUTABLE APPLICATION_SHORT_NAME=XBOL LANGUAGE=US

FNDLOAD apps/simple4u@tfrwei 0 Y UPLOAD_PARTIAL afcpprog.lct prog.ldt VALUE_SET APPLICATION_SHORT_NAME=XBOL LANGUAGE=US

FNDLOAD apps/simple4u@tfrwei 0 Y UPLOAD_PARTIAL afcpprog.lct prog.ldt VSET_TABLE APPLICATION_SHORT_NAME=XBOL LANGUAGE=US

FNDLOAD apps/simple4u@tfrwei 0 Y UPLOAD_PARTIAL afcpprog.lct prog.ldt DESC_FLEX APPLICATION_SHORT_NAME=XBOL LANGUAGE=US

FNDLOAD apps/simple4u@tfrwei 0 Y UPLOAD_PARTIAL afcpprog.lct prog.ldt PROGRAM APPLICATION_SHORT_NAME=XBOL LANGUAGE=US
7) That’s it – verify that the load worked by reviewing the log file and the application
NOTE: It would only allow me to upload once per session; if I log into UNIX with the terminal emulator and run upload it will not allow me to run upload again… I have to log out of UNIX and log back in. I’m sure this is a setting at the UNIX or terminal emulator that I was missing.
FNDLOAD apps/pwd 0 Y mode configfile datafile entity [ param ... ]

Parameter
Use

The APPS schema and password in the form username/password[@connect_string]. If connect_string is omitted, it is taken in a platform–specific manner from the environment using the name TWO_TASK.
<>
Concurrent program flags
Mode
UPLOAD or DOWNLOAD. UPLOAD causes the datafile to be uploaded to the database. DOWNLOAD causes the loader to fetch rows and write them to the datafile.

The configuration file to use (usually with a suffix of .lct, but not enforced or supplied by the loader).

The data file to write (usually with a suffix of .ldt, but not enforced or supplied by the loader). If the data file already exists, it will be overwritten.

The entity(ies) to upload or download. When uploading, you should always upload all entities, so specify a ”–” to upload all entities.
< [param] >
Zero or more additional parameters are used to provide bind values in the access SQL (both UPLOAD and DOWNLOAD). Each parameter is in the form NAME=VALUE. NAME should not conflict with an attribute name for the entities being loaded.



Concurrent Program Configuration File
The concurrent program configuration file afcpprog.lct downloads and uploads concurrent program definitions. It takes as parameters program name and application name. The following table lists the entities, sub–entities (if any), and download parameters for this configuration file.

Entity
Sub–entities, if any
Download Parameters
PROGRAM
INCOMPATIBILITY
CONCURRENT_PROGRAM_NAME, APPLICATION_SHORT_NAME
EXECUTABLE

EXECUTABLE_NAME




cd $FND_TOP/patch/115/import

cp credit.ldt /interface/inffrwei/TFRWEI/incoming/

cp /interface/inffrwei/TFRWEI/incoming/credit.ldt credit.ldt


FNDLOAD apps/simple4u@dfrwei 0 Y DOWNLOAD afcpprog.lct credit.ldt PROGRAM CONCURRENT_PROGRAM_NAME=FRWECRDSUM


FNDLOAD apps/simple4u@tfrwei 0 Y UPLOAD_PARTIAL afcpprog.lct credit.ldt EXECUTABLE CONCURRENT_PROGRAM_NAME=FRWECRDSUM LANGUAGE=US

cd $FND_TOP/patch/115/import

FNDLOAD apps/simple4u@tfrwei 0 Y UPLOAD_PARTIAL afcpprog.lct credit.ldt VALUE_SET CONCURRENT_PROGRAM_NAME=FRWECRDSUM LANGUAGE=US

exit

cd $FND_TOP/patch/115/import

FNDLOAD apps/simple4u@tfrwei 0 Y UPLOAD_PARTIAL afcpprog.lct credit.ldt VSET_TABLE CONCURRENT_PROGRAM_NAME=FRWECRDSUM LANGUAGE=US

exit

cd $FND_TOP/patch/115/import

FNDLOAD apps/simple4u@tfrwei 0 Y UPLOAD_PARTIAL afcpprog.lct credit.ldt DESC_FLEX CONCURRENT_PROGRAM_NAME=FRWECRDSUM LANGUAGE=US

exit

cd $FND_TOP/patch/115/import

FNDLOAD apps/simple4u@tfrwei 0 Y UPLOAD_PARTIAL afcpprog.lct credit.ldt PROGRAM CONCURRENT_PROGRAM_NAME=FRWECRDSUM LANGUAGE=US

exit