Showing posts with label DBA. Show all posts
Showing posts with label DBA. Show all posts

Thursday, 2 July 2020

Rac - Interview question

0. What is ORACLE RAC IP & VIRTUAL IP or VIP

Public IP:  The public IP address is for the server.  This is the same as any server IP address, a unique address with exists in /etc/hosts.
Private IP: Oracle RCA requires "private IP" addresses to manage the CRS, the clusterware heartbeat process and the cache fusion layer.
Virtual IP:  Oracle uses a Virtual IP (VIP) for database access.  The VIP must be on the same subnet as the public IP address.  The VIP is used for RAC failover (TAF).


In previous terms of RAC, We have one Public IP & One Private IP.

Public IP is for the rest of the world. In Normal case we use a protocol called Stateful protocol for Ex. TCP/IP (its like acknowledges)
Private communication between Node to Node should be very fast, In general we use a protocol called State less Protocol. For example UDP.

UDP like a SEND & FORGET.

In tnsnames. Ora

Node1 / Host1 Public IP
Node2 / Host2 Public IP.

Basically these hosts or node names be resolved by the clients.

When ever a client requires to establish a connection It looks for the first resolvable IP in Network file and establishes a connection.
The traditional setup before 10gR2, which uses a TCP/Ip protocol to get connected the client to the node.

TCP/IP basically is a state full protocal and should have a certain number of re-tries or time out required, before the client recognizes that node gone down.
Suppose if the time out we set is 600s, the client keep tries to establish a connection. After 600 seconds the client will get an error infor something like below.

Can not resolve the hostname or tns lost contact.

Then only client will fail over to the next available node.

==========

Since this is unacceptable for certain kind of high transaction environments.

So the Oracle comes with a better solution introduced a concept called a VIP.

VIP, A Virtual IP is nothing but another IP which runs on same interface eth0 as your Public IP.

This VIP is available on all nodes like your each node individual. Your listener is aware of both Public IP & vip.

It listens to public IP & VIP. Incase of a fail over the vip of Node-1 shifted to Node# 2.

The trouble is as soon as the VIP shifted to Node# 2, it changes the mac address which is appended of each VIP of the network interfaces.

When you start eth0 vip on Node#1 eth0 of node#1 address will be appended to vip1
When vip1 switches to node2 the mac address of vip1 going to be mac address of the interface card of Node#2, which means a new mac address is initiaed.

This changed mac address is immediately going to ask node#2, something is called re-arg, re-arg is protocol address resolution protocol
It means the node#2 immediately broad cast the new mac address to the all connected client.

All connected clients when they get the notification that the new vip have new mac address, they immediately Marked as invalid all connected sessions.

They imm’ly connected to vip on the other node, but the listener running on other node will not listen to VIP1,
It only listen to the PublicIP and VIP2. Once the vip1 is discarded by the listener running on Node#2, The client
Reads the second VIP address from tnsnames and connects to VIP#2.

THIS WHOLE THING COMPLETED IN 20 secs time

*******************************************************************************************************************************************************
1. Remote Listener Vs Local Listener:
====================================

Let's explain with an example...

suppose we have 2-node cluster: host1 and host2, with VIP address host1-vip and host2-vip respectively.
and one RAC database (orcl) running on this cluster; instace 1 (orcl1) on host1, and instance 2 (orcl2) on host2

we have listener_host1 running on host1, and listener_host2 running on host2.

listener_host1 is considered local listener for orcl1 instance, while listener_host2 is considered remote listener for that same orcl1 instance (because the listener in not running on the same machine as the database instance).

similarly, listener_host2 is considered local listener for orcl2 instance, and considered as remote listener for orcl1.

to make this consideration a real configuration, we configure the 2 parameters local_listener and remote_listener for both instances as below:

orcl1.local_listener=(address of listener_host1)
orcl1.remote_listener=(addresses of both listener_host1 and listener_host2)

orcl2.local_listener=(address of listener_host2)
orcl2.remote_listener=(addresses of both listener_host1 and listener_host2)

(as you see, we can simply use both listeners for the remote listener, as a simple configuration. But of course you could have configured orcl1.remote_listener=(addres of listener_host2) only.)

with such configuration, both listeners in the cluster knows about both instances, and about both hosts (statistics about host load, and instance load). and can make decision about forwarding a client connection request to the other node if it's less loaded. Which is the mechanism behind server-side load balancing.

clients are generally configured with tnsnames with both VIP addresses of the 2 hosts (i.e. can connect to either listener). so if a client attempts the connection to the database with the first IP (which is listener_host1), and suppose host1 is a bit loaded that host2, in such case the listener_host1 knows there is another instance orcl2 running on host2 that's less loaded. in such case, listener_host1 sends a redirect packet to the client asking him to transparently reconnect to listener_host2 to establish the database connection.

without such configuration of remote listener, each listener knows only about the local instance, and have nothing to do but connecting the client to the instance running on the same host as the listener. in such case you have only what's called client-side load balancing.

************************************************************************************************************************************************************8

2. WHAT IS SCAN LISTENER AND HOW IT WORKS IN ORACLE RAC 11GR2 ?

https://rajeevjhaoracle.wordpress.com/2013/11/15/what-is-scan-listener-and-how-it-works-in-oracle-rac-11gr2/


Terminologies:

Let us understand the components related to SCAN individually and then relate them together to understand SCAN in COMPLETE.

SCAN VIP:
==========

SCAN VIP is one of the resources you find in the output of “crsctl status resource –t” command. Number of SCAN VIP’s you notice will be the same as the number of SCAN LISTENERS in the setup.

SCAN VIP’s are physical IP addresses that you allocate to SCAN listeners. In the example that I use later in this blog, 192.168.122.5, 192.168.122.6, 192.168.122.7 are SCAN VIP’s. If you identify that SCAN VIP’s are online in the output of “crsctl status resource –t” command then IP addresses are online on the physical network ports. Only when SCAN VIP’s are online we can start the SCAN listeners.


SCAN LISTENER:
==============

SCAN Listener is the oracle component which starts running a service on the port (by default it’s 1521) using the SCAN VIP (IP address). So SCAN listener doesn’t start if SCAN VIP is not online. This is the major difference between a SCAN listener and SCAN VIP. The number of SCAN listeners you notice in the output will be the same as a number of SCAN VIP’s ONLINE. Name that is given to SCAN LISTENER is referred to as SCAN NAME and it is registered in DNS server. In our example which you will find next, the SCAN name is “SCAN_LISTENER”.

