Total Pageviews

Thursday, 28 April 2016

Script to Move Datafiles

Move datafile script (unix or windows)




ARCHIVE LOGGING (UNIX):

set linesize 150
column file_name format a60
set pagesize 200
set head off

select file_id, file_name
from dba_data_files
where file_name like '%disk8%'
/
select 'alter database datafile '||file_id||' offline;'
from dba_data_files
where file_name like '%disk8%'
/
select '!mv '||file_name||' '||file_name
from dba_data_files
where file_name like '%disk8%'
/
select 'alter database rename file "'||file_name||"' to "'||file_name||"';'
from dba_data_files
where file_name like '%disk8%'
/
select 'recover datafile '||file_id||';'
from dba_data_files
where file_name like '%disk8%'
/
select 'alter database datafile '||file_id||' online;'
from dba_data_files
where file_name like '%disk8%'
/
select 'select status from dba_data_files;' from dual;

NO ARCHIVE LOGGING (UNIX):

set linesize 150
column file_name format a60
set pagesize 200
set head off

select 'shutdown immediate' from dual;
select file_id, file_name
from dba_data_files
where file_name like '%disk8%'
/
select '!mv '||file_name||' '||file_name
from dba_data_files
where file_name like '%disk8%'
/
select 'startup mount' from dual;
select 'alter database rename file "'||file_name||"' to "'||file_name||"';'
from dba_data_files
where file_name like '%disk8%'
/
select 'alter database open;' from dual;
select 'select status from dba_data_files;' from dual;

ARCHIVE LOGGING (WINDOWS):

set linesize 150
column file_name format a60
set pagesize 200
set head off

select file_id, file_name
from dba_data_files
where file_name like '%disk8%'
/
select 'alter database datafile '||file_id||' offline;'
from dba_data_files
where file_name like '%disk8%'
/
select 'host move '||file_name||' '||file_name
from dba_data_files
where file_name like '%disk8%'
/
select 'alter database rename file "'||file_name||"' to "'||file_name||"';'
from dba_data_files
where file_name like '%disk8%'
/
select 'recover datafile '||file_id||';'
from dba_data_files
where file_name like '%disk8%'
/
select 'alter database datafile '||file_id||' online;'
from dba_data_files
where file_name like '%disk8%'
/
select 'select status from dba_data_files;' from dual;

NO ARCHIVE LOGGING (WINDOWS):

set linesize 150
column file_name format a60
set pagesize 200
set head off

select 'shutdown immediate' from dual;
select file_id, file_name
from dba_data_files
where file_name like '%disk8%'
/
select 'host move '||file_name||' '||file_name
from dba_data_files
where file_name like '%disk8%'
/
select 'startup mount' from dual;
select 'alter database rename file "'||file_name||"' to "'||file_name||"';'
from dba_data_files
where file_name like '%disk8%'
/
select 'alter database open;' from dual;
select 'select status from dba_data_files;' from dual;


Another Script
============

