Monday, May 16, 2016

Script to Get Data for SR Update Apache, Java, Client JRE, Forms, Perl, PL/SQL versions and Forms communication mode & Oracle Patch information

1) Apache, Java, Client JRE, Forms, Perl, PL/SQL versions and Forms communication mode
 
#!/bin/bash
# +===========================================================================+ 
# | FILENAME 
# | Instancedetails_R12.sh 
# | 
# | DESCRIPTION 
# |   This script can be used to collect Apache, Jserv, Forms, Jinitiator and   
# |   Perl version in E-Business suite R12 
# | 
# | PLATFORM 
# | Unix Generic, Linux, HP-UX,IBM AIX, Sunsolaris  
# | 
# | NOTES 
# |   Before running the script ensure that you have sourced the environment  
# |   by running APPS_host.env file from $APPL_TOP.   
# | 
# | HISTORY 
# |   Version 1.0
# +===========================================================================+ 
# 
#--------------------------------------------------------------------
# CONSTANTS

TEMP_FILE=/tmp/`hostname`_`date +%m%d%y.%H%M`.txt
ID1=dba@oncalldba.com

#--------------------------------------------------------------------
# MAIN
( 
echo "Script Started " 
date 
## The script shows output on screen and creates file named ${TEMP_FILE} file in /tmp  ## directory 
## Collect the Apache version 
echo "*****Apache Version*****" 
$IAS_ORACLE_HOME/Apache/Apache/bin/httpd -v 
echo " " 
## Collect perl version 
echo "*****perl version******" 
$IAS_ORACLE_HOME/perl/bin/perl -v|grep built 
echo " " 
## Collect Java version 
echo "******Java Version******" 
sh -c "`awk -F= '$1 ~ /^JSERVJAVA.*$/ {print $2}' $ADMIN_SCRIPTS_HOME/java.sh` -version;" 
echo " " 
## Collect client JRE version 
echo "*****Client JRE version*****" 
cat $FORMS_WEB_CONFIG_FILE|grep sun_plugin_version| cut -c 1-35 
echo " " 
## Collect Forms version 
echo "*****Forms Version*****" 
$ORACLE_HOME/bin/frmcmp_batch|grep Forms| grep Version 
echo " " 
## Collect PL/SQL Version 
echo "*****PL/SQL Version****" 
$ORACLE_HOME/bin/frmcmp_batch|grep PL/SQL|grep Version 
echo " " 
## Collect Forms communication mode 
echo "****Forms Communication Mode****" 
cat $FORMS_WEB_CONFIG_FILE|grep serverURL= 
echo "If the serverURL parameter has no value then Forms is implemented in socket mode else it is servlet" 
echo " " 
echo "Script Completed Successfully and it has generated the file  ${TEMP_FILE} in /tmp directory" 
echo "Script completed " 
date 
) 2>&1 | tee $TEMP_FILE
###
### END OF SCRIPT
###
# Use This to get the File to Inbox
uuencode $TEMP_FILE $TEMP_FILE |mail -s "${TWO_TASK} Details for SR Update" $ID1
# This Can be used if Mailx is activated for the host
2) Oracle Home & OPatch Information
 
#!/bin/bash
#===================================================================#
#                                                                   #
# Name     : sr_update.sh                                           #
# Synopsis : Gathers the  Host info and ORACLE_HOME & OPatch        #
#            Information and Stores in to File.                     #
#                                                                   #
#===================================================================#
#--------------------------------------------------------------------
# CONSTANTS

TEMP_FILE=/tmp/sr_update.txt
ID1=dba@oncalldba.com

#--------------------------------------------------------------------
# MAIN

