Wednesday, April 8, 2009

restore and recover a database to another host with RMAN Backup

1) RMAN> backup database; (source db)

2)Transfer this two backup pieces to target machine from source.

3)Determine the DBID of source machine.

SQL> select dbid from v$database;
( DBA (DBID=1130256874) ERA_h (three Schema database backup) (Personal))

4) Now perform task on target machine
$export ORACLE_SID=dba

Then connect to rman,

$ rman target /

5)Set DBID and restore spfile to pfile.

RMAN> set dbid 3386862614
RMAN> startup nomount
RMAN> restore spfile to pfile '/oracle/app/oracle/product/10.2.0/db_1/dbs/initdbase1.ora' from '/oradata2/o1_mf_s_654016132_421c64vl_.bkp';

6)start the instance with pfile.
RMAN> STARTUP FORCE NOMOUNT PFILE='/oracle/app/oracle/product/10.2.0/db_1/dbs/initdbase1.ora';

7)Restore controlfile and mount the database.RMAN> RESTORE CONTROLFILE FROM '/oradata2/o1_mf_s_654016132_421c64vl_.bkp';
RMAN> ALTER DATABASE MOUNT;

8)From SQL*Plus determine the data file and redo log file name.
SQL> COLUMN NAME FORMAT a70SQL> SELECT FILE# AS "File/Grp#", NAME FROM V$DATAFILE
UNION
SELECT GROUP#,MEMBER FROM V$LOGFILE ;

9)Catalog your backuppiece.

RMAN> catalog backuppiece '/oradata2/o1_mf_nnndf_TAG20080506T150716_421c355f_.bkp';

RMAN> list backup;

10)Make a script by issuing SET NEWNAME if you want different file name other than source.
In the script issue SET UNTIL clause and restore and recover database.

RMAN> @/export/home/oracle/rman

RMAN> run{
2> set newname for datafile 1 to '/oradata2/DBA/system01.dbf';
3> set newname for datafile 2 to '/oradata2/DBA/undotbs01.dbf';
4> set newname for datafile 3 to '/oradata2/DBA/sysaux01.dbf';
5> set newname for datafile 4 to '/oradata2/DBA/users01.dbf';
6> set newname for datafile 5 to '/oradata2/DBA/tbs201.dbf';
7> set newname for datafile 6 to '/oradata2/DBA/after_01.dbf';
8> set newname for datafile 7 to '/oradata2/DBA/after_02.dbf';
9> set newname for datafile 8 to '/oradata2/DBA/after_03.dbf';
10> set newname for datafile 1 to '/oradata2/DBA/system01.dbf';
11>
12> SET UNTIL SCN 745212;
13> RESTORE DATABASE;
14> SWITCH DATAFILE ALL;
15> RECOVER DATABASE;
16> }


11)Open the Database resetlogs option.
RMAN> alter database open resetlogs;

frm-41211 integration error: ssl failure running another product

You receive the above error when using RUN_PRODUCT or RUN_REPORT_OBJECT in forms:

This can occur for a number of reasons. Below are a number of Causes and Solutions
Cause no 1)
==========================

Cause of this error may be......

"Report Server" property of "Reports" object is not set.

you can try to solve this problem by following guideline.......

The "Report Server" property of the "Reports" object should be set. This could be either set in "Report Server" property of the "Reports" object during design time (in Forms Builder),

or

could be programaticaly set using SET_REPORT_OBJECT_PROPERTY built-in similar to following :

set_report_object_property(l_repid, REPORT_SERVER, 'name_of_reports_server');

where l_repid stands for the id of Reports Object


Cause no 2) - Multiple Calls of RUN_PRODUCT/RUN_REPORT_OBJECT:
===============================================================

If you run multiple Reports from Forms e.g. in a loop with
Run_report_object or Run_product and the Communicaton Mode is
Asynchronous you will get Error FRM-41211 INTEGRATION
ERROR: SSL FAILURE RUNNING ANOTHER PRODUCT.

