Posts

Showing posts from October, 2012

Oracle EBS Patch Tips

What We Mean By Patch ?

Is Program designed to fix some Bugs Or Particular problem .


types of file in patch
cxxxx.drvthe ‘c’ or copy driver dxxxx.drvthe ‘d’ or ‘database’ driver gxxxx.drvthe ‘g’ or ‘generate’ driver-form rep chart jxxxx.zip jar file
Applying Patch On EBS ?

-Go to Patch Directory , Unzip .
-inside patch Directory , you find Patch.DRV
-After Run Apps-.evn run adpatch
-answer on the question .
-On Some where in the question , you will be asked to apply patch name which is .DRV


Note : You Need to Enable Maintenance Mode using adadmin .


You will find Topics in Details on my blog talking about how to use adadmin and Adpatch .

Thank you
Osama Mustafa

Oracle Default Users

When you are creating Database , By Default there's Users Created In Installation Phase , Check Them :

SYSThe SYS user owns all base tables and user-accessable view of the data dictionary (Oracle configuration information). No Oracle user should ever alter (update, delete, or insert) any rows or schema objects conatained in the SYS schema, because such activity can compromise data integrety. The security administrator must keep strict control of this central account. SYSTEMThe SYSTEM user is used to create additional tables and views that display administrative information, and internal tables and views used by various Oracle options and tools. SYSMANThe SYSMAN user represents the Enterprise Manager super admin account. This EM admin can create and modify other EM admin accounts as well as admin the database instance itself.DBSNMPThe DBSNMP user is used by EM to monitor the database. EM uses this account to access performance stats about the database. The DBSNMP cr…

Find blocking sessions In Oracle

You can query the gv$lock and gv$session views to locate a blocking session in RAC.

Miladin Modrakovic offers this script to detect and kill RAC blocking sessions, using  GV$Session and GV$Lock.

 CREATE OR REPLACE PROCEDURE kill_blocker
AS
   sqlstmt   VARCHAR2 (1000);