echo "############ BEGIN INFO GATHERING ############" > $TEMP_FILE 
echo "[Date]: " `date` >> $TEMP_FILE 
echo "" >> $TEMP_FILE 
echo "------------- ORACLE HOME Info ----------------" >> $TEMP_FILE 
echo "" >> $TEMP_FILE 
echo "[ORACLE_HOME]: "$ORACLE_HOME >> $TEMP_FILE 
echo "" >> $TEMP_FILE 
echo "------------ Machine Info ------------" >> $TEMP_FILE 
echo "" >> $TEMP_FILE 
echo "[Name]: " `uname -an` >> $TEMP_FILE 
echo "" >> $TEMP_FILE 
echo "----------- ORACLE_HOME Patch Info -------------" >> $TEMP_FILE 
echo "" >> $TEMP_FILE 
$ORACLE_HOME/OPatch/opatch lsinventory -details -invPtrLoc \ 
$ORACLE_HOME/oraInst.loc >> $TEMP_FILE 
echo "" >> $TEMP_FILE 
echo "############ END INFO GATHERING ############" >> $TEMP_FILE 
echo "" >> $TEMP_FILE 

# Use This to get the File to Inbox
uuencode $TEMP_FILE $TEMP_FILE |mail -s "${ORACLE_SID} Details for SR Update" $ID1
# This Can be used if Mailx is activated for the host


Metalink Note ID's R12 : -- Script to find Apache, Java, JRE, Forms version for Oracle E-Business Suite R12 (Doc ID 468311.1) 11i/R12 : -- Utility /Script To Check The Techstack Component Versions (Forms, Http Server, JDK, Framework, Database, etc) (Doc ID 601736.1) ~~ Cheers

Sunday, May 15, 2016

Blocking Development Tools Like Toad to Connect PROD DB


Blocking Development Tools from Connecting from Production Database

CONNECT / AS SYSDBA;
 
CREATE OR REPLACE TRIGGER block_tools_from_prod
  AFTER LOGON ON DATABASE
DECLARE
  v_prog sys.v_$session.program%TYPE;
BEGIN
  SELECT program INTO v_prog 
    FROM sys.v_$session
  WHERE  audsid = USERENV('SESSIONID')
    AND  audsid != 0  -- Don't Check SYS Connections
    AND  ROWNUM = 1;  -- Parallel processes will have the same AUDSID's
 
  IF UPPER(v_prog) LIKE '%TOAD%' OR UPPER(v_prog) LIKE '%T.O.A.D%' OR -- Toad
     UPPER(v_prog) LIKE '%SQLNAV%' OR     -- SQL Navigator
     UPPER(v_prog) LIKE '%PLSQLDEV%' OR -- PLSQL Developer
     UPPER(v_prog) LIKE '%BUSOBJ%' OR   -- Business Objects
     UPPER(v_prog) LIKE '%EXCEL%'       -- MS-Excel plug-in
  THEN
     RAISE_APPLICATION_ERROR(-20000, 'Development tools are not allowed here.');
  END IF;
END;
/
SHOW ERRORS

~~ Cheers

Sending Mail from Oracle


1) Send Mail

Usage:

set serveroutput on

exec send_mail(msg_to =>'dba@oncalldba.com');

exec send_mail(msg_to =>'dba@oncalldba.com', -
msg_text=>'Sample email text from the Oracle database' -
);

Procedure:

CREATE OR REPLACE PROCEDURE SEND_MAIL (
  msg_from    VARCHAR2 := 'oracle',
  msg_to      VARCHAR2,
  msg_subject VARCHAR2 := 'Email alert from the Oracle database',
  msg_text    VARCHAR2 := '' )
IS
  c  UTL_TCP.connection;
  rc INTEGER;