So in short, always SCAN LISTENER and SCAN VIP are related to each other.


SCAN components in a cluster:
SCAN Name
SCAN IPs (3)
SCAN Listeners (3)


Node VIP:
=========

Node VIP is the IP address which has the capability of relocating to the local listener of other nodes when the current node goes down. The drawback of using only node VIP is TNS entry of application server should have all node VIP addresses updated. You can identify the IP address assigned to node VIP will be a part of LOCAL listener. Test it yourself, run “lsnrctl status” on every node and you will find that local listener has two IP addresses – 1 node IP and 2 node VIP.

The challenge of having multiple VIP addresses in TNS entry is addressed in 11gR2 introducing SCAN.

For more information visit: https://www.dbatrainings.com/


3. What is Voting Disk and OCR
************************************************************************************************************************************8

Voting Disk : Voting disk is shared disk that will be accessed by all the members nodes in the cluster. The
voting disk is used as a central reference for all nodes and keeps the heartbeat information between nodes.
If any of node is unable to ping the voting disk, the cluster immediately recognizes the communication
failure and evicts the node from cluster. The voting disk is sometimes called “Quorum device “.

OCR ( Oracle Cluster Registry) :-

OCR is shared storage and it is accessed by all nodes in the cluster. CRS ( Oracle Cluster Ready Services)
uses cluster registry to keep the configuration information. OCR is central repository for the CRS and
keeps the detail of the services and status of the resources.

How do you do Voting disk & OCR backup ?

Voting Disk backup is done using dd command
dd if=/dev/raw/vote01 of=/backup/vote01.bak

OCR Backup :
Oracle automatically takes backup every 4 hrs on master node. You can also take backup using ocrconfig
export utility.


Part 2:


OCR, Voting and OLR files
=========================

Over view:


Oracle Clusterware includes two important components that manage configuration and node membership: Oracle Cluster Registry (OCR), which also includes the local component Oracle Local Registry (OLR), and voting disks.
·       OCR manages Oracle Clusterware and Oracle RAC database configuration information
·       OLR resides on every node in the cluster and manages Oracle Clusterware configuration information for each particular node
·       Voting disks manage information about node membership. Each voting disk must be accessible by all nodes in the cluster for nodes to be members of the cluster
You can store OCR and voting disks on Oracle Automatic Storage Management (Oracle ASM), or a certified cluster file system.



Oracle Universal Installer for Oracle Clusterware 11g release 2 (11.2), does not support the use of raw or block devices. However, if you upgrade from a previous Oracle Clusterware release, then you can continue to use raw or block devices. Oracle recommends that you use Oracle ASM to store OCR and voting disks.Oracle recommends that you configure multiple voting disks during Oracle Clusterware installation to improve availability.


OCR:


OCR contains information about all Oracle resources in the cluster.
Oracle recommends that you configure:
·       At least three OCR locations, if OCR is configured on non-mirrored or non-redundant storage. Oracle strongly recommends that you mirror OCR if the underlying storage is not RAID. Mirroring can help prevent OCR from becoming a single point of failure.
·       At least two OCR locations if OCR is configured on an Oracle ASM disk group. You should configure OCR in two independent disk groups. Typically this is the work area and the recovery area.

*************************************************************************************************************************************

4. Backing Up Oracle Cluster Registry:

Automatic backups:Oracle Clusterware automatically creates OCR backups every four hours, each full day and end of the week. Oracle Database always retains the last three backup copies of OCR.  You cannot customize the backup frequencies or the number of files that Oracle Database retains. This backups will be done by CRSD process.

Manual backups:  Use the following  command on a node to force Oracle Clusterware to perform a backup of OCR at any time.

ocrconfig -manualbackup

 The -manualbackup option is especially useful when you want to obtain a binary backup on demand, such as before you make changes to OCR.

NOTE: The OCRCONFIG executable is located in the $GRID_HOME/bin directory.

OCRCONFIG utility:

Use the following command to display the OCR backup files.

ocrconfig -showbackup

To check manually/auto taken OCR backups saparatly use the flag manual/auto as follow.

ocrconfig –showbackup manual
ocrconfig –showbackup auto

The default location for generating backups on Linux or UNIX systems is $GRID_HOME/cdata/cluster_name, where cluster_name is the name of your cluster.

The OCRCONFIG utility creates a log file in $GRID_HOME/log/host_name/client

OCRCHECK Utility


The OCRCHECK utility displays the version of the OCR's block format, total space available and used space, OCRID, and the OCR locations that you have configured. OCRCHECK performs a block-by-block checksum operation for all of the blocks in all of the OCRs that you have configured. It also returns an individual status for each file and a result for the overall OCR integrity check.

You can only use OCRCHECK when the Oracle Cluster Ready Services stack is ONLINE on all nodes in the cluster.

# ocrcheck

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

Voting Disk:

Voting disks manage information about node membership. Each voting disk must be accessible by all nodes in the cluster for nodes to be members of the cluster.

Storing Voting Disks on Oracle ASM

Oracle ASM manages voting disks differently from other files that it stores. If you choose to store your voting disks in Oracle ASM, then Oracle ASM stores all the voting disks for the cluster in the disk group you choose.
Once you configure voting disks on Oracle ASM, you can only make changes to the voting disks' configuration using the crsctl replace votedisk command. This is true even in cases where there are no working voting disks.

Backing Up Voting Disks

In Oracle Clusterware 11g release 2 (11.2), you no longer have to back up the voting disk. The voting disk data is automatically backed up in OCR as part of any configuration change and is automatically restored to any voting disk added.

Restoring Voting Disks

Run the following command as root from only one node to start the Oracle Clusterware stack in exclusive mode, which does not require voting files to be present or usable:

# crsctl start crs -excl

Run the crsctl query css votedisk  command to retrieve the list of voting files currently defined

crsctl query css votedisk

This list may be empty if all voting disks were corrupted, or may have entries that are marked as status 3 or OFF
If the voting disks are stored in Oracle ASM, then run the following command to migrate the voting disks to the Oracle ASM disk group you specify:

crsctl replace votedisk +asm_disk_group

If you did not store voting disks in Oracle ASM, then run the following command using the File Universal Identifier (FUID) obtained in the previous step:

$ crsctl delete css votedisk FUID

Add a voting disk, as follows:

$ crsctl add css votedisk path_to_voting_disk

Stop the Oracle Clusterware stack as root:

# crsctl stop crs

Restart the Oracle Clusterware stack in normal mode as root:

# crsctl start crs

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

OLR:

In Oracle Clusterware 11g release 2 (11.2), each node in a cluster has a local registry for node-specific resources, called an Oracle Local Registry (OLR), that is installed and configured when Oracle Clusterware installs OCR. It contains manageability information about Oracle Clusterware, including dependencies between various services. Oracle High Availability Services uses this information. OLR is located on local storage on each node in a cluster.

Its default location is in the path $GRID_HOME/cdata/host_name.olr
To Check OLR status on each node using following command.

# ocrcheck -local

If we need to see the contents of the OLR

# ocrdump -local -stdout

To backup OLR manually

# ocrconfig –local –manualbackup

TO see the contents of the backup OLR file

ocrdump -local -backupfile olr_backup_file_name

To change backup location

ocrconfig -local -backuploc new_olr_backup_path

To restore OLR follow the step

# crsctl stop crs

# ocrconfig -local -restore file_name

# ocrcheck -local

# crsctl start crs

$ cluvfy comp olr

************************************************************************************************************************************************************.

5. Oracle RAC: Difference between CRSCTL and SRVCTL

srvctl
=======
Use SRVCTL to manage Oracle supplied resources such as
Listener
Instances
Disk groups
Networks
srvctl is used to manage the elements of the cluster like databases, instances, listeners, services etc.

srvtcl was introduced with Oracle 9i.

If resource name begins with ora then use SRVCTL.

Oracle suggest DBAs to use srvctl command to start the databases.

SRVCTL manages Oracle resource related operations:
Starting and stopping database instances and services
Also from 11gR2 manages the cluster resources like network, vip, disks etc

We can use the SRVCTL to manage configuration information.  Use SRVCTL commands to (add, remove, start, stop, modify, enable, and disable a number of entities, such as Databas ES, instances, listeners, SCAN listeners, services, grid naming Service (GNS), and Oracle ASM.)


crsctl
======
Use CRSCTL for managing Oracle Clusterware and its resources.

crsctl command is used to manage the elements of the clusterware like crs, css, evm.


crsctl was introduced with Oracle 10g.

CRSCTL manages Oracle Clusterware related operations like:
Starting and stopping Oracle Clusterware
Enabling and disabling Oracle Clusterware daemons
Checking the health of the cluster
Registering cluster resources


OCRCHECK:
========

 -- Displays health of OCR (Oracle Cluster Registry) / Oracle Local Registry (OLR).

How do I identify the OCR (or OLR) file location?
# ocrcheck


***************************************************************************************************************

6. What Thread in Rac:

A thread is a set of redo log files. Each instance mounts one thread of redo logs when it starts up. When using RAC, each instance must have its own thread of redo logs.

To map an instance to a different thread, use the THREAD initialization parameter (for example: THREAD = 2).


*****************************************************************************************************************

7. Special init parameters in Oracle RAC

(which are not available in stand alone instance)


instance_number
Oracle Real Application Clusters (RAC) parameter specifies a unique number that maps the instance.

instance_group
This RAC parameter specifies one or more instance groups and assigns the current instance to those groups.

thread
This RAC init parameter specifies the number of the redo thread to be used by an instance.

cluster_database
Oracle Real Application Clusters (RAC) parameter that specifies whether or not Real Application Clusters is enabled

cluster_database_instances
Oracle Real Application Clusters (RAC) parameter that specifies the number of instances that are configured as part of your cluster database.

cluster_interconnects
This RAC parameter provides Oracle with information about additional cluster interconnects available for use in Real Application Clusters environments.

remote_listener
local_listener
parallel_instance
max_commit_propagation_delay

init parameters, in Oracle RAC, with SAME VALUE across all instances
active_instance_count
archive_lag_target
compatible
cluster_database
cluster_database_instances
cluster_interconnects     
control_files
db_block_size
db_domain
db_files
db_name
db_recovery_file_dest
db_recovery_file_dest_size
db_unique_name
dml_locks                     -- when 0
instance_type                -- rdbms or asm
max_commit_propagation_delay
parallel_max_servers
remote_login_password_file
trace_enabled
undo_management

For example,
*.cluster_database=true
*.cluster_database_instances=2
*.compatible='11.2.0.2'
*.undo_management='AUTO'

init parameters, in Oracle RAC, with Unique Values across all instances
instance_number
instance_name
thread
undo_tablespace/rollback_segments

For example,
INST1.instance_number=1
INST1.instance_name=rac1
INST1.thread=1
INST1.undo_tablespace='UNDOTBS1'

INST2.instance_number=2
INST2.instance_name=rac2
INST2.thread=2
INST2.undo_tablespace='UNDOTBS2'

Wednesday, 24 February 2016

Migrate oracle 11.2.0.1.0(Windows 32-bit) TO linux (64-bit);

Migrate oracle 11.2.0.1.0(Windows 32-bit) TO linux (64-bit);

Source: Windows 32-bit

Target Linux 64-bit

Small guide what I am going to do:

Steps:
1. Check platform compatibility between Source and target OS
2. Start the database in read only mode
3. Check database readiness for transport from Windows to Linux using DBMS_TDB.CHECK_DB
4. Check if there are any external objects
5. Execute the RMAN Convert database command
6. Copy Converted datafiles, Generated Script and Pfile to Linux
7. Edit the Pfile for the new database (Linux)
8. Edit the Transport Script and Pfile changing the windows paths to Linux Paths.
9. Execute the Transport Script on Linux
10. Change the DBID
11. Run utlirp.sql and utlrp.sql for recompile all Pl/SQL modules.
12. Verify & Compare the database on Linux

Source:
Step 1:
====

SQL> Select * from v$transportable_platform order by platform_id;

Here both will (Windows and Linux endian format is little only)
Check the Version of database:
SQL> select * from v$version;
SQL> Select * from v$transportable_platform order by platform_id;
Check the Version of database:
SQL> Select * from v$transportable_platform order by platform_id;
Check the Version of database:
SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 – Production

Note: Kindly check it Target server pre-requesite install software only




Step 2:

2. Start the database in read only mode

> shut immediate;
>startup mount;

> alter database open read only;



Step 3:

3. Check database readiness for transport from Windows to Linux using DBMS_TDB.CHECK_DB