BEGIN
   FOR x IN (SELECT gvh.SID sessid, gvs.serial# serial,
                    gvh.inst_id instance_id
               FROM gv$lock gvh, gv$lock gvw, gv$session gvs
              WHERE (gvh.id1, gvh.id2) IN (SELECT id1, id2
                                             FROM gv$lock
                                            WHERE request = 0
                                           INTERSECT
                                           SELECT id1, id2
                                             FROM gv$lock
                                            WHERE lmode = 0)
                AND gvh.id1 = gvw.id1
                AND gvh.id2 = gvw.id2
                AND gvh.request = 0
                AND gvw.lmode = 0
                AND …

Redhat virtualization (KVM)

I am So Proud Today to write this topic , after 14 Hours Of continuous working . I Enabled Virtualization On Redhat , Its was challenging to me ,  I feel for moment its impossible to enable it .

But After finishing KVM installation and see everything is working fine i knew its deserve every moments . I believe in what they say now " Never Give Up " . I posting this article today for the people who wants to learn something new. And if you face any problem you can contact me here, I Wrote this because there's no much information about the package that you should install while you are working on Virtualization But Hope you will find this useful.


you can install the package from Redhat Media , some Package will Generate what called Package Dependency , You will start searching for missing Package on media with same name as appear to you . its waste of time , i will post under this topic the most important package that you need to install to avoid this error. 
Some Other Inf…

ORA-01502: index '%' or partition of such index is in unusable state

To Solve this error you could use more than one solution :

Solution One :

declare
begin
   for index_rec in (select owner, index_name
                     from dba_INDEXES
                     where status = 'UNUSABLE')
   loop                    
      execute immediate 'alter index ' || index_rec.owner || '.' ||
          index_rec.index_name || ' rebuild';
   end loop;
end;
Solution two:

10g and above :
alter system set skip_unusable_indexes=true;  thank you
Osama mustafa

Find which User are Running SQL Query

I will post this script here , and you can download it also :

SELECT SUBSTR(SS.USERNAME,1,8) USERNAME, SS.OSUSER "USER", AR.MODULE || ' @ ' || SS.machine CLIENT, SS.PROCESS PID, TO_CHAR(AR.LAST_LOAD_TIME, 'DD-Mon HH24:MM:SS') LOAD_TIME, AR.DISK_READS DISK_READS, AR.BUFFER_GETS BUFFER_GETS, SUBSTR(SS.LOCKWAIT,1,10) LOCKWAIT, W.EVENT EVENT, SS.status, AR.SQL_fullTEXT SQL FROM V$SESSION_WAIT W, V$SQLAREA AR, V$SESSION SS, v$timer T WHERE SS.SQL_ADDRESS = AR.ADDRESS AND SS.SQL_HASH_VALUE = AR.HASH_VALUE AND SS.SID = w.SID (+) AND ss.STATUS = 'ACTIVE' AND W.EVENT != 'client message' ORDER BY SS.LOCKWAIT ASC, SS.USERNAME, AR.DISK_READS DESC
To Download the Script Press Here


Thank you
Osama Mustafa

check character set in Oracle

Simple Topic just to people who asked before why NLS_CHARACTER SET Not appearing in my V$PARAMETER View :


Just Use two Below Query Depend on your version 

SQL> select value from nls_database_parameters where parameter = 'NLS_CHARACTERSET' ;VALUE ---------------------------------------- AR8MSWIN1256Check the National Character set :SQL> select value from nls_database_parameters where parameter = 'NLS_NCHAR_CHARACTERSET' ;
 Or you can Use :

SELECT value$ FROM sys.props$ WHERE name = 'NLS_CHARACTERSET' ;

Thank you
Osama Mustafa

Oracle Performance - Statspack

I mention before in my blog how to Generate AWR Reports But now How to Generate Statpack and how to use it !!!!


enable Statpack :

By default Statpack is disable to enable it do the following

1- Create tablespace with size at least 200MB
2-@?/rdbms/admin/spcreate

Disable it 

@?/rdbms/admin/spdropStatpack works on snapshot you can do the following with oracle snap shot :Generate Snapshot :exec statspack.snap;Orexec statspack.snap(i_snap_level => 10, i_modify_parameter => 'true'); Levels Description :Level 0 - This level captures general statistics, including rollback segment, row cache, SGA, system events, background events, session events, system statistics, wait statistics, lock statistics, and Latch information. Level 5 - This level includes capturing high resource usage SQL Statements, along with all data captured by lower levels. Level 6 - This level includes capturing SQL plan and SQL plan usage information for high resource usage SQL Statements, along with all …

AWR Reports Vs ASH Reports

Sometimes when you face performance issue On your database, Usually first thing you are doing is Generate One of the above reports . But What is the benefits of these reports ? What is the difference ? When Can i use them ?


Let Start

I share in my blog earlier how to generate AWR reports . But Today we are talking About another topic .

Automatic Workload Repository Reports/(AWR):

this report appear in 10g Database, I heard that some people said "AWR used Instead Of Statpack" !! NO AWR is higher Version of statpack , statpack still exists but you have to enable it.

The AWR takes a snap shot of the database in specified intervals (default is one hour) and stores in Sysaux tablespace. and you can change this interval using the following :

BEGIN DBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings( retention => 43200, -- Minutes (= 30 Days). Current value retained if NULL. interval => 30); -- Minutes. Current value retained if NULL. END; /
The snap …

Linux Command For DBA

Enable SSH in Linux: -
#chkconfig --list sshd
#chkconfig --levels 2345 sshd on

to find a file in a directory:-
$ find (directory_path) -name (file_name)

to find a value in a vi editor:-
in vi editor [esc] & :/(find_value)

to delete a value in a vi editor:-
in vi editor [esc] & :%s /delete_value

to delete contents in a file:-
in vi editor [esc] & :/%d

to replace a value in a vi editor:-
in vi editor [esc] & :%s /search_value/replace_value

to see the size of a file (or) directory:-
$du -csh (file or directory name)

to count the files & directories in a directory:-
$ls -l |wc -l

to count the files in a directory:-
$find . -type f |wc -l

to count the directries in a directory:-
$find . -type d |wc -l

to see the file-system in linux:-
$file /sbin/init
(or)
$getconf LONG_BIT

How to mount Windows shared folder in Linux: -
$mount.cifs //IPAddrss/share_folder_name/ /mnt -o user=username


Thank you 
Osama Mustafa

Patchest Number For Database

This is Some useful number for Database patches , you can download them from http://support.oracle.com

9.2.0.4 = 3095277
9.2.0.5 = 3501955
9.2.0.6 = 3948480
9.2.0.7 = 4163445
9.2.0.8 = 4547809(9i Final)
10.1.0.3 = 3761843
10.1.0.4 = 4163362
10.1.0.5 = 4505133
10.2.0.2 = 4547817
10.2.0.3 = 5337014
10.2.0.4 = 6810189

Thank you
Osama Mustafa

Oracle Critical Patch Update Advisory - October 2012

A Critical Patch Update (CPU) is a collection of patches for multiple security vulnerabilities. Critical Patch Update patches are usually cumulative but each advisory describes only the security fixes added since the previous Critical Patch Update advisory. Thus, prior Critical Patch Update advisories should be reviewed for information regarding earlier published security fixes.


Follow : Oracle Patch


Thank you
Osama Mustafa

Moving Schema to another Tablespace using "move" command.

Step One: Create New  tablespace

SQL>Create tablespace datafile ‘\osama.dbf’ size 1G;

Step Two : Check User On which Tablespace


SQL> select owner, tablespace_name from dba_tables where owner='' Step three:Create Script 

sqlplus / as sysdba
spool osama.log



SQL> select 'alter table ' || table_name || ' move tablespace mytab ;' from dba_tables where owner='' ; Spool off ; Step Four : Move Index
SQL> select 'Alter index ' || index_name || ' rebuild tablespace mytab ;' from dba_indexes where owner='' ; Step Five : Check Again

SQL> select owner, tablespace_name from dba_tables where owner=''; Thank you  Osama mustafa

DBID without Select OR RMAN

You can retive database id without Using v$view this way is useful when you losing your control file or data file and you need to know your DBID :


connect / as sysdba SQL> startup nomount;SQL> alter system dump datafile '/home/oracle/app/oracle/oradata/orcl/system01.dbf' block min 1 block max 2;   System altered.   tail -f /home/oracle/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_10680.trc ... Start dump data block from file /home/oracle/app/oracle/oradata/orcl/system01.dbf minblk 1 maxblk 2 V10 STYLE FILE HEADER: Compatibility Vsn = 186646528=0xb200000 Db ID=1229390655=0x4947033f, Db Name='ORCL' ...SQL> alter system dump datafile '/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf' block min 1 block max 2;   System altered.   tail -f /home/oracle/app/oracle/diag/rdbms/orcl/orcl/trace/orcl_ora_10680.trc ... Start dump data block from file /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf minblk 1 maxblk 2 V10 STYLE FILE HEADER: …

find the time of the last DDL statement that has been applied on a table.

SELECT object_name, object_type, last_ddl_time   FROM dba_objects (or all_objects)WHERE owner =<<owner oftable>>AND object_name ='MY_TABLE'

Thank you
Osama mustafa

DDL With the WAIT Option

The DDL_LOCK_TIMEOUT parameter indicates the number of seconds a DDL command should wait for the locks to become available before throwing the resource busy error message


For Example :

CREATE TABLE lock_tab (id NUMBER);INSERT INTO lock_tab VALUES (1);ALTER SESSION SET ddl_lock_timeout=30;ALTER TABLE lock_tab ADD (description VARCHAR2(50)); ALTER TABLE lock_tab ADD ( * ERROR at line 1: ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired  Ref :
Oracle_base


Thank you
Osama mustafa

Create Backup to another Location

run {
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT '/u01/Rman/%U';
ALLOCATE CHANNEL disk2 DEVICE TYPE DISK FORMAT '/u02/Rman/%U';
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'u02/rman/%F';
backup incremental level 0 database;
release channel disk1;
release channel disk2;

sql 'alter system archive log current';
ALLOCATE CHANNEL disk1 DEVICE TYPE DISK FORMAT '/u01/Rman/LOG_%t_%s_%p_%U';
ALLOCATE CHANNEL disk2 DEVICE TYPE DISK FORMAT '/u02/Rman/LOG_%t_%s_%p_%U';
backup archivelog all DELETE INPUT;
release channel disk1;
release channel disk2;

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK CLEAR;
}

Thank you
Osama mustafa

manual record to the Alert.log

Oracle Give us an Option to record our own error in alertlog.log But How can we Do that :

The procedure kdswrt in dbms_system package allows us to write own messages in the alert log / trace files or both.It receives two parameters:

-   A number that indicates where do we want to write our message:
     Writing to a TRACE file.     Writing to the Alert.log file.     Writing to both of them.        2.   A text string (the message itself).


How to Use it  :

exec dbms_system.ksdwrt(2, 'ORA-10200: Error in Database.);
 Sun Sep 29 10:00:57 2010
Thread 1 advanced to log sequence 7615 (LGWR switch)
Current log# 1 seq# 7615 mem# 0: u01/app/oracle/product/11.2.0/dbhome_1/REDO01.LOG
Sun Sep 29 11:10:15 2010
ORA-10200: Error in Database.
Sun Sep 29 11:10:15 2010
Thread 1 advanced to log sequence 7616 (LGWR switch)
Current log# 2 seq# 7616 mem# 0: u01/app/oracle/product/11.2.0/dbhome_1/REDO02.LOG
Sun Sep 29 10:00:57 2010
Thread 1 advanced to log sequence 7615 (LGWR switch)
Current log# 1 seq# 7615…

Check Rman Backup/Validate

There's More than One Way to Do it :

Check One :

To check Datavase Backup

RMAN > Restore Validate Database ; Check Two : 

Check Spfile

RMAN > restore validate spfile to 'c:\temp\spfile.ora';

Check Three :

Test Control File

RMAN> restore validate controlfile to 'c:\temp\control01.ctl';
Check Four :

Test Archive log

RMAN> list backup of archivelog all;  or
RMAN> list backup of archivelog all completed after 'sysdate -1';
Then
RMAN> restore validate archivelog from sequence XXX until sequence XXX; 

Thank you
Osama Mustafa

12c new features

Tom Kyte , Talk about 12c new features LETS START :

1) "With" clause can define PL/SQL functions

2) Improved defaults, including Default col to a sequence or "default if (on) null".  Or always use a generated as an identity (with optional sequence def info).  Or Metadata-only defaults (default on an added column). 

3) Bigger varchar2, nvarchar2, raw -up to 32K.  But follows rules like LOB, if over 4K will be out of line. (max_SQL_String_Size init param)