Solution:
========================
1) Use SYNCHRONOUS instead of ASYNCHRONOUS when running multiple
reports. This way the next report will not run until the first
completes.

2) Use ON-ERROR trigger on forms-level as follows:

DECLARE
lv_errcode number := error_code;
lv_errtype varchar2(3) := error_type;
lv_errtxt varchar2(80) := error_text;
BEGIN
IF (lv_errcode = 41211) THEN null;
ELSE
message(lv_errtype || '-' || to_char(lv_errcode) || ': ' ||
lv_errtxt);
raise form_trigger_Failure;
END IF;
END;
This will allow you to bypass the FRM-41211 error if you
are receiving it in error.

3) Introduce a small delay between the two calls. For instance,
executing either the PAUSE command or create a TIMER between
the successive RUN_PRODUCT/RUN_REPORT_OBJECT commands.
Cause no 3 - Environment problems:
=============================================


The same report may be able to run successfully on another machine.
The form may compile and run successfully, it is only when issuing
the call to RUN_PRODUCT or RUN_REPORT_OBJECT that the above error occurs.

Solution:
========================

Verify that the REPORTS60_PATH is set correctly.
The REPORTS60_PATH should point to a directory which contains
the executable files (for example,.rdf or .rep files) that are
used by Oracle Forms to run the report. Also make sure that the environment
variable is spelled properly (REPORTS60_PATH and not REPORT60_PATH).
This is the environment variable that is used by the system to find your
reports executables.

Cause no 4 - Memory Problems:  
========================================


Integration errors are most commonly caused by memory resource problems.
This type of error can also occur if you do not have enough REAL ( CONVENTIONAL )
memory necessary to launch Reports or Graphics.
A general recommendation is 8 MB of Memory for one runtime component
and 3 MB for each additional Runtime you want to run concurrently.
16 MB of memory are recommended for one Designer Component and
an additional 4MB for each Designer you want to run concurrently.



Cause no 5) Incompatible Report/Graphics Version:
======================================================
Make sure that you have properly installed the Oracle Graphics,
Oracle Reports and Oracle Book version that is compatible
with the Oracle Forms version that you are running.


Cause no 6) LAN Installation of Developer:
======================================================

You are using a Windows platform using a LAN install
(the Oracle products are installed on a network drive).
When you issue the RUN_PRODUCT built-in to call Oracle Reports
from Oracle Forms, the following error occurs:
FRM-41211: Integration error -- SSL failure running another product
Running the report stand-alone can result in the following
error: REP-118 : Unable to create a temporary file.

NOTE: LAN INSTALLATION IS NO LONGER SUPPORTED WITH ORACLE DEVELOPER.


7) Last Cause may be .....

May be this problem is for the REPORT DEVELOPER or RUNTIME not installed in your machine or might be one that is installed is of older version... there is a conflict between forms developer and reports run-time . be sure that your form is not corrupted and reinstall reports.

Last solution..... you can reinstall of the reports
( i solved my problem by this way)


1. close all applications that are runnig
[especially antivirus progs]

2. remove in the registry the reports path key

3. install reports

4. set your reports path in the register.

5. reboot computer
6. close all applications that would be start when windows start

7.run form and call a report

TNS-12542: address already in use.

TNS-12542: address already in use.
Cause
Problem is caused due to the fact that the free ports in the windows client has been exhausted and it is trying to make use of a port which is in TIME_WAIT state which gives the error tns-12542: address already in use.

FixThere are 2 solutions available:

1.) increase the free port range:

======================

Start Registry Editor (Regedt32.exe).Locate the following key in the registry:HKEY_LOCAL_MACHinE\SYSTEM\CurrentControlSet\Services\Tcpip\ParametersOn the Edit menu, click Add Value, and then add the following registry value:

Value Name: MaxuserPort Data Type: REG_DWORD
Value: 65534 Valid Range: 5000-65534 (decimal)
Default: 0x1388 (5000 decimal)