Note:
Before converting the database, we have to be make sure that whether a database can be transported to a desired destination platform, and whether the current state of the database permits transport. We check this using "DBMS_TDB.CHECK_DB" procedure.
If this procedure returns "FALSE" then the output includes the reason why the database cannot be transported like target platform has a different endian format, database is not open read-only, there are active transactions in the database, database compatibility version is below 10 etc.

set serveroutput on
declare
db_ready boolean;
begin
db_ready := dbms_tdb.check_db('Linux x86 64-bit');
end;
/
PL/SQL procedure successfully completed.
Note: If database is not open in read-only mode, then the above procedure may return error like Database is not open READ ONLY. Please open database READ ONLY and retry.

Step 4:

Check if there are any external objects:

Note:

If there is any external objects take note of them, they will need to be taken care manually because RMAN cannot automate the transport of such objects. "DBMS_TDB.CHECK_EXTERNAL" must be used to identify any external tables, directories or BFILEs.

set serveroutput on
declare
external boolean;
begin
external := dbms_tdb.check_external;
end;
/

The following directories exist in the database:
SYS.ORACLE_OCM_CONFIG_DIR, SYS.DATA_PUMP_DIR, SYS.XMLDIR

Note:

No need to worry its automatically taking when we start using pfile in Target

Step 5

5. Using the RMAN CONVERT DATABASE:
After all the pre-requisites have been performed successfully, we can use the RMAN CONVERT DATABASE command to generate the output files for the target database. While executing the CONVERT DATABASE command, we need to specify the new database name, the destination platform, path to save the transport script and optionally a path, where to save the output files.
Note: If you omit the "DB_FILE_NAME_CONVERT" clause, the output files are created in

"C:\ORACLE_HOME\database" folder.
C:\>rman target /


CONVERT DATABASE NEW DATABASE 'migra'
transport script 'd:\app\mig\script.sql'
to platform 'Linux x86 64-bit'
db_file_name_convert 'D:\app\kumar\oradata\prod500\' 'D:\app\mig\';

output:

Starting conversion at source at 23-JUL-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=135 device type=DISK

Directory SYS.ORACLE_OCM_CONFIG_DIR found in the database
Directory SYS.DATA_PUMP_DIR found in the database
Directory SYS.XMLDIR found in the database

User SYS with SYSDBA and SYSOPER privilege found in password file
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00001 name=D:\APP\KUMAR\ORADATA\PROD500\SYSTEM01.DBF
converted datafile=D:\APP\TRANS\SYSTEM01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:01:55
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00002 name=D:\APP\KUMAR\ORADATA\PROD500\SYSAUX01.DBF
converted datafile=D:\APP\TRANS\SYSAUX01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00003 name=D:\APP\KUMAR\ORADATA\PROD500\UNDOTBS01.DBF

converted datafile=D:\APP\TRANS\UNDOTBS01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00005 name=D:\APP\KUMAR\ORADATA\PROD500\UNDOTBS02.DBF

converted datafile=D:\APP\TRANS\UNDOTBS02.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00004 name=D:\APP\KUMAR\ORADATA\PROD500\USERS01.DBF
converted datafile=D:\APP\TRANS\USERS01.DBF
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01
Edit init.ora file D:\APP\KUMAR\PRODUCT\11.2.0\DBHOME_1\DATABASE\INIT_00PE587E_1
_0.ORA. This PFILE will be used to create the database on the target platform
Run SQL script D:\APP\TRANS\SCRIPT.SQL on the target platform to create database

To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target plat
form
To change the internal database identifier, use DBNEWID Utility
Finished conversion at source at 23-JUL-14



Note:

I all my converting datafiles,scripts file,exe file will store in this location


=D:\app\mig\

But my Init.ora file store in at $ORACLE_HOME take copy of this file also.

Move this Mig file to Linux server:


Note:

Source completed copy all the move to Window server to linux server

Phase -II – Target server (Linux):


6. Copy Converted Datafiles, Generated Script and Pfile to the Linux Machine:
Now copy these converted datafiles, transport script and Pfile on the Linux server. Do not forget to create necessary folder on linux machine such as adump, bdump, udump, cdump, flash_recovery_area.

Note:
Since we are those parameter in not ther in migrate init.ora parameter

c:/app/mig/ move to Linux /oracle/u01/oradata/


Phase -II – Target server (Linux)

7. Edit init.ora or pfile for new database:
Open the init.ora file generated by RMAN. The first section of pfile must be updated, others are optional. Change all the absolute path of windows environment to absolute path of Linux environment.

Note:
Since we are those parameter in not ther in migrate init.ora parameter
control_files = "/oracle/u01/oradata/mig/CF_D-MIGRA_ID-2500231993_01PEOM3D"

db_recovery_file_dest = "/oracle/u01/oradata/mig/flash_recovery_area"

db_recovery_file_dest_size= 4039114752

audit_file_dest = "/oracle/u01/oradata/mig/ADUMP"

db_name = "MIGRA"

oracle_base = "/oracle/u01/

remote_login_passwordfile= "EXCLUSIVE"

db_domain = ""

dispatchers = "(PROTOCOL=TCP) (SERVICE=migra500XDB)"

__pga_aggregate_target = 318767104



# The values of the following parameters are from source database:

processes = 150

memory_target = 855638016
diagnostic_dest = "/oracle/u01"

Once Completed editing Init.ora file:

8. Edit The Script:
Before running the transport script on the target Linux server we need to edit it to set the correct paths for pfile, datafiles, logfiles and tempfiles. Update all the paths as per your Linux environment.

STARTUP NOMOUNT PFILE='/oracle/u01/oradata/mig/INIT_00PEOM3D_1_0.ORA'
CREATE CONTROLFILE REUSE SET DATABASE "MIGRA" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/oracle/u01/oradata/mig/ARCH_D-MIGRA_ID-2500231993_S-34_T-1_A-850908222_03PEOM3D' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/oracle/u01/oradata/mig/ARCH_D-MIGRA_ID-2500231993_S-32_T-1_A-850908222_04PEOM3D' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/oracle/u01/oradata/mig/ARCH_D-MIGRA_ID-2500231993_S-33_T-1_A-850908222_05PEOM3D' SIZE 50M BLOCKSIZE 512
DATAFILE
'/oracle/u01/oradata/mig/SYSTEM01.DBF',
'/oracle/u01/oradata/mig/SYSAUX01.DBF',
'/oracle/u01/oradata/mig/UNDOTBS01.DBF',
'/oracle/u01/oradata/mig/USERS01.DBF',
'/oracle/u01/oradata/mig/UNDOTBS02.DBF'
CHARACTER SET WE8MSWIN1252
;
9. Execute the Script:

Set Environment:

export PATH=/usr/lib64/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/oradb/bin:/oracle/u01/product/11.2.0/dbhome_1/bin:/oracle/u01/product/11.2.0/dbhome_1/OPatch

export ORACLE_SID=MIGRA
export ORACLE_HOME=/oracle/u01/product/11.2.0/dbhome_1


> sqlplus / as sysdba

>@/oracle/u01/mig/SCRIPT.sql

Crated database

>alter database open resetlogs;


ii) once this completed as per SCRIPT.SQL add temporary tablespace since RMAN
didn;t take covert this temp tablespace.

CREATE TEMPORARY TABLESPACE temp_mig TEMPFILE '/oracle/u01/oradata/mig/temp_mig1.dbf' size 5m;
SIZE 20M REUSE
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 16M;
(or)
SQL> ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/u01/oradate/mig/DATA_D-MIGRA_I-2500231993_TS-TEMP_FNO-1_06PEOM3D'
2 size 5m;
ALTER TABLESPACE TEMP ADD TEMPFILE '/oracle/u01/oradate/mig/DATA_D-MIGRA_I-2500231993_TS-TEMP_FNO-1_06PEOM3D'
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]
ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]

Cause:


There no temp file and sql statement not getting executed,
since this problem for packege file so we have to run = utlirp.sql


solve:
=====

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup upgrade pfile='/oracle/u01/oradata/mig/INIT_00PEOM3D_1_0.ORA';
ORACLE instance started.

Total System Global Area 851808256 bytes
Fixed Size 2218112 bytes
Variable Size 641730432 bytes
Database Buffers 201326592 bytes
Redo Buffers 6533120 bytes
Database mounted.
Database opened.
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
READ WRITE

SQL> select logins from v$instance;

LOGINS
----------
RESTRICTED

SQL> select status from v$instance;

STATUS
------------
OPEN MIGRATE

>@$ORACLE_HOME/rdbms/admin/utlirp.sql

Once comeplete


Once its completed create temporary tablespace since I am going to run utlrp.sql so
that time should need temp tablespace.

CREATE TEMPORARY TABLESPACE temp_mig TEMPFILE '/oracle/u01/oradata/mig/temp_mig1.dbf' size 5m;
SIZE 20M REUSE
EXTENT MANAGEMENT LOCAL UNIFORM SIZE 16M;


iii) Run utlrp.sql for compile invalid object:

> shut immediate
>startup pfile='/oracle/u01/oradata/mig/INIT_00PEOM3D_1_0.ORA';
>@$ORACLE_HOME/rdbms/admin/utlrp.sql

Error:
====

RROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 6923
Session ID: 201 Serial number: 165

ERROR:
ORA-03114: not connected to ORACLE

Chacking alert.log file need to extend temporay tablespace

solve:

Add new datafile in the temporary tablespace


iv) Error:
======

> shut immediate;

ORA-24324: service handle not initialized
ORA-01041: internal error. hostdef extension doesn't exist

solution:

Creating Tnsname.ora entry

MIGRA =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dev186.chainsys.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = migra)
)
)

cross-check:

]$tnsping migra
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = dev186.chainsys.com)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = migra)))
OK (10 msec)

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

What is UTLIRP.SQL ?
This is a SQL script which first Invalidates & then recompiles PL/SQL modules viz.,
procedures, functions, packages, types, triggers, views in a database
This script expects standard.sql, dbmsstdx.sql files to be available in the current directory.
There should be no other DDL on the database while running the script.

Note: mostly this run it at database in upgrade mode only, only migration time or cross-platform time we run this one.

+ What UTLIRP.SQL does?
The utlirp.sql script recompiles existing PL/SQL modules in the FORMAT required
by the NEW DATABASE with the below steps:
=======================================

SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production


SQL> select * From dba_directories;

OWNER DIRECTORY_NAME
------------------------------ ------------------------------
DIRECTORY_PATH
--------------------------------------------------------------------------------
SYS ORACLE_OCM_CONFIG_DIR
D:\app\kumar\product\11.2.0\dbhome_1\ccr\state

SYS DATA_PUMP_DIR
D:\app\kumar\admin\prod500\dpdump\

SYS XMLDIR
c:\ade\aime_dadvfm0254\oracle\rdbms\xml


SQL> select tablespace_name from dba_tablespaces;

TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
TEMP_MIG

6 rows selected.

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
/oracle/u01/oradata/mig/UNDOTBS02.DBF
/oracle/u01/oradata/mig/USERS01.DBF
/oracle/u01/oradata/mig/UNDOTBS01.DBF
/oracle/u01/oradata/mig/SYSAUX01.DBF
/oracle/u01/oradata/mig/SYSTEM01.DBF

SQL> SELECT COMP_NAME,STATUS FROM DBA_REGISTRY;


Successfully Migration Done :



Thanks & Regards

Kumaresan Nethaji


Follow Document:



Youtube.com--> converting oracle database windows to Linux

Thursday, 18 February 2016

Tuning PGA memory


Tuning PGA Memory – Oracle database 10g
--------------------------------------------------


Correct size of PGA
====================

You can get the correct size of PGA using V$PGA_TARGET_ADVICE, dynamic performance view.


 SELECT ROUND(pga_target_for_estimate/1024/1024) target_mb,
 estd_pga_cache_hit_percentage cache_hit_perc,
 estd_overalloc_count
 FROM V$PGA_TARGET_ADVICE;



Checking PGA for each sessions:
================================

You can check session level PGA using V$SESSTAT and V$SESSION view and also you can check the username, who is using

that memory.

 SELECT
s.value,s.sid,a.username
FROM
V$SESSTAT S, V$STATNAME N, V$SESSION A
WHERE
n.STATISTIC# = s.STATISTIC# and
name = 'session pga memory'
AND s.sid=a.sid
ORDER BY s.value;



To check the total PGA in use and hit ratio for PGA:
==================================================

SQL> SELECT * FROM V$PGASTAT;


The ideal way to perform sorts is by doing the entire job in memory. A sort job that Oracle performs entirely in memory