4) TopN and Pagenation queries using the 'OFFSET' clause + optional 'FETCH next N rows' in SELECT.  Eg: SELECT ... FROM t ORDER BY y FETCH FIRST 5 ROWS

5) Row pattern matching using the "MATCH_RECOGNIZE" clause.  Gonna take a while to get this one.

6) Partitioning improvements including ASYNC Global Index maintenance (includes new jobs to do work 'later'), cascade truncate & exchange, multi ops in a single DDL, online partition moves (no RDBMS_REDEFINITION), "int…

emagent : Memory 0x0 encountered

Image
When you try to login to EM the following screen appear :











-bash-3.00$ emctl stop dbconsole Oracle Enterprise Manager 11g Database Control Release 11.1.0.7.0 Copyright (c) 1996, 2008 Oracle Corporation. All rights reserved. https://rgpdb1.rg.com:1158/em/console/aboutApplication Stopping Oracle Enterprise Manager 11g Database Control ... ... Stopped. -bash-3.00$ -bash-3.00$ -bash-3.00$ -bash-3.00$ emctl start dbconsole Oracle Enterprise Manager 11g Database Control Release 11.1.0.7.0 Copyright (c) 1996, 2008 Oracle Corporation. All rights reserved. https://rgpdb1.rg.com:1158/em/console/aboutApplication Starting Oracle Enterprise Manager 11g Database Control ............................................................................................. failed. ------------------------------------------------------------------ Logs are generated in directory /pdb01/oraprod/db/tech_st/11.1.0/rgpdb1_rgprd1/sysman/logSolution: Check the following processes and kill them :

