Monday, December 26, 2011

Move Datafiles on standby server without moving Primary


Move Datafiles on standby server without moving Primary
Include below parameter in standby parameter file
DB_FILE_NAME_CONVERT = '/primary_location/xyz.dbf','/standby_location/xyz.dbf'
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE cancel;
shut immediate
startup nomount pfile=initSCSL.ora
alter database mount standby database ;
alter system set standby_file_management='MANUAL' SCOPE=MEMORY ;
! cp /primary_location/xyz.dbf'  /standby_location/xyz.dbf
alter database rename file  '/primary_location/xyz.dbf' to '/standby_location/xyz.dbf';
alter system set standby_file_management='AUTO' SCOPE=MEMORY ;
alter database recover managed standby database parallel 4 disconnect from session;

OR
-concept not tested--do a test on non-produciton-
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE cancel;
mv  /primary_location/xyz.dbf  /standby_location/xyz.dbf
create a soft link ln -s /standby_location/xyz.dbf /primary_location/xyz.dbf
startup nomount pfile=initSCSL.ora
alter database mount standby database ;
alter database recover managed standby database parallel 4 disconnect from session;

Regards
Manoj

Thursday, October 20, 2011

XXX Is not a valid responsibility for the current user

There are multiple fixes for the error, some are listed below

This error is displayed because of the caching framework of apache, workflow components in oracle apps are suppose to sync the cache. When workflow events fail to trigger/function due to some XYZ reason, this issue occurs. Make sure workflow components are working optimally for permanent fix for temporary fix clear cache.

1. Clear cache
Go to > Functional Administrator responsibility
Click on Core services tab (the tab at the top right)
Click on Caching Framework Tab (blue tab under main tab)
Click on Global configuration
Click on Clear All Cache
A warning message related to performance will come , say yes

2. Bounce Apache by clearing cache
 
 
Regards
Manoj

Wednesday, October 12, 2011


Datafile high water mark
How lower can you resize datafiles ?
define blksize=8192 –set  your db block size