is said to be an optimal sort. If you set the PGA_AGGREGATE_TARGET too low, some of the sort data is written out

directly to disk (temporary tablespace) because the sorts are too large to fit in memory. If only part of a sort job

spills over to disk, it’s called a 1-pass sort. If the instance performs most of the sort on disk instead of in memory,

the response time will be high. This is called multi pass sort.

Another method of checking the efficiency of PGA memory is to check V$SQL_WORKAREA_HISTOGRAM.

V$SQL_WORKAREA_HISTOGRAM displays the cumulative work area execution statistics (cumulated since instance startup) for

different work area groups. The work areas are split into 33 groups based on their optimal memory requirements with the

requirements increasing in powers of two. That is, work areas whose optimal requirement varies from 0 KB to 1 KB, 1 KB

to 2 KB, 2 KB to 4 KB, … and 2 TB to 4 TB.

For each work area group, the V$SQL_WORKAREA_HISTOGRAM view shows how many work areas in that group were able to run in

optimal mode, how many were able to run in one-pass mode, and finally how many ran in multi-pass mode. The DBA can take

a snapshot at the beginning and the end of a desired time interval to derive the same statistics for that interval.


SELECT
low_optimal_size/1024 “Low (K)”,
(high_optimal_size + 1)/1024 “High (K)”,
optimal_executions “Optimal”,
onepass_executions “1-Pass”,
multipasses_executions “>1 Pass”
FROM v$sql_workarea_histogram
WHERE total_executions <> 0;




You can check the proportion of work areas since you started the Oracle instance, using optimal, 1-pass, and multipass

PGA memory sizes.


SELECT name PROFILE, cnt COUNT,
DECODE(total, 0, 0, ROUND(cnt*100/total)) PERCENTAGE
FROM (SELECT name, value cnt, (sum(value) over ()) total
FROM V$SYSSTAT
WHERE name like 'workarea exec%');


PROFILE COUNT PERCENTAGE
————————————————– ———- ———-
workarea executions – optimal 6650608 100
workarea executions – onepass 2 0
workarea executions – multipass 0 0

Since almost all the sorting and temporary operation are carried out inder optimal catagory we can conclude that out

PGA is sized correctly.


Thursday, 11 February 2016

shall script oracle R12

schedule scripts:

1 ) Rman daily backup;


0 04 * * * sh /home/oracle/scripts/rman_script/rman__db.sh



====


. ~/.bash_profile

find /backup/PROD_DB_BACKUP/DB -mtime +2 -type f -exec rm {} \;

export NLS_DATE_FORMAT='DD-MON-YYYY HH24:MI:SS'
LOG=/backup/WEPPROD_DB_BACKUP/LOGS/rmanPROD`date +%d.%m.%Y_%T`.log
rman  target / LOG = $LOG <<EOF
run {
crosscheck backup;
delete force  noprompt obsolete;
allocate channel t1 device type disk;
allocate channel t2 device type disk;
allocate channel t3 device type disk;
allocate channel t4 device type disk;
allocate channel t5 device type disk;
allocate channel t6 device type disk;
allocate channel t7 device type disk;
allocate channel t8 device type disk;
backup as COMPRESSED BACKUPSET
     format '/backup/_DB_BACKUP/DB/%d_%t_%s_%p'
        tag 'dbmain_full_backup' database;
SQL 'alter system archive log current';
crosscheck archivelog all;
backup as compressed backupset archivelog all format '/backup/DB_BACKUP/DB/%d_Arch_Log%t_%s_%p';
    backup
    tag = cf1
   format '/backup/_BACKUP/DB/%d_CONTROL_%t_%s_%p' current controlfile;
release channel t1;
release channel t2;
release channel t3;
release channel t4;
release channel t5;
release channel t6;
release channel t7;
release channel t8;
}
EOF

CAP=`echo $ORACLE_SID|tr '[a-z]' '[A-Z]'`
#MAIL_ID="gopinath.k@jin,beniston.thangaraj@jsw.in,venkat.p@wepsol.in,wep.dba@jsw.in"
MAIL_ID="Oracle.Alert@wepinam.s@.in,ajaykumar.ch@.in,Hari.Krishna@@"

#tail -10 $LOG | grep ^"RMAN-"

#cat $LOG | grep ^"RMAN-"|grep ^"ORA-"
tail -30 $LOG | grep ^"RMAN-"

if [ $? -ne 0 ]
then
mail -s "Rman Backup Successful of $CAP on `date`"   $MAIL_ID < $LOG
else
mail -s "Rman Backup Failed of $CAP on `date`" $MAIL_ID <$LOG
fi



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



2 ) Per day how much archive log files will generating in Production instance:
--------------------------------------------------------------------------

0 07 * * * sh /home/oracle/scripts/cron_scripts/sql/log_per_day.sh



[oracle@dbwep ~]$ more /home/oracle/scripts/cron_scripts/sql/log_per_day.sh

. /oracle/WEPPROD/db/tech_st/10.2.0/_connect.env
#rm /tmp/archive.html
sqlplus system/manager @/home/oracle/scripts/cron_scripts/sql/log_per_day.sql << EOF
exit
EOF
mail -s "WEPPROD Archives Generated Report"Oracle.Alert@gmail.com, <

/tmp/archive.lst


Base on "log_per_day.sh" will generating and given the out put.-----


set pagesize 200
set linesize 100

col d_dt for a10
col DATE new_value ye_date
col db_name new_value SID
!rm /tmp/archive.lst
--spool /tmp/archive.lst
--select sysdate-1 as yest_date from dual;
select name db_name from v$database;
--!rm /tmp/archive.lst
---set markup html on
spool /tmp/archive.lst
--TTITLE CENTER 'ye_date'
--TTITLE LEFT 'Archives Generated for 'SID ' on ' ye_date
TTITLE LEFT 'Database Name - ' SID


SELECT Start_Date,
       Start_Time,
       Num_Logs