BEGIN
  c := UTL_TCP.open_connection('127.0.0.1', 25);       -- open the SMTP port 25 on local machine
  DBMS_OUTPUT.put_line(UTL_TCP.get_line(c, TRUE));
  rc := UTL_TCP.write_line(c, 'HELO localhost');
  DBMS_OUTPUT.put_line(UTL_TCP.get_line(c, TRUE));
  rc := UTL_TCP.write_line(c, 'MAIL FROM: '||msg_from);
  DBMS_OUTPUT.put_line(UTL_TCP.get_line(c, TRUE));
  rc := UTL_TCP.write_line(c, 'RCPT TO: '||msg_to);
  DBMS_OUTPUT.put_line(UTL_TCP.get_line(c, TRUE));
  rc := UTL_TCP.write_line(c, 'DATA');                 -- Start message body
  DBMS_OUTPUT.put_line(UTL_TCP.get_line(c, TRUE));
  rc := UTL_TCP.write_line(c, 'Subject: '||msg_subject);
  rc := UTL_TCP.write_line(c, '');
  rc := UTL_TCP.write_line(c, msg_text);
  rc := UTL_TCP.write_line(c, '.');                    -- End of message body
  DBMS_OUTPUT.put_line(UTL_TCP.get_line(c, TRUE));
  rc := UTL_TCP.write_line(c, 'QUIT');
  DBMS_OUTPUT.put_line(UTL_TCP.get_line(c, TRUE));
  UTL_TCP.close_connection(c);                         -- Close the connection
EXCEPTION
  WHEN OTHERS THEN
       raise_application_error(
           -20000, 'Unable to send e-mail message from pl/sql because of: '||
           SQLERRM);
END;
/ 
2) Sending Mail with Attachments

CREATE OR replace PROCEDURE Send_mail (
msg_from    VARCHAR2 := 'dba@oncalldba.com',
----- MAIL BOX SENDING THE EMAIL
msg_to      VARCHAR2 := 'dba@oncalldba.com',
----- MAIL BOX RECIEVING THE EMAIL
msg_subject VARCHAR2 := 'Output file TEST1',----- EMAIL SUBJECT
msg_text    VARCHAR2 := 'THIS IS THE TEXT OF THE EMAIL MESSAGE.',
v_output1   VARCHAR2 :=
'THIS IS THE TEXT OF THE ATTACHMENT FILE. THIS TEXT SHOULD BE IN A TEXT FILE ATTACHED TO THE EMAIL.'
)
IS
  c    utl_tcp.connection;
  rc   INTEGER;
  crlf VARCHAR2(2) := Chr(13)
                      ||Chr(10);
  mesg VARCHAR2( 32767 );