ps -ef | grep …

Oracle RAC 12c: New Features

1. Application Continuity

2. Oracle Flex ASM
With this feature, database instances use remote ASM instances. 

3. Oracle ASM Disk Scrubbing
Checks for logical data corruptions and repair them automatically.

4. Enhancements to Policy-based Databases
Actively utilizes different sized servers

5. What - if analysis for server pool management

6. Standardized deployment and patching
Introducing GHS, rapid home provisioning and gold images

7. A new "ghctl" command for better patching

8. Oracle Utility Cluster

9. Dynamic IP Management and name resolution made easy

10. IPv6 Based IP Addresses Support for client connectivity

11. Multi-purpose Installation

12. Oracle installer will run Fix-up scripts & "root.sh" scripts across nodes. You don't have to run the scripts manually on RAC nodes.



Thank you Asif Momen .


Thank you 
Osama Mustafa 

ORA-02020: too many database links in use

Error :

ORA-02020: too many database links in use


Solution :

Increase the open_links and open_links_instance parameter in the DB . Bounce Database

Or

SQL>alter session close database link "link name";


Thank you
Osama mustafa

ORA-19527: physical standby redo log must be renamed

In Standby Database Alert log i Found the following :

Attempt to start background Managed Standby Recovery process (neonprd)
MRP0 started with pid=31, OS id=5623962
Mon Oct 8 09:12:10 2012
MRP0: Background Managed Standby Recovery process started (neonprd)
Managed Standby Recovery not using Real Time Apply
parallel recovery setup failed: using serial mode
Mon Oct 8 09:12:17 2012
Waiting for all non-current ORLs to be archived...
Mon Oct 8 09:12:17 2012
Errors in file /oracle/admin/neonprd/bdump/neonprd_mrp0_5623962.trc:
ORA-00367: checksum error in log file header
ORA-00318: log 1 of thread 1, expected file size 512 doesn't match 512
ORA-00312: online log 1 thread 1: '/oracle/redolog/neonprd/redo01a.log'
Clearing online redo logfile 1 /oracle/redolog/neonprd/redo01a.log
Clearing online log 1 of thread 1 sequence number 267655
Mon Oct 8 09:12:17 2012
Errors in file /oracle/admin/neonprd/bdump/neonprd_mrp0_5623962.trc:
ORA-19527: physical standby redo log must be rename…