----   ROUND(Num_Logs * (Vl.Bytes / (1024 * 1024)),
    -- 2) AS Mbytes
      -- Vdb.NAME AS Dbname
  FROM (SELECT TO_CHAR(Vlh.First_Time,
                       'YYYY-MM-DD') AS Start_Date,
               TO_CHAR(Vlh.First_Time,
                       'HH24') || ':00' AS Start_Time,
               COUNT(Vlh.THREAD#) Num_Logs
          FROM V$log_History Vlh WHERE TRUNC(vlh.first_time) =  TRUNC(SYSDATE-1)
         GROUP BY TO_CHAR(Vlh.First_Time,
                          'YYYY-MM-DD'),
                  TO_CHAR(Vlh.First_Time,
         'HH24') || ':00') Log_Hist,
       V$log Vl,
       V$database Vdb
 WHERE Vl.GROUP# = 1
  ORDER BY Log_Hist.Start_Date,
        Log_Hist.Start_Time;

TTITLE off
clear col
undefine SID
undefine ye_date
--set markup html off
spool off

You have new mail in /var/spool/mail/oracle


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


3) :- Inactive session sechdule-program;
----------------------------------------

0 9,14,18 * * * sh /home/oracle/scripts/cron_scripts/shell/inactwep.sh




#!/bin/ksh
. /oracle/WEPPROD/db/tech_st/12.1.0/WEPPROD_dbwep.env
home_dir=`echo /home/oracle/scripts/cron_scripts` ; export home_dir
shell_dir=`echo $home_dir/shell/` ; export shell_dir
sql_dir=`echo $home_dir/sql/` ; export sql_dir
out_dir=`echo $home_dir/Logs/` ; export out_dir
v_date=`date +"%Y%m%d%H:%M"`
LOGFILE=/tmp/inactive_$1.log.$v_date; export LOGFILE
FILE=/tmp/inactive.lst
dba_list="Oracle.Alert@gmail.com,

ol.in,"
#dba_list="valliappan.ramanathan@gmail,afsal.mohammed@gmail.cpm"

apps_user=apps
apps_pwd=wep2dba
db_connect="$apps_user/$apps_pwd@prod"

if [ -f $FILE ]
then
        echo "File exists"
        rm $FILE
fi

run_spr=`sqlplus -s $db_connect @$sql_dir/inactwep.sql << EOF
exit
EOF`
echo $?
echo $run_spr
if [ $? -ne 0 ]
  then
     echo "problems with sqlplus" >> $LOGFILE
  else
     echo ' '
if [ -f $FILE ]
        then
                mail -s "Inactive session .......${v_date}" $dba_list < /tmp/inactive.lst
        else
                echo "" > /dev/null
        fi
fi



ii) scripts:

spool /tmp/inactive.lst


 SELECT
 s.sid,
 s.serial#,
 s.machine,
 to_char(s.logon_time,'mm-dd-yy hh24:mi:ss') Logon_Time,
 s.last_call_et/7200 Last_Call_ET,
 s.action,
 s.module
 FROM
        V$SESSION s,v$PROCESS p
        WHERE s.paddr = p.addr AND
        s.username IS NOT NULL AND
        s.last_call_et/7200 > 1 and
        s.status='INACTIVE' and
        s.module not like 'JDBC%'
        order by logon_time
/
spool off




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

4: -

All concurrent Program schedule crontab -l:
-----------------------------------------

0 07 * * * sh /home/oracle/scripts/cron_scripts/shell/run_it.sh Prod 2>&1 >/dev/null





#!/bin/ksh
#set -x
#dba_list="wep.dba@gmailcom"
dba_list="Oracle.Alert@gmail.com"
ORACLE_HOME=/oracle//db/tech_st/12.1.0;export ORACLE_HOME
PATH=$PATH:/usr/openwin/bin:/usr/local/bin:$ORACLE_HOME/bin:.;export PATH

ORACLE_SID=PROD;export ORACLE_SID
ORAENV_ASK=NO; export ORAENV_ASK
#. oraenv

home_dir=`echo /home/oracle/scripts/cron_scripts` ; export home_dir
shell_dir=`echo $home_dir/shell/` ; export shell_dir
sql_dir=`echo $home_dir/sql/` ; export sql_dir
out_dir=`echo $home_dir/Logs/` ; export out_dir
v_date=`date +"%Y%m%d%H:%M"`
LOGFILE=/tmp/run_it_$1.log.$v_date; export LOGFILE

. /oracle/PROD/db/tech_st/12.1.0/PROD_dbwep.env

   apps_user=apps
   apps_pwd=apps
db_connect="$apps_user/$apps_pwd@$1"

run_spr=`sqlplus -s $db_connect @/home/oracle/scripts/cron_scripts/sql/daily.sql $1 << EOF
exit
EOF`

  if [ $? -ne 0 ]
  then
     echo "problems with sqlplus"
  else
     echo ' '
     echo $out_dir
     if [ -s  $out_dir\Daily_run_$1.txt ]
     then
               echo "Sending E-mail for $1 Production report ...."
               mail -s "$1 Production Status Report" $dba_list < $out_dir/Daily_run_$1.txt
     else
       echo "no report exists"
     fi
  fi






ii) Base above shall scripts call this sql scripts =" daily.sql".


set trimspool on
set feedback off
set term off
set verify off

spool /home/oracle/scripts/cron_scripts/Logs/Daily_run_&&1..txt

rem start /home/oracle/scripts/cron_scripts/sql/cnt_requests.sql
start /home/oracle/scripts/cron_scripts/sql/cnt_req_users.sql
start /home/oracle/scripts/cron_scripts/sql/max_run_programs.sql
start /home/oracle/scripts/cron_scripts/sql/top_running_jobs.sql
start /home/oracle/scripts/cron_scripts/sql/conc_req_error_rpt.sql
start /home/oracle/scripts/cron_scripts/sql/pend_dtl.sql &&1

exit


iii)

 more /home/oracle/scripts/cron_scripts/sql/cnt_requests.sql    --> scripts


set lines 120
set pages 0
col cnt format 999999 heading "Total No of Requests"
--- ttitle 'Number of Concurrent Requests ' skip 2
select '                         Number of Concurrent Requests for ', sysdate - 1 from dual ;

set pages 900
 select  count(*) cnt
 from fnd_concurrent_requests
 where trunc(actual_start_date) = trunc(sysdate) -1
/






iv) start /home/oracle/scripts/cron_scripts/sql/cnt_req_users.sql

select fcr.cnt "Conc Reqs", icxs.self_serv_user_count "SelfServ Users", icxs.self_serv_session_count "SelfServ