select /*+rule*/ 'alter database datafile '''||file_name||''' resize '||ceil( (nvl(hwm,1)*&blksize)/1024/1024)||'m;',
ceil( (nvl(hwm,1)*&blksize)/1024/1024 ) smallest,
ceil( blocks*&blksize/1024/1024) currsize,
ceil( blocks*&blksize/1024/1024) -
ceil( (nvl(hwm,1)*&blksize)/1024/1024 ) savings
from
   dba_data_files a,
   (select file_id, max(block_id+blocks-1) hwm
   from
      dba_extents
   group by file_id ) b
where a.file_id = b.file_id(+);


source: dba-oracle.com

Regards
Manoj

Thursday, September 29, 2011

Check India Localization patchset level
How to check the current India Localization Patchset Level installed on an Instance


India Localization Patchset is IN60107(Patch Number = 5498551)
If the Patch Number 5498551 is applied, your current India Localization patchset is IN60107.
This can be verified by running the below select
select * from JAI_APPLIED_PATCHES where Patch_number = 5498551;

If the Patch Number 5498551 is not applied, the India Localization Patchset should be IN60106 or below.
This can be checked by running the below statement:-
select * from JA_IN_INSTALL_CHECK_INFO where name like '601%';


source: Metalink ID: 752704.1

Regards
Manoj

Monday, September 5, 2011

select Query to view long running sql's

select Query to view long running sql's

set linesize 160
set pagesize 100

col machine for a15

select
machine,
ELAPSED_SECONDS,
TIME_REMAINING,
100 - (TIME_REMAINING*100/ELAPSED_SECONDS),
OPNAME  ,
b.TARGET,
b.sid
from
v$session a,
v$session_longops b
where a.sid=b.sid and
time_remaining != 0 ;

Thursday, August 18, 2011

Compiling forms in Oracle apps (e-business suite) 11i

Compiling forms in Oracle apps (e-business suite) 11i

All module fmb are located in $AU_TOP
-Change directory to $AU_TOP/forms/US
Take backup of existing fmx

f60gen module=<formname>.fmb userid=apps/<apps_pwd> output_file=<required_module_top>/forms/US/<formname>.fmx

Regards
Manoj

Monday, August 8, 2011

Given a username, gives his roles and privileges

Query to return roles and privileges in tabular format. Usefull for auditing.

select
  lpad(' ', 2*level) || granted_role "User, his roles and privileges"
from
  (
  /* THE USERS */
    select
      null     grantee,
      username granted_role
    from
      dba_users
    where
      username like upper('%&enter_username%')
  /* THE ROLES TO ROLES RELATIONS */
  union
    select
      grantee,
      granted_role
    from
      dba_role_privs
  /* THE ROLES TO PRIVILEGE RELATIONS */
  union
    select
      grantee,
      privilege
    from
      dba_sys_privs
  )
start with grantee is null
connect by grantee = prior granted_role
Allocated Tablespace quota for each oracle database user

select
username,
tablespace_name,
trunc(bytes/1024/1024,0) MB,
decode(max_bytes, '-1', 'UNLIMITED',MAX_BYTES/1024/1024) "QUOTA (MB)"
from
dba_ts_quotas
List of Database users about to expire in 'n' days.

select * from dba_users where expiry_date  > sysdate - 10 and expiry_date < sysdate + 10
Currently Logged in Forms users

SELECT TIME, user_name, responsibility_name, user_form_name
FROM apps.fnd_form_sessions_v
ORDER BY 1


Sessions opened by each user

select user_name, count(1) "Sessions Opened"
from apps.fnd_form_sessions_v
group by user_name order by count(1)desc
Database size with breakdown of datafiles, tempfiles, redologs and archivelogs

select
a.bytes "Data Files GB",
b.bytes "Temp Files GB",
c.bytes "Log Files GB",
d.bytes "Archive Logfiles 30 Days",
(a.bytes + b.bytes + c.bytes + d.bytes) "Total GB"
from
(select sum(bytes/1024/1024/1024) bytes from dba_data_files) a ,
(select sum(bytes/1024/1024/1024) bytes from dba_temp_files) b,
(select count(1) * 0.05859375 bytes from v$logfile) c,
(SELECT count(1) * 0.05859375 bytes from v$log_history
where to_date(first_time) > sysdate - 30) d
Tablespace Free size for E-business suite


I have included only those tablespaces which frequently become full

select
  a.tablespace_name,
  round(sum(a.bytes/1024/1024),2) TOTAL_MB,  
  round(sum
  (
    ( case
    when autoextensible = 'YES' then
    (a.maxbytes - a.user_bytes) + nvl(b.bytes,0)
    when autoextensible = 'NO' then
    nvl(b.bytes,0)
    end
    )/1024/1024
  ),2) FREE_MB
from
  dba_data_files a,
  (
    select file_id,
      sum(bytes) bytes
    from dba_free_space
    group by file_id
  ) b
where
  a.file_id = b.file_id(+)
and a.tablespace_name in
(
'SYSTEM',
'APPLSYSD',
'APPLSYSX',
'GLX',
'GLD',
'APD',
'APX',
'ARD',
'ARX',
'UNDOTS1'
)
group by a.tablespace_name

Temp Tablespace error's and resolution

ora-01652

Troubleshooting Details
Error explanation
There is no enough space for a temporary segment. The size reported in the error message is the number of contiguous free Oracle blocks that cannot be found in the listed tablespace.

How to approach the ORA-1652 error
There are two views in the database that help keep track of the free space in the temporary tablespace: v$sort_usage and v$tempseg_usage (from 9i onwards).

In order for the approach to be relevant, the following investigation steps should be followed immediately after the error occurs : Check the status of the sort segment utilization :
select TABLESPACE_NAME,TOTAL_BLOCKS,USED_BLOCKS,FREE_BLOCKS from v$sort_segment;
If USED_BLOCKS = TOTAL_BLOCKS, find which user and statement is using the temporary sort segment by following: (Note 317441.1 - How Do You Find Who And What SQL Is Using Temp Segments) In some cases, you may find that the ORA-1652 is not reported for a temporary tablespace, but a permanent one. This is not an abnormal behaviour and it can occur for example while creating or dropping objects like tables and indexes in permanent tablespaces. (Reference : Note 19047.1 - OERR: ORA 1652 unable to extend temp segment by %s in tablespace %s) In such cases the following note will be of use :
( Note 100492.1 - ORA-01652 : Estimate Space Needed to CREATE INDEX)

In the process of diagnostic and tuning, the resumable statement feature can be useful. It allows the DBA, once having applied the appropriate solution to the space allocation issue, to resume the suspended transaction which does not loose all the work done previously. By querying dba_resumable one can find the statement that is executed when ORA-1652 occurs. See Note 136941.1 - Using RESUMABLE Session to Avoid Transaction Abort Due to Space Errors.

There are two ways of solving this error

Add more tempfiles, increase the size of the current ones or enable auto extend and the most important:
Tune the queries/statements so that the sort operations are done in memory and not on the disk.
Note that the extents allocated for a user's sort segment are NOT deallocated but are marked as FREE from performance reasons. The FREE extents can be further used by other users that are executing sort
operations.  After the database restart the allocated extens are NOT released either but are FREE to be reused.
Hence, seeing  the physical space of the temporary tablespace fully allocated is not a reason to be concerned per se. The above query of V$SORT_SEGMENT should be used to establish the free space inside the temporary tablespace.

Known issues
Note 463819.1 - Database HANG After Migrating to 10.2 : ORA-1652
Note 164850.1 - ORA-01652 in Resumable Statements Prevents any SELECT on DBA_RESUMABLE View

SQL Queries

Temp Tablespace usage Report

SELECT   A.tablespace_name tablespace, D.mb_total,
         SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_used,
         D.mb_total - SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_free
FROM     v$sort_segment A,
         (
         SELECT   B.name, C.block_size, SUM (C.bytes) / 1024 / 1024 mb_total
         FROM     v$tablespace B, v$tempfile C
         WHERE    B.ts#= C.ts#
         GROUP BY B.name, C.block_size
         ) D
WHERE    A.tablespace_name = D.name
GROUP by A.tablespace_name, D.mb_total

Temp Space usage session wise

SELECT   S.sid || ',' || S.serial# sid_serial, S.username,
         T.blocks * TBS.block_size / 1024 / 1024 mb_used, T.tablespace,
         T.sqladdr address, Q.hash_value, Q.sql_text
FROM     v$sort_usage T, v$session S, v$sqlarea Q, dba_tablespaces TBS
WHERE    T.session_addr = S.saddr
AND      T.sqladdr = Q.address (+)
AND      T.tablespace = TBS.tablespace_name
--AND      T.blocks * TBS.block_size / 1024 / 1024  > 5024
ORDER BY S.sid

Regards
Manoj
Check Database Memory Usage SGA+PGA

UNIX tools which look at UNIX process memory are unable to distinguish between private and shared memory and thus over-report memory usage for Oracle processes.

Check memory usage from Oracle Database

Total memory usage
select sum(bytes)/1024/1024 mb from (select bytes from v$sgastat union all select value bytes from v$sesstat s, v$statname n where n.STATISTIC# = s.STATISTIC# and  n.name = 'session pga memory' );

Process wise listing
select a.sid,value/(1024*1024) "MB",program from v$session a, v$sesstat b where a.sid=b.sid and b.statistic#=(select statistic# from v$statname where name='session pga memory') order by value/(1024*1024) desc ;


source: oracle communities
JBOSS certificate deployment



Create Private Certificate store

keytool -genkey alias mysite.com keyalg RSA -keystore key.store


create cretificate request

keytool -certreq -alias mysite.com -file certreq.csr -keystore key.store



You should receive 3+ certificates

root


intermidiate ( can be more than one )


certificate generated against your CSR


Import root CA

keytool -import -alias root -keystore key.store -trustcacerts -file /root/root.txt


Import intermediate CA

keytool -import -alias intermediate -keystore key.store -trustcacerts -file /root/intermediate.txt

Import signed CA

keytool -import -alias mysite.com -keystore key.store -trustcacerts -file /root/mysite.com.txt


Steps to generate pfx ( private key+ certificate) to send it backup to CA ( windows )

create keystore of PKCS12

keytool -genkey -alias pkc -keystore key.store.p12 -storetype pkcs12

truncate the pkcs keystore

keytool -delete -alias pkc -keystore key.store.p12 -storetype pkcs12

copy/import der keystore to pkcs keystore

keytool -importkeystore -srckeystore key.store -destkeystore key.store.p12 -srcstoretype jks -deststoretype pkcs12 -scrstorepass 123455 -deststorepass 2323233 -srcalias mysite.com -destalias mysite.com

export the pfx bundle

keytool -exportcert -keystore key.store.p12 -storetype pkcs12 -alias mysite.com -file mysite.pfx

Generate private key from the key store

syntax: java -jar exportprivatekey.zip [pkcs12 or jks]

example: java -jar exportprivatekey.zip /root/key.store jks hello mysite.com mysite.key


Bundle private and public key in pkcs12 format

openssl pkcs12 -export -out mm.e.pfx -inkey mysite.key -in my.txt


Oracle database Moving tempfiles without shutdown



Before 10g

alter database tempfile 'temp26.dbf' offline ;

host mv temp26.dbf /temp/temp26.dbf

host ln -s temp26.dbf /temp/temp26.dbf

alter database tempfile 'temp26.dbf' online;



After 10g

alter database tempfile 'temp26.dbf' offline ;

host mv temp26.dbf /temp/temp26.dbf

alter database rename file 'temp26.dbf' to '/temp/temp26.dbf'

Oracle E-business suite logs clean up

 Oracle E-business suite logs clean up #!/bin/bash cd $EBS_DOMAIN_HOME find $EBS_DOMAIN_HOME -type f -path "*/logs/*.log?*" -mtime...