Description: This parameter controls the maximum port number used when an application requests any available user port from the system. Normally, ephemeral (that is, short-lived) ports are allocated between the values of 1024 and 5000 inclusive.

2.) Decrease the value for TIME_WAIT state:

================================

TcpTimedWaitDelay (new in Windows NT versions 3.51 SP5 and later)

Key: Tcpip\Parameters Value Type: REG_DWORD - Time in seconds

Valid Range: 30-300 (decimal)Default: 0xF0 (240 decimal)

Description: This parameter determines the length of time that a connection will stay in the TIME_WAIT state when being closed. While a connection is in the TIME_WAIT state, the socket pair cannot be re- used. This is also known as the "2MSL" state, as by RFC the value should be twice the maximum segment lifetime on the network. See RFC793 for further details.

Thursday, March 5, 2009

show alert log contents with external table

show alert log contents with external table

1. Run the procedure with system user or (any privilige user)


DECLARE
BDumpDir VARCHAR2(200);
SID VARCHAR2(16);
ObjectExists EXCEPTION;
PRAGMA EXCEPTION_INIT(ObjectExists,-955);
BEGIN
------ get the bdump dir
SELECT value
INTO BDumpDir
FROM v$parameter
WHERE name='background_dump_dest';

----- create the directory for the bdump dir
EXECUTE IMMEDIATE 'CREATE OR REPLACE DIRECTORY bdump_dir AS '''||
BDumpDir||'''';
----- grant the necessary privileges
EXECUTE IMMEDIATE 'GRANT READ ON DIRECTORY bdump_dir TO system';
------ get the SID
SELECT instance_name INTO SID FROM v$instance;
----- create the external table
EXECUTE IMMEDIATE 'CREATE TABLE system.ALERT_LOG_EXTERNAL
(TEXT VARCHAR2(255)
) ORGANIZATION EXTERNAL
(TYPE ORACLE_LOADER
DEFAULT DIRECTORY BDUMP_DIR
ACCESS PARAMETERS
(records delimited by newline
nobadfile
nologfile
)
LOCATION (''alert_'||SID||'.log'')
)
REJECT LIMIT UNLIMITED'
;
------ ignore ORA-955 errors (object already exists)
EXCEPTION WHEN ObjectExists THEN NULL;
END;
/


2. Now we can query the external table to read the alert log contents.


a. show from last but in ascending order (this is nice and real)
----------------------------------------------------------------

select text from(
select rownum s,text from (
SELECT rownum,text FROM system.alert_log_external
order by rownum desc
)
where rownum<200
)
order by s desc


b. show from last
-------------------

select rownum,text from (
SELECT * FROM system.alert_log_external
order by rownum desc
)


c. show with like condition
---------------------------

select rownum,text from (
SELECT * FROM system.alert_log_external
order by rownum desc
)
where upper(text) like upper('%ERROR%')

---------------end--------

Trace the object's/ query's execution Path

For sql / procedure / function trace (more effective way to tuning the execution path)

1. for seeing the trace file path , execute the following query

SELECT s.sid, s.serial#, pa.value '\' LOWER(SYS_CONTEXT('userenv','instance_name')) '_ora_' p.spid '.trc' AS trace_fileFROM v$session s, v$process p, v$parameter paWHERE pa.name = 'user_dump_dest'AND s.paddr = p.addrAND s.audsid = SYS_CONTEXT('USERENV', 'SESSIONID');

2. for trace file identifier(optional)

alter session set tracefile_identifier = 'LONG_RUNNING_QUERY';

3. for anable the session lebel trace file generate

ALTER SESSION SET EVENTS '10046 trace name context forever, level 8';

4. execute your tuning able objects or query

5.execute the following command for better readable format

$ tkprof trc_file_name Output_file_name.txt

example:-
$ tkprof F:\ORACLE\product\10.2.0 \admin\DBA\udump\dba_ora_3920.trc c:\transte.txt

6. Turn off the Trace

ALTER SESSION SET EVENTS '10046 trace name context off';

----------end-------------------------------------