Sessions", fl.forms_user_count "Forms Users", fl.forms_se
ssion_count "Forms Sessions"
from icx.icx_sessions icxs, fnd_concurrent_requests fl
(select count(distinct user_id) self_serv_user_count, count(*) self_serv_session_count from icx.icx_sessions where

trunc(creation_date) = trunc(sysdate-1)) icxs,
(select count(distinct user_id) forms_user_count,count(*) forms_session_count from applsys.fnd_logins where trunc

(start_time)=trunc(sysdate-1)) fl,
(select count(*) cnt from fnd_concurrent_requests where trunc(actual_start_date) = trunc(sysdate-1) ) fcr
/

v) /home/oracle/scripts/cron_scripts/sql/max_run_programs.sql


set lines 120
set pages 900
col program format a70
col cnt format 999999 heading "Number of Runs"
ttitle 'Programs that ran for more than 20 times ' skip 2
 select  substr(user_concurrent_program_name,1,70) program, count(*) cnt
 from fnd_conc_req_summary_v
 where trunc(actual_start_date) = trunc(sysdate) -1
 group by substr(user_concurrent_program_name,1,70)
having count(*) > 20
order by 2
/


vi) start /home/oracle/scripts/cron_scripts/sql/top_running_jobs.sql

ttitle 'Concurrent Requests which has more than 30 minutes of execution time' skip 2

SELECT a.request_id,
       substr(user_concurrent_program_name,1,50) name,
       to_char(actual_start_date,'DD-MON-YY HH24:MI') st_dt,
       to_char(actual_completion_date,'HH24:MI') end_tm,
trunc(((actual_completion_date-actual_start_date)*24*60*60)/60)+(((actual_completion_date-actual_start_date)

*24*60*60)-(trunc(((actual_completion_date-actual_start_date
)*24*60*60)/60)*60))/100 exe_time,
       requestor,
       decode(a.status_code,'E','Error','X','Terminated','Normal') status_code
FROM apps.fnd_conc_req_summary_v a
WHERE actual_start_date >= decode(to_char(sysdate,'DAY'),'MONDAY',trunc(sysdate)-3 ,
                                        'SUNDAY',trunc(sysdate)-2,
                                        trunc(sysdate-1))
AND nvl(actual_completion_date,sysdate) - actual_start_date >= 30/24/60
ORDER BY actual_start_date, name
;


vii) /home/oracle/scripts/cron_scripts/sql/conc_req_error_rpt.sql => what concurrent program completed with Error:


ttitle 'Concurrent Requests that Completed in Error ' skip 2
SELECT a.request_id request_id,
       substr(a.user_concurrent_program_name,1,50) name,
       to_char(a.actual_start_date,'HH24:MI') st_time,
       to_char(a.actual_completion_date,'HH24:MI') end_time,
       requestor ,
       decode(a.phase_code,'R','Running','P','Inactive','C','Completed',
              a.phase_code) phase_code,
       decode(a.status_code,'E','Error',   'C','Normal','X','Terminated', 'Q','On Hold', 'D','Cancelled',

'G','Warning',
        'R','Normal',  'W', 'Paused', a.status_code) status_code
FROM apps.fnd_conc_req_summary_v a
WHERE  trunc(actual_completion_date) = trunc(sysdate - 1)
AND a.status_code in ('E','X','D')
ORDER BY actual_start_date;



viii) /home/oracle/scripts/cron_scripts/sql/pend_dtl.sql

ttitle center 'Scheduled Requests in &&1 Production' skip 2

select fcr.request_id,
       substr(decode(fcp.user_concurrent_program_name,'Report Set',fcp.user_concurrent_program_name || ' ' ||

fcr.description,fcp.user_concurrent_program_name),1,47) co
nc_prog_name,
       fu.user_name requestor,
       decode(fcr.phase_code,'R','Running','P',decode(fcr.hold_flag,'Y','Inactive','Pending'),'C','Completed',

fcr.phase_code) phase_code,
       decode(fcr.status_code,'E','Error',   'C','Normal',    'X','Terminated',
                            'Q',decode(fcr.hold_flag,'Y','On Hold',decode(sign(fcr.requested_start_date-

sysdate),1,'Scheduled','Standby')), 'D','Cancelled', 'G','Warnin
g',
                            'R','Normal',  'W', 'Paused','T','Terminating',
                            'R','Normal',  'W', 'Paused','T','Terminating',
                            'I','Scheduled',
                            fcr.status_code) status_code,
       to_char(fcr.requested_start_date,'DD-MON-YYYY HH24:MI:SS') req_start_dt
from
     apps.fnd_user fu,
     apps.fnd_concurrent_programs_vl fcp,
     apps.fnd_concurrent_requests fcr
where fcp.concurrent_program_id = fcr.concurrent_program_id
 and fcr.status_code in ('Q', 'I')
 and fcr.phase_code = 'P'
and fcr.requested_by = fu.user_id
order by 1
;
ttitle off


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

5> alertlog.Error monitoringS:
------------------------------

*/2 * * * * sh /home/oracle/ora_alert.sh  


#!/bin/sh

set -x
. ~/.bash_profile
SID="`echo $ORACLE_SID`"
MAIL_ID="Oracle.Alert@wepindia.com"

#/orahome/oracle/product/TJTG/db/tech_st/10.2.0/admin/TJTG_tjtgb001/bdump
cd /oracle/PROD/db/tech_st/12.1.0/admin/PROD_dbwep/diag/rdbms/wepprod/PROD/trace

LAST="`cat /tmp/last`"
CUR="`cat alert_$SID.log | wc -l`"

DIFF="`expr $CUR - $LAST`"

sed -ne "${LAST},${CUR}p"  alert_$SID.log | grep '^ORA'|grep -v '^ORACLE'  > /tmp/file
#grep -A$DIFF alert_$SID.log | grep ^ORA  > /tmp/file
#sed -n '`cat /tmp/last`,`cat alert_$SID.log` p' alert_$SID.log | grep '^ORA'  > /tmp/file
#awk 'NR >= "`echo $LAST`" && NR <= "`echo $CUR`"' alert_$SID.log | grep '^ORA' > /tmp/file

if [ -f /tmp/file ] && [ `ls -lrt /tmp/file  | awk '{print $5}'` -gt 0 ]
then
echo "ORA Error exists in alert log of $SID" > /tmp/report
echo "------------------------------------------------------------------" >> /tmp/report
cat /tmp/file  >> /tmp/report

mail -s "ORA Error Alert on $SID at `date`" $MAIL_ID < /tmp/report

#echo $CUR > /tmp/last

fi
echo $CUR > /tmp/last


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