select 'alter database rename file '''|| file_name ||''' to '''/u0/' || 
substr(file_name, 5) ||''';' from dba_data_files;

to:

select 'alter database rename file '''|| file_name ||''' to '||'''/u0/' || 
substr(file_name, 5) ||''';' from dba_data_files;


Another
=======
SQL>spool rename_datafile.sql
set line 140
set pagesize 2000
set heading off
select ‘alter database rename file ‘ ||””|| file_name || ”” || ‘ to ‘|| ””||
‘/oracle/IMPRD/data’ || substr(file_name, instr(file_name, ‘/’, -1)) ||”” || ‘;’
from dba_data_files
/
SQL>spool off
Spool to a file and then:
1- Shutdown immediate;
2- OS copy the files to the new location
3- Startup Mount;
4- Execute the spooled file ( SQL>@rename_datafile.sql )
5- Alter database open;

Another
=======
select 'alter database rename file '||chr(39)||name||chr(39)||' to
'||chr(39)||'F'||substr(name,2)||chr(39)||';'
from v$datafile;


Wednesday, 27 April 2016

APPS/SYSADMIN password in Oracle Apps R12

Step to Find APPS PASSWORD :

Step #1


sqlplus> sqlplus system/system_password
sqlplus / as sysdba

Step#2:  Create Function to decrypt the encrypted password

SQL> create FUNCTION apps.decrypt_pin_func(in_chr_key IN VARCHAR2,in_chr_encrypted_pin IN VARCHAR2) RETURN VARCHAR2 AS LANGUAGE JAVA NAME 'oracle.apps.fnd.security.WebSessionManagerProc.decrypt(java.lang.String,java.lang.String) return java.lang.String';
/
Function created.

Step#3: Query for password

set linesize 200 long 300

SQL> select ENCRYPTED_FOUNDATION_PASSWORD from apps.fnd_user where USER_NAME='GUEST';

ENCRYPTED_FOUNDATION_PASSWORD
--------------------------------------------------------------------------------
ZG379C5C883FF56235BE975D075A6FD2E7A749279B7BFCE331530B443E86F41A1966E3E4B1864519DB88BC07D58666AD837B

Step#4:  Get the Apps password using encrypted guest password

SQL> SELECT apps.decrypt_pin_func('GUEST/ORACLE','ZG379C5C883FF56235BE975D075A6FD2E7A749279B7BFCE331530B443E86F41A1966E3E4B1864519DB88BC07D58666AD837B') from dual;

APPS.DECRYPT_PIN_FUNC('GUEST/ORACLE','ZG379C5C883FF56235BE975D075A6FD2E7A749279B
--------------------------------------------------------------------------------
APPS123

Step#5: Test apps password

SQL> conn apps/APPS123;
Connected.

Step to Find SYSADMIN PASSWORD :

Step# 1:

SQL> conn apps/APPS123;
Connected.

Step#2:

SQL> CREATE OR REPLACE PACKAGE get_pwd AS
FUNCTION decrypt (KEY IN VARCHAR2, VALUE IN VARCHAR2)
RETURN VARCHAR2;
END get_pwd;
Package created.

Step# 3:

SQL>
 CREATE OR REPLACE PACKAGE BODY get_pwd  AS
 FUNCTION decrypt (KEY IN VARCHAR2, VALUE IN VARCHAR2)
 RETURN VARCHAR2
 AS  LANGUAGE JAVA NAME 'oracle.apps.fnd.security.WebSessionManagerProc.decrypt(java.lang.String,java.lang.String) return java.lang.String'; END get_pwd;
 /
Package body created.

Step# 4:

SQL> SELECT usr.user_name,
       get_pwd.decrypt
  2    3            ((SELECT (SELECT get_pwd.decrypt
  4                                (fnd_web_sec.get_guest_username_pwd,
  5                                 usertable.encrypted_foundation_password
  6                                )
  7                        FROM DUAL) AS apps_password
  8                FROM fnd_user usertable
  9               WHERE usertable.user_name =
 10                        (SELECT SUBSTR
 11                                    (fnd_web_sec.get_guest_username_pwd,
 12                                     1,
 13                                       INSTR
 14                                            (fnd_web_sec.get_guest_username_p
 15                                             '/'
 16                                            )
 17                                     - 1
 18                                    )
 19                           FROM DUAL)),
 20             usr.encrypted_user_password) PASSWORD
  FROM fnd_user usr
 WHERE usr.user_name = '&USER_NAME';
Enter value for user_name: SYSADMIN
old  23:  WHERE usr.user_name = '&USER_NAME'
new  23:  WHERE usr.user_name = 'SYSADMIN'


USER_NAME                                     PASSWORD
------------------------                        -----------------
SYSADMIN                                        SYSADMIN123

Step#5 :  Bellow sql will help you to validate SYSADMIN Password

SQL> select fnd_web_sec.validate_login('SYSADMIN','SYSADMIN123) from dual;

FND_WEB_SEC.VALIDATE_LOGIN('SYSADMIN','SYSADMIN123')
--------------------------------------------------------------------------------
Y


Ref:
http://dbafix.blogspot.com/2014/04/find-out-appssysadmin-password-in.html

Monday, 25 April 2016

FRM-92050 Failed to Connect to Server


In our case the below actions fixed the issue.


Please execute following actions:
a. Copy fndfmxit.so from a backup.
b. Place it in $FND_TOP/bin.
c. Instead bounce services 

adapcctl.sh: exiting with status 150



adapcctl.sh: exiting with status 150
On E-Business Suite Release 12 environment, while starting midtier services using adstrtal.sh, below error occurs:

Executing service control script:
/oracle/apps/VIS/inst/apps/<CONTEXT>/admin/scripts/adapcctl.sh start
Timeout specified in context file: 100 second(s)
Script returned:
****************************************************
You are running adapcctl.sh version 120.7.12010000.2
Starting OPMN managed Oracle HTTP Server (OHS) instance ...
adapcctl.sh: exiting with status 150
adapcctl.sh: check the logfile /oracle/apps/VIS/inst/apps/<CONTEXT>/logs/appl/admin/log/adapcctl.txt for more information ...
.end std out.
.end err out.
****************************************************
Same error for adoacorectl.sh, adoafmctl.sh, adformsctl.sh.

CAUSE:
There is a states file called .opmndat at /oracle/apps/VIS/inst/apps/<CONTEXT>/ora/10.1.3/opmn/logs/states which gets created when services are started.
Whenever services are started this file gets created or updated.
Unfortunately for some reason this file is not updated when services are started.

SOLUTION:
1. Shutdown all Middle tier services and ensure no defunct processes exist running the following from the operating system:

# ps -ef | grep <applmgr>

If one finds any, kill these processes.
2. Navigate to $INST_TOP/ora/10.1.3/opmn/logs/states directory. It contains hidden file .opmndat:

# ls -lrt .opmndat
3. Delete this file .opmndat after making a backup of it:

# rm .opmndat
4. Restart the services.

5. Re-test the issue.
- See more at: http://oracledbajourney.blogspot.com/2013/01/adapcctlsh-exiting-with-status-150.html#sthash.jGeENkex.dpuf

Ref:
http://oracledbajourney.blogspot.com/2013/01/adapcctlsh-exiting-with-status-150.html

Sunday, 24 April 2016

Scripts To monitor Oracle Database And Application Server

Check Archive log size and deletion
===========================
For last 20 days.
===========
SELECT SUM_ARCH.DAY,
         SUM_ARCH.GENERATED_GB,
         SUM_ARCH_DEL.DELETED_GB,
         SUM_ARCH.GENERATED_GB - SUM_ARCH_DEL.DELETED_GB "REMAINING_GB"
    FROM (  SELECT TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY') DAY,
                   SUM (ROUND ( (blocks * block_size) / (1024 * 1024)/1024, 2))
                      GENERATED_GB
              FROM V$ARCHIVED_LOG
             WHERE ARCHIVED = 'YES'
          GROUP BY TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY')) SUM_ARCH,
         (  SELECT TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY') DAY,
                   SUM (ROUND ( (blocks * block_size) / (1024 * 1024)/1024, 2))
                      DELETED_GB
              FROM V$ARCHIVED_LOG
             WHERE ARCHIVED = 'YES' AND DELETED = 'YES'
          GROUP BY TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY')) SUM_ARCH_DEL
   WHERE SUM_ARCH.DAY = SUM_ARCH_DEL.DAY(+)
       AND TO_DATE (SUM_ARCH.DAY, 'DD/MM/YYYY') >sysdate-20
ORDER BY TO_DATE (DAY, 'DD/MM/YYYY');

another
======
SELECT SUM_ARCH.DAY,
         SUM_ARCH.GENERATED_GB,
         SUM_ARCH_DEL.DELETED_GB,
         SUM_ARCH.GENERATED_GB - SUM_ARCH_DEL.DELETED_GB "REMAINING_GB"
    FROM (  SELECT TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY') DAY,
                   SUM (ROUND ( (blocks * block_size) / (1024 * 1024)/1024, 2))
                      GENERATED_GB
              FROM V$ARCHIVED_LOG
             WHERE ARCHIVED = 'YES'
          GROUP BY TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY')) SUM_ARCH,
         (  SELECT TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY') DAY,
                   SUM (ROUND ( (blocks * block_size) / (1024 * 1024)/1024, 2))
                      DELETED_GB
              FROM V$ARCHIVED_LOG
             WHERE ARCHIVED = 'YES' AND DELETED = 'YES'
          GROUP BY TO_CHAR (COMPLETION_TIME, 'DD/MM/YYYY')) SUM_ARCH_DEL
   WHERE SUM_ARCH.DAY = SUM_ARCH_DEL.DAY(+)

ORDER BY TO_DATE (DAY, 'DD/MM/YYYY');

ASMspacereport 
=============
SET LINESIZE 150
SET PAGESIZE 9999
SET VERIFY off
COLUMN group_name             FORMAT a20           HEAD 'Disk Group|Name'
COLUMN sector_size            FORMAT 99,999        HEAD 'Sector|Size'
COLUMN block_size             FORMAT 99,999        HEAD 'Block|Size'
COLUMN allocation_unit_size   FORMAT 999,999,999   HEAD 'Allocation|Unit Size'
COLUMN state                  FORMAT a11           HEAD 'State'
COLUMN type                   FORMAT a6            HEAD 'Type'
COLUMN total_mb               FORMAT 999,999,999   HEAD 'Total Size (GB)'
COLUMN free_mb                FORMAT 999,999,999   HEAD 'Free Size (GB)'
COLUMN used_mb                FORMAT 999,999,999   HEAD 'Used Size (GB)'
COLUMN pct_used               FORMAT 999.99        HEAD 'Pct. Used'

SELECT
    distinct name                            group_name
  , sector_size                              sector_size
  , block_size                               block_size
  , allocation_unit_size                  allocation_unit_size
  , state                                        state
  , type                                         type
  , round(total_mb/1024)                              "total_gb"
  , round(free_mb/1024)                               "free_gb"
  , round((total_mb - free_mb) / 1024)          "used_gb"
  , round((1- (free_mb / total_mb))*100, 2)  "pct_used"
from v$asm_diskgroup ORDER BY name
/
exit

ASM disk usage in detail
===================
SET LINESIZE 150
SET PAGESIZE 9999
SET VERIFY off
COLUMN group_name             FORMAT a20           HEAD 'Disk Group|Name'
COLUMN sector_size            FORMAT 99,999        HEAD 'Sector|Size'
COLUMN block_size             FORMAT 99,999        HEAD 'Block|Size'
COLUMN allocation_unit_size   FORMAT 999,999,999   HEAD 'Allocation|Unit Size'
COLUMN state                  FORMAT a11           HEAD 'State'
COLUMN type                   FORMAT a6            HEAD 'Type'
COLUMN total_mb               FORMAT 999,999,999   HEAD 'Total Size (GB)'
COLUMN free_mb                FORMAT 999,999,999   HEAD 'Free Size (GB)'
COLUMN used_mb                FORMAT 999,999,999   HEAD 'Used Size (GB)'
COLUMN pct_used               FORMAT 999.99        HEAD 'Pct. Used'

SELECT
    distinct name                            group_name
  , sector_size                              sector_size
  , block_size                               block_size
  , allocation_unit_size                  allocation_unit_size
  , state                                        state
  , type                                         type
  , round(total_mb/1024)                              "total_gb"
  , round(free_mb/1024)                               "free_gb"
  , round((total_mb - free_mb) / 1024)          "used_gb"
  , round((1- (free_mb / total_mb))*100, 2)  "pct_used"
from v$asm_diskgroup ORDER BY name
/
exit


Check tablespace free space and used
============================
set pages 999
col tablespace_name format a40
col "size MB" format 999,999,999
col "free MB" format 99,999,999
col "% Used" format 999
select  tsu.tablespace_name, ceil(tsu.used_mb) "size MB"
,       decode(ceil(tsf.free_mb), NULL,0,ceil(tsf.free_mb)) "free MB"
,       decode(100 - ceil(tsf.free_mb/tsu.used_mb*100), NULL, 100,
               100 - ceil(tsf.free_mb/tsu.used_mb*100)) "% used"
               from     (select tablespace_name, sum(bytes)/1024/1024 used_mb
                from    dba_data_files group by tablespace_name union all
                        select  tablespace_name || '  **TEMP**'
                                ,       sum(bytes)/1024/1024 used_mb
                                        from    dba_temp_files group by tablespace_name) tsu
                                        ,       (select tablespace_name, sum(bytes)/1024/1024 free_mb
                                                from    dba_free_space group by tablespace_name) tsf
                                                where   tsu.tablespace_name = tsf.tablespace_name (+)
                                                order   by 4
                                                /

Tablespace usage
=============
set lines 300
 SELECT A.TABLESPACE_NAME,round(SUM(A.TOTS)/1024/1024/1024) "Tot size GB",
 round(SUM(A.SUMB)/1024/1024) "Tot Free MB",
 round(SUM(A.SUMB)*100/SUM(A.TOTS)) "%FREE",
 100-round(SUM(A.SUMB)*100/SUM(A.TOTS)) "%USED",
 round(SUM(A.LARGEST)/1024/1024) MAX_FREE,SUM(A.CHUNKS) CHUNKS_FREE
 FROM (
 SELECT TABLESPACE_NAME,0 TOTS,SUM(BYTES) SUMB,
 MAX(BYTES) LARGEST,COUNT(*) CHUNKS
 FROM SYS.DBA_FREE_SPACE A
 GROUP BY TABLESPACE_NAME
 UNION
 SELECT TABLESPACE_NAME,SUM(BYTES) TOTS,0,0,0
 FROM SYS.DBA_DATA_FILES
 GROUP BY TABLESPACE_NAME) A, V$INSTANCE B
 where A.TABLESPACE_NAME='&TBS'
 GROUP BY UPPER(B.INSTANCE_NAME),A.TABLESPACE_NAME
 order by 5
/

Redolog Size
==========
set linesize 300
column REDOLOG_FILE_NAME format a50
SELECT
    a.GROUP#,
    a.THREAD#,
    a.SEQUENCE#,
    a.ARCHIVED,
    a.STATUS,
    b.MEMBER    AS REDOLOG_FILE_NAME,
    (a.BYTES/1024/1024) AS SIZE_MB
FROM v$log a
JOIN v$logfile b ON a.Group#=b.Group#
ORDER BY a.GROUP# ASC;

Datafile size
==========
set linesize 1000
set pagesize 1000
select a.file_name, a.tablespace_name, a.bytes/1024/1024 "Size",
to_char(b.creation_time, 'DD-MON-YYYY HH24:MI:SS') " Creation Date"
from dba_data_files a, v$datafile b where a.tablespace_name='&tbsp'
and a.file_id = b.file#
order by file_name;

Pending Concurrent request
=====================
select COUNT (distinct cwr.request_id) Pending_Requests FROM apps.fnd_concurrent_worker_requests cwr, apps.fnd_concurrent_queues_tl cq, apps.fnd_user fu WHERE (cwr.phase_code = 'P' OR cwr.phase_code = 'R') AND cwr.hold_flag != 'Y' AND cwr.requested_start_date <= SYSDATE AND cwr.concurrent_queue_id = cq.concurrent_queue_id AND cwr.queue_application_id = cq.application_id and cq.LANGUAGE='US'
AND cwr.requested_by = fu.user_id and cq.user_concurrent_queue_name
in ( select unique user_concurrent_queue_name from apps.fnd_concurrent_queues_tl);

User Connected to Database
====================
select sid, serial#, username, osuser, program from gv$session  where username is not null AND PROGRAM NOT LIKE 'FTE_TXN_MANAGER%'
AND PROGRAM NOT LIKE 'STANDARD%'
AND PROGRAM NOT LIKE 'FNDSCH%'
AND PROGRAM NOT LIKE 'RCVOLTM%'
AND PROGRAM NOT LIKE 'JDBC%'
AND PROGRAM NOT LIKE 'PODAMGR%'
AND PROGRAM NOT LIKE 'INVMGR%'
AND PROGRAM NOT LIKE 'frmweb%'
AND PROGRAM NOT LIKE 'OAMCOLMGR%'
AND PROGRAM NOT LIKE 'INVTMRPM%'
AND PROGRAM NOT LIKE 'frmbld%'
AND PROGRAM NOT LIKE 'CRM%'
AND PROGRAM NOT LIKE 'ICM%'
AND PROGRAM NOT LIKE 'IEU_SH_CS%'
AND PROGRAM NOT LIKE 'FNDSM%'
AND PROGRAM NOT LIKE 'CRPINQMGR%'
AND PROGRAM NOT LIKE 'PASMGR%'
AND PROGRAM NOT LIKE 'IEU_WL_CS%'
AND PROGRAM NOT LIKE 'oraagent.bin%'
AND PROGRAM NOT LIKE 'FNDIM%';

Check Managers status from Front end.
=============================
set pagesize 9999;
select decode(CONCURRENT_QUEUE_NAME,'FNDICM','Internal Manager','FNDCRM','Conflict Resolution Manager','AMSDMIN','Marketing Data Mining Manager','C_AQCT_SVC','C AQCART Service','FFTM','FastFormula Transaction Manager','FNDCPOPP','Output Post Processor','FNDSCH','Scheduler/Prereleaser Manager','FNDSM_AQHERP','Service Manager: AQHERP','FTE_TXN_MANAGER','Transportation Manager','IEU_SH_CS','Session History Cleanup','IEU_WL_CS','UWQ Worklist Items Release for Crashed session','INVMGR','Inventory Manager','INVTMRPM','INV Remote Procedure Manager','OAMCOLMGR','OAM Metrics Collection Manager','PASMGR','PA Streamline Manager','PODAMGR','PO Document Approval Manager','RCVOLTM','Receiving Transaction Manager','STANDARD','Standard Manager','WFALSNRSVC','Workflow Agent Listener Service','WFMLRSVC','Workflow Mailer Service','WFWSSVC','Workflow Document Web Services Service','WMSTAMGR','WMS Task Archiving Manager','XDP_APPL_SVC','SFM Application Monitoring Service','XDP_CTRL_SVC','SFM Controller Service','XDP_Q_EVENT_SVC','SFM Event Manager Queue Service','XDP_Q_FA_SVC','SFM Fulfillment Actions Queue Service','XDP_Q_FE_READY_SVC','SFM Fulfillment Element Ready Queue Service','XDP_Q_IN_MSG_SVC','SFM Inbound Messages Queue Service','XDP_Q_ORDER_SVC','SFM Order Queue Service','XDP_Q_TIMER_SVC','SFM Timer Queue Service','XDP_Q_WI_SVC','SFM Work Item Queue Service','XDP_SMIT_SVC','SFM SM Interface Test Service') as "Concurrent Manager's Name", max_processes as "TARGET Processes", running_processes as "ACTUAL Processes" from apps.fnd_concurrent_queues where CONCURRENT_QUEUE_NAME in ('FNDICM','FNDCRM','AMSDMIN','C_AQCT_SVC','FFTM','FNDCPOPP','FNDSCH','FNDSM_AQHERP','FTE_TXN_MANAGER','IEU_SH_CS','IEU_WL_CS','INVMGR','INVTMRPM','OAMCOLMGR','PASMGR','PODAMGR','RCVOLTM','STANDARD','WFALSNRSVC','WFMLRSVC','WFWSSVC','WMSTAMGR','XDP_APPL_SVC','XDP_CTRL_SVC','XDP_Q_EVENT_SVC','XDP_Q_FA_SVC','XDP_Q_FE_READY_SVC','XDP_Q_IN_MSG_SVC','XDP_Q_ORDER_SVC','XDP_Q_TIMER_SVC','XDP_Q_WI_SVC','XDP_SMIT_SVC');


Query to check lock
================
set serveroutput on size 10000
declare
  cursor c1 is
    select * from v$lock where request != 0
      order by id1, id2;
  wid1            number := -999999;
  wid2            number := -999999;
  wholder_detail  varchar2(200);
  v_err_msg          varchar2(80);
  wsid            number(5);
  wstep           number(2);
  wtype           varchar2(10);
  wobject_name    varchar2(180);
  wobject_name1   varchar2(80);
  wlock_type      varchar2(50);
  w_lastcallet  varchar2(11);
  h_lastcallet  varchar2(11);
begin
  for c1_rec in c1 loop
    if c1_rec.id1 = wid1 and c1_rec.id2 = wid2 then
       null;
    else
       wstep  := 10;
       select sid , type into wsid , wtype
         from v$lock
         where id1  = c1_rec.id1
           and id2  = c1_rec.id2
           and request = 0
           and lmode != 4;
      dbms_output.put_line('  ');
       wstep  := 20;
      select 'Holder DBU: '||s.username ||' OSU: '||s.osuser ||' DBP:'||p.spid||' APP: '|| s.process ||
                ' SID:' || s.sid || ' Status: ' || s.status  ||
                ' (' ||         floor(last_call_et/3600)||':'||
                                floor(mod(last_call_et,3600)/60)||':'||
                                mod(mod(last_call_et,3600),60) ||
                ') Module:'|| module ||
              ' AppSrvr: ' || substr(replace(machine,'GEIPS-AMER\',null),1,15)
          into wholder_detail
          from v$session s, v$process p
          where s.sid= wsid
            and s.paddr = p.addr;
      dbms_output.put_line(wholder_detail);

      begin
        select decode(wtype,'TX', 'Transaction',
                            'DL', 'DDL Lock',
                            'MR', 'Media Recovery',
                            'RT', 'Redo Thread',
                            'UN', 'User Name',
                            'TX', 'Transaction',
                            'TM', 'DML',
                            'UL', 'PL/SQL User Lock',
                            'DX', 'Distributed Xaction',
                            'CF', 'Control File',
                            'IS', 'Instance State',
                            'FS', 'File Set',
                            'IR', 'Instance Recovery',
                            'ST', 'Disk Space Transaction',
                            'TS', 'Temp Segment',
                            'IV', 'Library Cache Invalida-tion',
                            'LS', 'Log Start or Switch',
                            'RW', 'Row Wait',
                            'SQ', 'Sequence Number',
                            'TE', 'Extend Table',
                            'TT', 'Temp Table',
                            'Un-Known Type of Lock')
                into wlock_type
                from dual;
        declare
          cursor c3 is
            select object_id from v$locked_object
              where session_id = wsid;
        begin
          wobject_name := '';
          for c3_rec in c3 loop
            select object_type||': '||owner||'.'||object_name
              into wobject_name
              from dba_objects
              where object_id = c3_rec.object_id;
            wobject_name := wobject_name ||' '||wobject_name1;
          end loop;
        exception
          when others then
            wobject_name := wobject_name ||' No Object Found';
        end;
        dbms_output.put_line('Lock Held: '||wlock_type||' for Object :'||wobject_name);
      exception
        when no_data_found then
          dbms_output.put_line('Lock Held: '||wlock_type||' No object found in DBA Objects');
      end;
    end if;
       wstep  := 30;
    select '....   Requestor DBU: '||s.username ||' OSU: '||s.osuser ||' DBP:'||p.spid||' APP: '|| s.process ||
                ' SID:' || s.sid || ' Status: ' || s.status  ||
                ' (' ||         floor(last_call_et/3600)||':'||
                                floor(mod(last_call_et,3600)/60)||':'||
                                mod(mod(last_call_et,3600),60) ||
                ') Module:'|| module ||
              ' AppSrvr: ' || substr(replace(machine,'GEIPS-AMER\',null),1,15)
          into wholder_detail
          from v$session s, v$process p
          where s.sid= c1_rec.sid
            and s.paddr = p.addr;
    dbms_output.put_line(wholder_detail);
    wid1  := c1_rec.id1;
    wid2  := c1_rec.id2;
  end loop;
  if wid1 = -999999 then
       wstep  := 40;
    dbms_output.put_line('No one requesting locks held by others');
  end if;
exception
  when others then
         v_err_msg := (sqlerrm ||'  '|| sqlcode||' step='||to_char(wstep));
    DBMS_OUTPUT.PUT_LINE(v_err_msg);
end;
/

Check tbs
========
select  * from dba_tablespace_usage_metrics where used_percent >90;

To Check Asm mount point disk space
============================
SET LINESIZE 150
SET PAGESIZE 9999
SET VERIFY off
COLUMN group_name             FORMAT a20           HEAD 'Disk Group|Name'
COLUMN sector_size            FORMAT 99,999        HEAD 'Sector|Size'
COLUMN block_size             FORMAT 99,999        HEAD 'Block|Size'
COLUMN allocation_unit_size   FORMAT 999,999,999   HEAD 'Allocation|Unit Size'
COLUMN state                  FORMAT a11           HEAD 'State'
COLUMN type                   FORMAT a6            HEAD 'Type'
COLUMN total_mb               FORMAT 999,999,999   HEAD 'Total Size (GB)'
COLUMN free_mb                FORMAT 999,999,999   HEAD 'Free Size (GB)'
COLUMN used_mb                FORMAT 999,999,999   HEAD 'Used Size (GB)'
COLUMN pct_used               FORMAT 999.99        HEAD 'Pct. Used'

SELECT
    distinct name                            group_name
  , sector_size                              sector_size
  , block_size                               block_size
  , allocation_unit_size                  allocation_unit_size
  , state                                        state
  , type                                         type
  , round(total_mb/1024)                              "total_gb"
  , round(free_mb/1024)                               "free_gb"
  , round((total_mb - free_mb) / 1024)          "used_gb"
  , round((1- (free_mb / total_mb))*100, 2)  "pct_used"
from v$asm_diskgroup
where name ='DATA_DEV' and round((1- (free_mb / total_mb))*100, 2)>80
ORDER BY name
/





other tbs scripts
===========
http://dbaahmed.blogspot.in/2015/01/tablespace-queries-col-tablespace-for.html

Thursday, 21 April 2016

Session history.

Users connect to server details.

select
       substr(a.spid,1,9) pid,
       substr(b.sid,1,5) sid,
       substr(b.serial#,1,5) ser#,
       substr(b.machine,1,6) box,
       substr(b.username,1,10) username,
--       b.server,
       substr(b.osuser,1,8) os_user,
       substr(b.program,1,30) program
from v$session b, v$process a
where
b.paddr = a.addr
and type='USER'
order by spid; 

Tuesday, 12 April 2016

Create/Check dbc file in r12


Create/Check DBC file


· (Hostname_SID).dbc not (Context Name).dbc file exist on both the nodes in application Tier.

· This File exists in $FND_TOP/secure

· Login as Application user (On both the nodes)

· When you create a file it’s name is .dbc. You might need to copy it as .dbc .



java oracle.apps.fnd.security.AdminAppServer apps/ STATUS DB_HOST== DB_PORT=1521 DB_NAME=DBC=.dbc


OUTPUT


Database Server

---------------

DATABASE_ID:

AUTHENTICATION: SECURE

Application Server

------------------

APPL_SERVER_STATUS: VALID/INVALID

APPL_SERVER_ID:051D72DC25AE30D5E0440003BAA9A29B24326414774079047273642913323149


· To Create the DBC File


o echo $FNDNAM

This will give the value for FNDNAM. In our case it gives ‘APPS’

o There should be no space on both side of ‘=’

o This will create a file .dbc. You might need to copy it as .dbc .


java oracle.apps.fnd.security.AdminAppServer apps/ ADD FNDNAM=apps GWYUID=applsyspub/pub TWO_TASK= SECURE_PATH=$FND_TOP/secure GUEST_USER_PWD=guest/oracle APPS_JDBC_DRIVER_TYPE=THIN DB_HOST= DB_PORT=1521

With more options
java oracle.apps.fnd.security.AdminAppServer
apps/apps
ADD FNDNAM=apps
GWYUID=applsyspub/pub
TWO_TASK=TEST
SECURE_PATH=$FND_TOP/secure
GUEST_USER_PWD=guest/oracle
APPS_JDBC_DRIVER_TYPE=THIN
DB_HOST=
DB_PORT=

For 11i.

Ref:
http://bysanirajesh.blogspot.com/2012/08/dbc-file-administration.html



Upgrade APEX 4.1.1 to 4.2.1 on Oracle Linux with GlassFish

Upgrade APEX 4.1.1 to 4.2.1 on Oracle Linux with GlassFish
==============================================


Steps:
1) download the software
You can download APEX 4.2.1 here. I downloaded the “all languages” zip file. Please note that the documentation is no longer included with the software. You can download the documentation separately here.
2) copy and extract the software
Now copy and extract the apex_4.2.1.zip file to your server. I use “unzip” to unzip the zip file. This will create a folder named “apex”. I usually keep this folder on my server in a permanent location, for example /u01/app/apex.
3) check the tablespace requirements
You need about 275MB of free space in the APEX tablespace (mine is called “APEX”) and 100MB of free space in the SYSTEM tablespace.
4) stop the APEX Listener
Before you start with the upgrade, you need to stop the APEX Listener to make sure no one is using the software during the upgrade.
To stop the APEX Listener under GlassFish, you can do it as follows:
– connect to the GlassFish administration console (by default this is port 4848 using SSL).
– log in with the “admin” user.
– click on Standalone Instances => Applications.
– select the “apex” application and select “Disable” from the “More Actions” drop down list.
The APEX Listener should now be stopped on your GlassFish instance.
5) start the upgrade
To upgrade the APEX software, you need to run the “apexins.sql” sql script from within the “apex” folder that you extracted above. You need to connect as SYS as SYSDBA with the oracle software owner (mine is called “oracle”). Make sure the “apex” folder is writeable!
apexins.sql needs 4 parameters: the name of the tablespace for the APEX user (in my case: APEX), the name of the tablespace for the FLOWS_FILES user (in my case: APEX), the name of the TEMP tablespace (in my case: TEMP) and the name of the virtual image directory (which is “/i/”).

$ su - oracle
$ cd /u01/app/apex
$ sqlplus /nolog
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jan 3 11:21:39 2013

Copyright (c) 1982, 2011, Oracle. All rights reserved.

SQL> connect / as sysdba
Connected.
SQL> @apexins.sql APEX APEX TEMP /i/
The upgrade will now start. This will create a new schema called “APEX_040200”. The upgrade can take some time, depending on the speed of your server. On my server (with fairly recent hardware), it took about 17 minutes. After the upgrade, check the installation log file (in the same folder where you exectuted the apexins.sql file) to make sure no errors were encountered during the process.
6) verify the installation
I always verify my APEX installation after a upgrade by querying dba_registry:

$ sqlplus /nolog

SQL*Plus: Release 11.2.0.3.0 Production on Thu Jan 3 12:06:21 2013

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

SQL> conn / as sysdba
Connected.
SQL> select status from dba_registry where comp_id='APEX';

STATUS
-------------------------------------------------------
VALID
Ref:
====
https://matthiashoys.wordpress.com/tag/apexins-sql/

https://community.oracle.com/thread/2328355?tstart=0

Sunday, 3 April 2016

Front end not opening Apache issue

libopmnoraclenls.so: unable to open library error in opmnctl logs.


libclntsh.so.10.1: wrong ELF class: ELFCLASS64 Killed

Solution
1) Simply copy the file libclntsh.so.10.1 file from a working
environment to non-working environment into the lib32 directory.
But, this is applicable only to the same version of OS.
OR
2) You can generate libclntsh.so.10.1 by executing the following command
$10.1.3_OH/bin/genclntsh -32
3) Setting the correct oracle home to 10.1.3 then running that ./bin/genclntsh helps:

If you run with the -32 option it updates the ./lib32 version of libclntsh.so.10.1
If you run without the -32 option it updates the ./lib version of libclntsh.so.10.1
( and similarly if it was set to 10.1.2, libclntsh.so.10.1 will be created in 10.1.2/lib )
So it is very important to set OH to 10.1.3.
 
Ref:
http://bkpappsdba.blogspot.com/2008/11/r12-install-and-post-install-issues-in.html

https://mpoojari.wordpress.com/2012/04

/04/libclntsh-so-10-1-wrong-elf-class-elfclass64-killed/

Friday, 1 April 2016

RMAN RESTORE ISSUE....



"File 1 was not restored from a sufficiently old backup" in RMAN Recover

RMAN> recover database;

starting media recovery

Oracle Error:
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/package/oracle/oradata/perseus/system01.dbf'

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/15/2012 11:09:12
RMAN-06053: unable to perform media recovery because of missing log
RMAN-06025: no backup of archived log for thread 1 with sequence 41765 and starting SCN of 9738413586917 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 41764 and starting SCN of 9738413585738 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 41763 and starting SCN of 9738413584155 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 41762 and starting SCN of 9738413582950 found to restore
...

RMAN-06025: no backup of archived log for thread 1 with sequence 41734 and starting SCN of 9738413520883 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 41733 and starting SCN of 9738413519245 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 41732 and starting SCN of 9738413518015 found to restore
RMAN-06025: no backup of archived log for thread 1 with sequence 41731 and starting SCN of 9738413516741 found to restore

RMAN> alter database open resetlogs;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 02/15/2012 11:28:44
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/package/oracle/oradata/perseus/system01.dbf'

RMAN> list backup of archivelog all;

List of Backup Sets
===================

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
16198481 73.00K     DISK        00:00:00     11-FEB-12     
        BP Key: 16198488   Status: AVAILABLE  Compressed: YES  Tag: SAT
        Piece Name: /package/oracle/orabackup/rman/rman_PERSEUS_arc_20120211_4644_1

  List of Archived Logs in backup set 16198481
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    41584   9738413221153 11-FEB-12 9738413222321 11-FEB-12
...

  1    41724   9738413502482 12-FEB-12 9738413503782 12-FEB-12
  1    41725   9738413503782 12-FEB-12 9738413505258 12-FEB-12
  1    41726   9738413505258 12-FEB-12 9738413509317 12-FEB-12
  1    41727   9738413509317 12-FEB-12 9738413513782 12-FEB-12

BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
16205673 11.50K     DISK        00:00:01     12-FEB-12     
        BP Key: 16205679   Status: AVAILABLE  Compressed: YES  Tag: SUN
        Piece Name: /package/oracle/orabackup/rman/rman_PERSEUS_arc_20120212_4653_1

  List of Archived Logs in backup set 16205673
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    41730   9738413516668 12-FEB-12 9738413516741 12-FEB-12

RMAN> recover database until sequence 41730;

Starting recover at 15-FEB-12
using channel ORA_DISK_1
using channel ORA_DISK_2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/15/2012 11:38:42
RMAN-06556: datafile 1 must be restored from backup older than SCN 9738413516668

Need to tell RMAN when to stop.
RMAN>  recover database until sequence 41731;

Starting recover at 15-FEB-12
using channel ORA_DISK_1
using channel ORA_DISK_2

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=41730
channel ORA_DISK_1: reading from backup piece /package/oracle/orabackup/rman/rman_PERSEUS_arc_20120212_4653_1
channel ORA_DISK_1: piece handle=/package/oracle/orabackup/rman/rman_PERSEUS_arc_20120212_4653_1 tag=SUN
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/oradb/archive/perseus/archive1_41730_729171422.dbf thread=1 sequence=41730
media recovery complete, elapsed time: 00:00:01
Finished recover at 15-FEB-12

RMAN> alter database open resetlogs;

database opened
new incarnation of database registered in recovery catalog
starting full resync of recovery catalog
full resync complete



 SET UNTIL SEQUENCE 41668;
  RECOVER DATABASE ;




Reference:--
https://blogs.warwick.ac.uk/java/entry/rman_backup/

https://oracleracdba1.wordpress.com/2013/08/25/rman-recovery-if-the-missing-archive-logs-are-required-for-recovery/

https://www.veritas.com/support/en_US/article.TECH76121