BEGIN
    c := utl_tcp.Open_connection('192.35.140.18', 25);
    ----- OPEN SMTP PORT CONNECTION
    rc := utl_tcp.Write_line(c, 'HELO 192.35.140.18');
    ----- PERFORMS HANDSHAKING WITH SMTP SERVER
    dbms_output.Put_line(utl_tcp.Get_line(c, TRUE));
    rc := utl_tcp.Write_line(c, 'EHLO 192.35.140.18');
    ----- PERFORMS HANDSHAKING WITH SMTP SERVER, INCLUDING EXTRA INFORMATION
    dbms_output.Put_line(utl_tcp.Get_line(c, TRUE));
    rc := utl_tcp.Write_line(c, 'MAIL FROM: '
                                ||msg_from); ----- MAIL BOX SENDING THE EMAIL
    dbms_output.Put_line(utl_tcp.Get_line(c, TRUE));
    rc := utl_tcp.Write_line(c, 'RCPT TO: '
                                ||msg_to); ----- MAIL BOX RECIEVING THE EMAIL
    dbms_output.Put_line(utl_tcp.Get_line(c, TRUE));
    rc := utl_tcp.Write_line(c, 'DATA'); ----- EMAIL MESSAGE BODY START
    dbms_output.Put_line(utl_tcp.Get_line(c, TRUE));
    rc := utl_tcp.Write_line(c, 'Date: '
                                ||To_char(SYSDATE, 'dd Mon yy hh24:mi:ss'));
    rc := utl_tcp.Write_line(c, 'From: '
                                ||msg_from
                                ||' <'
                                ||msg_from
                                ||'>');
    rc := utl_tcp.Write_line(c, 'MIME-Version: 1.0');
    rc := utl_tcp.Write_line(c, 'To: '
                                ||msg_to
                                ||' <'
                                ||msg_to
                                ||'>');
    rc := utl_tcp.Write_line(c, 'Subject: '
                                ||msg_subject);
    rc := utl_tcp.Write_line(c, 'Content-Type: multipart/mixed;');
    ----- INDICATES THAT THE BODY CONSISTS OF MORE THAN ONE PART
    rc := utl_tcp.Write_line(c, ' boundary="-----SECBOUND"');
    ----- SEPERATOR USED TO SEPERATE THE BODY PARTS
    rc := utl_tcp.Write_line(c, '');
    ----- INSERTS A BLANK LINE. PART OF THE MIME FORMAT AND NONE OF THEM SHOULD BE REMOVED.
    rc := utl_tcp.Write_line(c, '-------SECBOUND');
    rc := utl_tcp.Write_line(c, 'Content-Type: text/plain');
    ----- 1ST BODY PART. EMAIL TEXT MESSAGE
    rc := utl_tcp.Write_line(c, 'Content-Transfer-Encoding: 7bit');
    rc := utl_tcp.Write_line(c, '');
    rc := utl_tcp.Write_line(c, msg_text); ----- TEXT OF EMAIL MESSAGE
    rc := utl_tcp.Write_line(c, '');
    rc := utl_tcp.Write_line(c, '-------SECBOUND');
    rc := utl_tcp.Write_line(c, 'Content-Type: text/plain;');
    ----- 2ND BODY PART.
    rc := utl_tcp.Write_line(c, ' name="Test.txt"');
    rc := utl_tcp.Write_line(c, 'Content-Transfer_Encoding: 8bit');
    rc := utl_tcp.Write_line(c, 'Content-Disposition: attachment;');
    ----- INDICATES THAT THIS IS AN ATTACHMENT
    rc := utl_tcp.Write_line(c, ' filename="Test.txt"');
    ----- SUGGESTED FILE NAME FOR ATTACHMENT
    rc := utl_tcp.Write_line(c, '');
    rc := utl_tcp.Write_line(c, v_output1);
    rc := utl_tcp.Write_line(c, '-------SECBOUND--');
    rc := utl_tcp.Write_line(c, '');
    rc := utl_tcp.Write_line(c, '.'); ----- EMAIL MESSAGE BODY END
    dbms_output.Put_line(utl_tcp.Get_line(c, TRUE));
    rc := utl_tcp.Write_line(c, 'QUIT'); ----- ENDS EMAIL TRANSACTION
    dbms_output.Put_line(utl_tcp.Get_line(c, TRUE));
    utl_tcp.Close_connection(c); ----- CLOSE SMTP PORT CONNECTION
EXCEPTION
  WHEN OTHERS THEN
             Raise_application_error(-20000, SQLERRM);
END;
/  
~~ Cheers

Saturday, May 14, 2016

E-Business Suite R12.2: Online Patching


Oracle E-Business Suite Release 12.2 introduces Online Patching, a new feature that greatly reduces the downtime that was needed in previous releases for application of Release Update Packs (RUPs), Critical Patch Updates (CPUs), and other patches and bug fixes of various kinds.

How it Works?
  1. A copy is made of the running system.
  2. Patches are applied to the copy while users continue to access the running system.
  3. Transparently to users, the copy becomes the new running system.
  4. What was the original running system (now obsolete) is deleted. 
The Online Patching infrastructure is the Oracle E-Business Suite Release 12.2 mechanism that allows Oracle E-Business Suite patches to be applied online, while the system is running and users are working as normal. This infrastructure includes database objects and file system components.
To Incorporate the Online patching There few Architectural Changes in 12.2 to Support Online Patching.
Patching Occurs on a Copy Not on the Actual system.
  • Database
    • A separate copy is maintained of all database code objects that
      are changed by a patch
  • File system
    • All patches are applied to the secondary file system
    • Synchronization of the file systems is managed by the patching tools


