Tuesday, June 21, 2016


Configure UNIX server for oracle apps workflow mailer.


Edit the /etc/mail/sendmal.mc file
Look for this bellow line in this file
DAEMON_OPTIONS (`Port=smtp,Addr=127.0.0.1, Name=MTA')dn

sendmail configuration for workflow mail, setup test box
Add 1 line with SMTP port Number and Server IP to this above line
DAEMON_OPTIONS (`Port=25,Addr=192.168.1.61, Name=MTA')dnl
Here 25 is SMTP Port Number, 192.168.1.61 is Server IP
After adding his like file look like this
DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
DAEMON_OPTIONS(`Port=25,Addr=192.168.1.61, Name=MTA')dnl


Rebuild /etc/sendmail.cf from the revised /etc/mail/sendmail.mc
$m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
**NOTE: yum install sendmail-cf ( if error encountered )

yum install dovecot* (this is for imap)
/etc/init.d/dovecot restart
telnet localhost 143
a login appuser apppassword
c list "" *
create folder PROCESS and DISCARD under ~/mail


regards
 

Thursday, January 7, 2016

RMAN backup scripts

RMAN cold backup
================
run{
allocate channel d1 type disk FORMAT   '/u01/xx/xxxxx//%d_db_%u_%s_%p' MAXPIECESIZE 10G;
allocate channel d2 type disk FORMAT   '/u01/xx/xxxxx//%d_db_%u_%s_%p' MAXPIECESIZE 10G;
allocate channel d3 type disk FORMAT   '/u01/xx/xxxxx//%d_db_%u_%s_%p' MAXPIECESIZE 10G;
allocate channel d4 type disk FORMAT   '/u01/xx/xxxxx//%d_db_%u_%s_%p' MAXPIECESIZE 10G;
shutdown immediate;
startup mount;
backup tag FYR_database_cold as compressed backupset database ;
release channel d1;
release channel d2;
release channel d3;
release channel d4;
allocate channel ar1 type disk format '/u01/xxxxx/rman_cn_%T_%U.rman';
sql "alter database backup controlfile to ''/u01/xxxxx/rman_control.rman'' reuse";
release channel ar1 ;
alter database open;
}


RMAN Hot Backup
===============
run{
allocate channel d1 type disk FORMAT   '/u01/xxxxxx/%d_db_%u_%s_%p' MAXPIECESIZE 10G;
allocate channel d2 type disk FORMAT   '/u01/xxxxxx/%d_db_%u_%s_%p' MAXPIECESIZE 10G;
backup tag whole_database_cold as compressed backupset database ;
release channel d1;
release channel d2;
release channel d3;
release channel d4;
allocate channel ar1 type disk format '/u01/xxxx/rman_arc_%T_%U.rman';
BACKUP ARCHIVELOG from time 'sysdate - 2' ;
sql "alter database backup controlfile to ''/u01/xxxx/rman_control.rman'' reuse";
release channel ar1 ;
}

RESTORE (Duplicate)
===================
rman auxiliary /
RUN
{
ALLOCATE AUXILIARY CHANNEL c1 xxxICE TYPE disk ;
ALLOCATE AUXILIARY CHANNEL c2 xxxICE TYPE disk ;
ALLOCATE AUXILIARY CHANNEL c3 xxxICE TYPE disk ;
SET NEWNAME FOR DATABASE TO '/u01/xxx/oracle/data/%b';
duplicate database PROD to 'xxx' BACKUP LOCATION '/xxxxx/DB_Restore_xxx'
duplicate database PROD to 'xxx' BACKUP LOCATION '/xxxxx/DB_Restore_xxx'
LOGFILE GROUP 1 ('/u01/xxx/oracle/data/redo01.rdo') SIZE 1G REUSE, GROUP 2 ('/u01/xxx/oracle/data/redo02.rdo') SIZE 1G REUSE, GROUP 3 ('/u01/xxx/oracle/data/redo03.rdo') SIZE 1G REUSE;}


Use this in init file for RAC database "_no_recovery_through_resetlogs=TRUE"
Scripts for Apps DBA for daily operations.


--------------------------------------------------------
------OPERATION SCRIPTS TO HELP IN DAILY JOBS-----------
--------------------------------------------------------
1. Unlock application user
2. Currently Logged in users
3. Datafile shrink Report
4. Check DR Gap
5. Check DR current activity
6. Find SQL executed by a concurrent request
7. Unlock FNd user
8. Free Tablespace report
9. Get DDL of an object
10. List invalids with statement to compile them
11. Responsibilities assigned to a user.


--------------------------------------------------------
1. Unlock application user

BEGIN
FND_USER_PKG.EnableUser('A.STIGTER');
END;
/
--------------------------------------------------------
2. Currently Logged in users
SELECT
  fu.user_name User_Name,
  fu.email_address emailid,
  fu.description,
  TO_CHAR(IC.FIRST_CONNECT,'dd-Mon-rrrr HH24:mi:ss')"First Accessed",
  TO_CHAR(IC.LAST_CONNECT,'dd-Mon-rrrr HH24:mi:ss')"Last Accessed",
  ic.nls_territory,
  FVL.RESPONSIBILITY_NAME "RESPONSIBILITY NAME",
  fr.RESPONSIBILITY_KEY "Responsibility Key",
  ic.function_type,
  ic.time_out,
  fu.user_id,
  fu.employee_id,
  ic.responsibility_application_id,
  ic.responsibility_id,
  ic.org_id,
  ic.counter,
  fr.menu_id,
  ic.disabled_flag
FROM
  apps.fnd_user fu,
  apps.fnd_responsibility fr,
  apps.icx_sessions ic,
  apps.fnd_responsibility_VL FVL
WHERE
fu.user_id          = ic.user_id
AND FR.RESPONSIBILITY_KEY =FVL.RESPONSIBILITY_KEY
and fVl.responsibility_key != 'IRC_EXT_CANDIDATE'
AND fr.responsibility_id  = ic.responsibility_id
AND ic.disabled_flag      ='N'
AND ic.responsibility_id IS NOT NULL
AND (ic.last_connect + DECODE(apps.FND_PROFILE.VALUE('ICX_SESSION_TIMEOUT'), NULL,limit_time, 0,limit_time,apps.FND_PROFILE.VALUE('ICX_SESSION_TIMEOUT')/60)/24) > sysdate
and counter < ic.limit_connects
ORDER BY "Last Accessed" DESC;
--------------------------------------------------------
3. Datafile shrink Report

select /*+rule*/ 'alter database datafile '''||file_name||''' resize '||ceil( (nvl(hwm,1)*8192)/1024/1024)||'m autoextend on maxsize '||ceil( blocks*8192/1024/1024)||'m;' stat,
ceil( (nvl(hwm,1)*8192)/1024/1024 ) smallest,
ceil( blocks*8192/1024/1024) currsize,
ceil( blocks*8192/1024/1024) -
ceil( (nvl(hwm,1)*8192)/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(+)
order by 4;
***NOTE: Autoexend on has to be enabled with relevant maxsize

--------------------------------------------------------
4. Check DR Gap

select a.*, b.*, (a."Archived" - b."Applied") "GAP"
from
(select thread#, max(sequence#) "Archived" from v$archived_log where archived='YES' group by thread# ) a,
(select thread#, max(sequence#) "Applied" from v$archived_log where applied='YES' group by thread# ) b where a.thread# = b.thread#
--------------------------------------------------------
5. Check DR current activity

SELECT PROCESS, STATUS, THREAD#, SEQUENCE#, BLOCK#, BLOCKS FROM V$MANAGED_STANDBY
--------------------------------------------------------
6. Find SQL executed by a concurrent request

SELECT
  B.sid,
  C.sql_text ,
  C.module
FROM APPS.fnd_concurrent_requests A ,
  gV$SESSION B ,
  gV$SQLAREA C
WHERE A.oracle_session_id = B.audsid
AND B.sql_hash_value      = C.hash_value
AND A.request_id          = 1451703
--------------------------------------------------------
7. Unlock FNd user

BEGIN
FND_USER_PKG.EnableUser('&username');
END;
/
--------------------------------------------------------
8. Free Tablespace report
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,
  (100 - round((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) *100) / round(sum(a.bytes/1024/1024),2))) "Percentage Used"
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(+)
group by a.tablespace_name
order by Total_mb desc
--------------------------------------------------------
9. Get DDL of an object

--select dbms_metadata.get_ddl( object_type=>'&OBJECT_TYPE',name=>'&OBJECT_NAME',schema=>'&SCHEMA_NAME') FROM DUAL ;

select dbms_metadata.get_ddl(object_type, object_name, owner)
from
(
    --Convert DBA_OBJECTS.OBJECT_TYPE to DBMS_METADATA object type:
    select
        owner,
        object_name,
        decode(object_type,
            'PACKAGE',      'PACKAGE_SPEC',
            'PACKAGE BODY', 'PACKAGE_BODY',
            'TYPE BODY', 'TYPE_BODY',
            object_type
        ) object_type
    from dba_objects
    where object_name = :object_name
        --These objects are included with other object types.
        and object_type not in ('INDEX PARTITION','LOB','LOB PARTITION','TABLE PARTITION')
        --Ignore system-generated types that support collection processing.
        and not (object_type like 'TYPE' and object_name like 'SYS_PLSQL_%')
)
order by owner, object_type, object_name;
--------------------------------------------------------
10. List invalids with statement to compile them

set linesize 200
set pagesize 200
col object_name for a40
col owner for a6
set echo off
set feedback off
set verify off
set heading off
SELECT '----------------' from dual;
SELECT 'List of Invalids' from dual;
SELECT '----------------' from dual;
set heading on
select owner, objecT_name, objecT_type, status from dba_objects where status!='VALID';
set heading off
SELECT '---------------------------------' from dual;
SELECT 'Execute Below to compile invalids' from dual;
SELECT '---------------------------------' from dual;
select 'alter ', object_type, owner, '.' ,object_name, 'compile ;' from dba_objects where status!='VALID' and object_type != 'PACKAGE BODY'
union ALL
select 'alter ', decode (OBJECT_TYPE, 'PACKAGE BODY', 'PACKAGE'), owner, '.' ,object_name, 'compile BODY ;' from dba_objects where status!='VALID' and object_type = 'PACKAGE BODY' ;
--------------------------------------------------------
11. Responsibilities assigned to a user.

Select b.user_name, c.responsibility_name, a.START_DATE, a.END_DATE
from fnd_user_resp_groups_direct a, fnd_user b, fnd_responsibility_tl c
where a.user_id = b.user_id
and a.responsibility_id = c.responsibility_id
and b.user_name='&username'



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...