ORA-00313 ,ORA-00312 open failed for members of log group

ORA-00313: open failed for members of log group 206 of thread 2
ORA-00312: online log 206 thread 2: '/u05/oradata/stdby/'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory


 Solution :

1-Mount the database.

SQL>STARTUP MOUNT
Database mounted.

2-Check the status of the logile to see whether it is current.

SELECT STATUS FROM V$LOG WHERE GROUP#=2;
STATUS
----------------
CURRENT  Note : If the status did not CURRENT then simply drop the log file by:


SQL>ALTER DATABASE DROP LOGFILE GROUP 2;
3-Add new Redo Log by :

SQL>ALTER DATABASE ADD LOGFILE GROUP 4 'u03/App/Oradata/redo3.log' SIZE 50M;

4-Do Recover and Open Database Resetlog :


SQL>RECOVER DATABASE UNTIL CANCEL;
SQL>ALTER DATABASE OPEN RESETLOGS;
Enjoy
Osama Mustafa

LMT Vs ASSM

Two methods to manage space :


Locally managed tablespace (LMT)—The LMT is implemented by adding the EXTENT MANAGEMENT LOCAL clause to the tablespace definition syntax. Unlike the older dictionary managed tablespaces (DMTs), LMTs automate extent management and keep the Oracle DBA from being able to specify the NEXT storage parameter to govern extent sizes. The only exception to this rule is when NEXT is used with MINEXTENTS at table creation time.
Automatic segment space management (ASSM)—The ASSM tablespace is implemented by adding the SEGMENT SPACE MANAGEMENT AUTO clause to the tablespace definition syntax. ASSM tablespaces automate freelist management by replacing the traditional one-way linked-list freelists with bitmap freelists, and remove the ability to specify PCTUSED, FREELISTS, and FREELIST GROUPS storage parameters for individual tables and indexes.(method used by Oracle to manage space inside data blocks. It eliminates the need to specify parameters like PCTUSED, …

Active Trace Steps

There's More than One Way to active Oracle Trace , This Topic will talk about how to do this ?

Lets Rock N Roll


1-Alter session set sql _trace Statement 

alter session set sql_trace = true;
Or ( The two Statement is equal )
alter session set events '10046 trace name context forever, level 1';
2-DBMS_Session.Set_Sql_Trace 

dbms_session.set_sql_trace (true); Deactivate dbms_session.set_sql_trace (false); 3-DBMS_Support.Start_trace 

dbms_support.start_trace (binds=>{true|false}, waits=>{true|false}); Or to Disable it
dbms_support.stop_trace;
4-Alter Session set event
5-dbms_system.set_ev
6-Oradebug Command
7-DBMS_MONITOR.Session_trace_enable


Ref Link :
1-Oracle-Base
2-Gplivna 

Enjoy
Osama Mustafa 

Oracle OpenWorld , Amazing World

Image
Enjoy 
Osama Mustafa

Temporary tablespace group

What We Mean By That ?

A temporary tablespace group consists of only temporary tablespace, and has the following properties:
It contains one or more temporary tablespaces. It contains only temporary tablespace. It is not explicitly created. It is created implicitly when the first temporary tablespace is assigned to it, and is deleted when the last temporary tablespace is removed from the group. 
Benefits :

Temporary tablespace group has the following benefits:
It allows multiple default temporary tablespaces to be specified at the database level. It allows the user to use multiple temporary tablespaces in different sessions at the same time. It allows a single SQL operation to use multiple temporary tablespaces for sorting. 
How to Know How Much Group you have A…