DataBase 11G R2 Edition-Based Redefinition (EBR)
Enables the online upgrade of the database tier,Allows an application to efficiently store multiple copies of its application definition in the same database. Provides an isolation mechanism that allows pre-upgrade and post-upgrade schema to co-exist,Changes to database objects are made in the isolation of an “Edition” ,Changes to database objects do not effect the running Application.

Database Editions
  • Run Edition
    • The edition currently in use by the running application ,Used by Online Users
    • This is always the default database edition 
    • Never changed by a Patch
  • Patch Edition
    • The edition currently in use by the patching tool adop (AD Online Patching) utility.
    • This edition is only present when patching is in progress 
    • Changes do no affect the running Application
    • Always the direct child of the Run Edition.
  • Old Edition(s)
    • There maybe zero or more Old Editions
    • When the Patch Edition is promoted to production the previous Run Edition is now regarded as an Old Edition
    • Only retained until a full cleanup operation is run 

File System
EBS 12.2 is installed with 3 file systems,All 3 file system forms Single E-Business Suite Instance and connect to a single database.
  • FS-1 (Production file system),Used by the current users of the system
  • FS-2 (Copy of Production file system), Where Actual Patching is done
  • FS-NE (Non Editioned file system) ,Stores data that is stored on the file system

  • In Release 12.2, all patching operations are carried out while the applications are in use and users are online.
  • Patching is performed using the new adop (AD Online Patching) utility.
  • A short period of downtime is required, but this amounts to little more than a restart of the services: the time the applications are unavailable is measured in minutes rather than hours, and this can be specified to be at the most convenient time.
The two files systems are rotated between Run and Patch during every patch cycle


  • Run Edition
    • The edition currently in use by the running application ,Used by Online Users
    • Never changed by a Patch



  • Patch Edition
    • The edition currently in use by the patching tool adop (AD Online Patching) utility.
    • This edition is only present when patching is in progress 
    • Changes do no affect the running Application 
    • Currently being patched
      or
      Waiting for the next patch cycle
  The Online Patching cycle consists of the following phases:
  1. Prepare a virtual copy (patch edition) of the running application (run edition).
  2. Apply patches to the patch edition of the application.
  3. Finalize the system in readiness for the cutover phase.
  4. Cutover to the patch edition and make it the new run edition.
  5. Cleanup obsolete definitions or data to recover space.
This introduces the concept of a patching cycle that consists of several phases, in contrast to the model used in previous releases. These phases are denoted prepare, apply, finalize, cutover, and cleanup.


To support Online Patching Cycle phases, ADOP replaces ADPATCH utility to apply Application patches. In below diagram you can see how a patch is applied.
 

Prepare
  • Patch Edition & Run Edition of the file systems are synchronized
  • All files on the Patch Edition are an exact copy of the files on the Run Edition
  • Patch Edition is created in the database
  • All code objects in the Patch Edition begin as pointers to code objects in the Run Edition
  • Storage objects such as tables are not copied

Apply
  • Patches are applied to the copy (Patch Edition)
  • Users are connected to the Application and can perform their work unaffected by the patch
  • The running application is unaffected by these changes

Finalize
  • Patches are applied to the copy (Patch Edition)
  • Users are connected to the Application and can perform their work unaffected by the patch
  • The running application is unaffected by these changes

Cutover
  • During cutover a brief downtime is taken
  • Middle-tier processes stopped
  • File system roles swapped, where in Patched (FS-2) promoted to Run and FS-1 available for next patching cycle
  • In Database Patch Edition promoted to Run Edition
  • Middle-tier processes restarted

Cleanup
  • Cleanup occurs after users have been brought back online to the newly patched Application
  • In Database Code objects patched in the latest patching cycle are deleted from Old Editions.
  • In File System it does not perform any task, except marking Pre-Patch File System ready for the next Patching Cycle. 
Apart from the above Five phases we have hidden phase, Abort some thing slimier to adworker hidden option ,The Online Patching Cycle can be aborted at any time prior to Cutover.