Friday, November 12, 2010

http://ocp.community.ge/

Hello All,

I moved all my posts in new url, I use community domain.

New Address of my blog is http://ocp.community.ge/

Wednesday, November 3, 2010

Huge Space Consumption by $ORACLE_HOME/.patch_storage

Hello All

When we applied Patchset 10.2.0.4 and some critical oracle patches, we got space problem on server.

We found large directories in solaris with command :du -ko /u0|sort -n | tail -10.

$ORACLE_HOME/.patch_storage was largest directory in oracle_home.

In .patch_storage is keeping your system up to date with Patchsets, Patch Bundles, Merge Label Requests (MLR) or Critical Patch Updates (CPU) for restore old versions.

for clearing this directory we can use MetaLink Note 550522.1
or simple: opatch util Cleanup

Tuesday, October 26, 2010

The Real Application testing, Database Replay process

The Real Application testing, Database Replay process

The Real Application testing feature, which consists of two separate tools, Database Replay and the SQL performance Analyzer, is arguably the most significant new feature in the Oracle Database 11.1 Release. With this process we can simulate a real production workload on a test system; we can apply some patches, change data storage and see how our performance changes on test system.
In this post we step by step review Database replay process

1. Restart prod DB and startup restrict mode (this in optional)
2. We can use optional workload filters to restrict the workload capture to only a part of the actual production workload:
BEGIN
DBMS_WORKLOAD_CAPTURE.ADD_FILTER(FNAME => 'FILTER_NAME',FATTRIBUTE => 'USER',FVALUE => 'SCOTT');

END;
We can find filter’s in view DBA_WORKLOAD_FILTERS;
3. Start Workload capture, means start process which collect workload to the some files, which then will apply on test DB:
BEGIN
DBMS_WORKLOAD_CAPTURE.START_CAPTURE(NAME => '2010OCT',DIR => 'DATA_PUMP_DIR',DURATION => 1200);
END;

Duration is number of seconds for which workload will be captured this is optional parameter.
DIR is oracle directory which must be empty!
We can manually stop capture process with this statement:
BEGIN
DBMS_WORKLOAD_CAPTURE.FINISH_CAPTURE();
END;

We can see status of process in view DBA_WORKLOAD_CAPTURES
4. Preprocess capture data means that capture data will procedure the metadata for captured workload and transform the captured workload datafiles into reply streams called reply files that you can now replay on the test system:
BEGIN
DBMS_WORKLOAD_REPLAY.PROCESS_CAPTURE(CAPTURE_DIR => 'DATA_PUMP_DIR');
END;

5. Now we must create test DB which should have same data structure as prod DB, we can use rman scripts(backup, restore), snapshot standby DB, Data pump utilities or simple cold backup for creating test DB
6. Check that oracle directory in test DB link on directory where replay files are located, in this scenario we create directory TEST_DIR
7. Initializing the replay Data means initialize the data, which loads the metadata into tables required by workload process:
BEGIN
DBMS_WORKLOAD_REPLAY.INITIALIZE_REPLAY(REPLAY_NAME => 'TEST_REPLAY',REPLAY_DIR => 'TEST_DIR');
END;

8. Then we mush remap connections with statement:
BEGIN
DBMS_WORKLOAD_REPLAY.REMAP_CONNECTION(CONNECTION_ID => 111);
END;

9. Prepare the Workload for Replay with statement :
BEGIN
DBMS_WORKLOAD_REPLAY.PREPARE_REPLAY();
END;

There we run procedure with default parameters, for example we can use parameter synchronization, by default true, meaning that the commit order of captured workload will be preserved during the workload replay
10. Set up Reply Clients. The reply driver is a special application that consumes the captured workload by sending replay requests to the test DB. The reply client in essence simulates the production system on the test DB. To Find optimal number of clients we must run this statement on test server in terminal window up to directory where is test_dir
wrc system/a mode=calibrate replay_dir=./test_dir
if we should run with 2 or more clients we must open new terminals and run process in other windows.
Run client with this statement:
wrc system/a mode=replay replaydir=./test_dir
11. Now we can start replay process with statement:
BEGIN
DBMS_WORKLOAD_REPLAY.START_REPLAY();
END:

You must start minimum of one wrc client before you can start the workload replay.
You can manually stop Replay process by statement, this is optional, because replay process will finished itself:
BEGIN
DBMS_WORKLOAD_REPLAY.CANCEL_REPLAY();
END;

Status and progress of replay process you can see in view : DBA_WORKLOAD_REPLAYS
12. Report and result of replay process you can see with this statement :



DECLARE
CAP_ID NUMBER;
REP_ID NUMBER;
REP_RPT CLOB;
BUFFER VARCHAR2(32767);
BUFFER_SIZE CONSTANT BINARY_INTEGER := 32767;
AMOUNT BINARY_INTEGER;
OFFSET NUMBER(38);
FILE_HANDLE UTL_FILE.FILE_TYPE;
DIRECTORY_NAME CONSTANT VARCHAR2(80) := 'TEST_DIR';
V_FILENAME CONSTANT VARCHAR2(80) := 'REPLAY.HTML';
BEGIN
CAP_ID := DBMS_WORKLOAD_REPLAY.GET_REPLAY_INFO(DIR => 'TEST_DIR');
SELECT MAX(ID)
INTO REP_ID
FROM DBA_WORKLOAD_REPLAYS
WHERE CAPTURE_ID = CAP_ID ;
REP_RPT := DBMS_WORKLOAD_REPLAY.REPORT(REPLAY_ID => REP_ID,
FORMAT => DBMS_WORKLOAD_REPLAY.TYPE_HTML);
-- WRITE REPORT TO FILE
DBMS_OUTPUT.ENABLE(100000);
-- --------------------------------
-- OPEN NEW XML FILE IN WRITE MODE
-- --------------------------------
FILE_HANDLE := UTL_FILE.FOPEN(LOCATION => 'TEST_DIR',
FILENAME => V_FILENAME,
OPEN_MODE => 'W',
MAX_LINESIZE => BUFFER_SIZE);
AMOUNT := BUFFER_SIZE;
OFFSET := 1;
WHILE AMOUNT >= BUFFER_SIZE
LOOP
DBMS_LOB.READ(LOB_LOC => REP_RPT,
AMOUNT => AMOUNT,
OFFSET => OFFSET,
BUFFER => BUFFER);
OFFSET := OFFSET + AMOUNT;
UTL_FILE.PUT(FILE => FILE_HANDLE,
BUFFER => BUFFER);
UTL_FILE.FFLUSH(FILE => FILE_HANDLE);
END LOOP;
UTL_FILE.FCLOSE(FILE => FILE_HANDLE);
END;







Friday, October 15, 2010

increase session_cached_cursors

Hello all,

We have performance problem on prod DB, and Oracle ADDM advice us increase size of session_cached_cursors parameter.

We decide find reason of problem.

Here you can find statement which you should run where problem appear.

create table t1 as select sql_text from v$sqlarea;

alter table t1 add sql_text_wo_constants varchar2(3000);

create or replace function
remove_constants( p_query in varchar2 ) return varchar2
as
l_query long;
l_char varchar2(1);
l_in_quotes boolean default FALSE;
begin
for i in 1 .. length( p_query )
loop
l_char := substr(p_query,i,1);
if ( l_char = '''' and l_in_quotes )
then
l_in_quotes := FALSE;
elsif ( l_char = '''' and NOT l_in_quotes )
then
l_in_quotes := TRUE;
l_query := l_query || '''#';
end if;
if ( NOT l_in_quotes ) then
l_query := l_query || l_char;
end if;
end loop;
l_query := translate( l_query, '0123456789', '@@@@@@@@@@' );
for i in 0 .. 8 loop
l_query := replace( l_query, lpad('@',10-i,'@'), '@' );
l_query := replace( l_query, lpad(' ',10-i,' '), ' ' );
end loop;
return upper(l_query);
end;
/
update t1 set sql_text_wo_constants = remove_constants(sql_text);



now we can see result on statement



select sql_text_wo_constants, count(*)
from t1
group by sql_text_wo_constants
having count(*) > 100
order by 2 desc
/

we can see selects which is reason of performance problem.

In these select please use bind variables.

Monday, August 2, 2010

Gather schema statistic exluding some tables

Whenever a valid SQL statement is processed Oracle has to decide how to retrieve the necessary data. This decision can be made using one of two methods:

* Rule Based Optimizer (RBO) - This method is used if the server has no internal statistics relating to the objects referenced by the statement. This method is no longer favoured by Oracle and will be desupported in future releases.
* Cost Based Optimizer (CBO) - This method is used if internal statistics are present. The CBO checks several possible execution plans and selects the one with the lowest cost, where cost relates to system resources.

If new objects are created, or the amount of data in the database changes the statistics will no longer represent the real state of the database so the CBO decision process may be seriously impaired. The mechanisms and issues relating to maintenance of internal statistics are explained below:


Using dbms_stat procedure:

dbms_stat procedure gather statistics for DB object, after gathering them, oracle build right sql_plans and optimize SQL statement.

Example gathering statistic for schema, this statement built SQL text.

select 'execute dbms_stats.gather_table_stats (ownname=>''' || upper(owner)
|| ''', tabname=> ''' || upper(table_name) || ''', degree=>10, cascade=> true);' from DBA_TABLES
where upper(owner) in ('SCOTT') and table_name not in
('TABLE1','TABLE2') order by owner, table_name;

note:
if you have very large tables you can exclude it for quickly gathering statistics

ownname means schema name
degree means that 10 oracle process will start gather information
cascade means that statistics gather for all indexes on tables

Friday, May 21, 2010

Installing Oracle Management Agent 11g with response file

Hello Again,

As you know, we installed Oracle EM Grid control 11g in Linux server 2 day ago, now we are trying install management agent in server where is our DB's

First of all download install packages from:
http://www.oracle.com/technology/software/products/oem/htdocs/agentsoft.html

Our example is for :
Agent Software for 64-bit Platforms,Linux x86-64

1. copy zip files in server

2. unzip Linux_x86_64_Grid_Control_agent_download_11_1_0_1_0.zip file(for example /0 folder)

3. make changes on file additional_agent.rsp located linux_x64/response sub folder.

We should set some init parameters

SECURITY_UPDATES_VIA_MYORACLESUPPORT=FALSE
DECLINE_SECURITY_UPDATES=TRUE
ORACLE_AGENT_HOME_LOCATION=/u1/app/oracle/agent11g(you can change as you wish)
OMS_HOST=OEMserver (host where is installed EM grid 11g)
OMS_PORT=4889
AGENT_REGISTRATION_PASSWORD=****** (Agent registration password, if you set it during Oracle EM installation )

4. execute runinstaller with specified parameters
./runInstaller -silent -responseFile /0/linux_x64/response/additional_agent.rsp


If you have some question please contact me by e-mail: vmantua@gmail.com

Wednesday, May 19, 2010

Install Grid Control 11g on linux CentOS(32 bit)

Hi All,

I'm writing manual of installation grid control 11g in Linux (32 bit ). Installation of this product not like early versions of grid control, cause of this is that grid control instead of oracle application server is use oracle web logic server now.

Let's Start!

First of all we should install oracle DBMS and create database for repository OEM.

A. Installation DBMS

1. Install rpm’s

Login on server with user root
 
1.1 run and install rpm’s with command rpm -Uvh

libaio-devel-0.3.106-3.2.i386.rpm

unixODBC-2.2.11-7.1.i386.rpm

unixODBC-devel-2.2.11-7.1.i386.rpm

unixODBC-devel-2.2.11-7.1.x86_64.rpm

1.2 delete old version of rmp ksh

rpm -e ksh-20060214-1.7.i386

1.3 Install new version of ksh: rpm –Uvh pdksh-5.2.14-36.el5.i386.rpm

2. Configuring Linux for Oracle

mkdir -p /u0/app/oracle

groupadd oinstall
groupadd dba
useradd –s /bin/bash –d /u0/app/oracle –g oinstall –G dba oracle

passwd oracle
chown -R oracle:oinstall /u0/app
chmod -R 777 /u0/app 
 

change /etc/sysctl.conf, add lines:
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586



Reboot system

3. Install Oracle software

3.1 Download from http://www.oracle.com/technology/software/products/database/index.html

Installation packages

Oracle Database 11g Release 2 (11.2.0.1.0) for Linux x86

Linux_11gR2_database_1of2.zip (1,285,396,902 bytes) (cksum - 2237015228)

Linux_11gR2_database_2of2.zip (995,359,177 bytes) (cksum - 2649514514)

3.2 login on server with user oracle , unzip zip files and run runinstaller

B. Install Oracle Web Logic Server And Grid Control


1. Install Oracle RDMS 11g
Please see part A


2.
Install Oracle Web Logic server

2.1
download installation package http://www.oracle.com/technology/software/products/ias/htdocs/wls_main.html Oracle WebLogic Server 11gR1 (10.3.2) - Package Installer

2.2 Copy wls1032_linux32.bin file in server and run command chmod a+x *.bin

2.3 Run ./ wls1032_linux32.bin for installation web logic server

3. Create DB , configure listener.ora file and tnsnames.ora file for connecting DB(You can use dbca utility)

4.Change Oracle instance parameters and increase size of UNDO TBS: 
  

ALTER system SET session_cached_cursors = 200 scope=spfile;
ALTER system SET log_buffer = 10485760 scope=spfile;
ALTER system SET processes = 500 scope=spfile;
ALTER system SET open_cursors = 300 scope=spfile;
   Restart DB and run command :
    ALTER DATABASE DATAFILE ‘/u1/oradata/OEMREP/undotbs01.dbf’ RESIZE 250M;



5. Download Grig control soft from
       

http://www.oracle.com/technology/software/products/oem/htdocs/linuxsoft.html
      

GridControl_11.1.0.1.0_Linux_1of3.zip
(1,346,827,162 bytes) (cksum - 4036510904)
           GridControl_11.1.0.1.0_Linux_2of3.zip (1,504,676,900 bytes) (cksum - 2185370223)   
       GridControl_11.1.0.1.0_Linux_3of3.zip (1,336,577,399 bytes) (cksum - 4010010869)
  
Copy these files in server unzip and run runinstaller

6. After install

Navigate to the Oracle home of the OMS and run the following command to see a message that confirms that OMS is up and running.

$<OMS_HOME>/bin/emctl status oms

Go to the Oracle home of the Management Agent and run the following command to see a message that confirms that the Management Agent is up and running.

$<AGENT_HOME>/bin/emctl status agent

Run the following command to see a message that confirms that EMD upload completed successfully.

[$<AGENT_HOME>/bin/emctl upload


6.1. Adding ports to firewall rules.

  • Don’t forget to open ports on your firewall:

Default Ports to be opened:

Enterprise Manager Upload Http Port

4889

Enterprise Manager Upload Http SSL Port

4900

Enterprise Manager Central Console Http SSL Port

7799

Enterprise Manager Central Console Http Port

7202

Enterprise Manager Central Console Http Port

7788

Node Manager Http SSL Port

7403

Managed Server Http SSL Port

7301

Oracle Management Agent Port

3872

Admin Server Http SSL Port

7101


Login to EM Grid Control console (sysman/password)

SSL – standard approach:
https://hostname.local:7799/em

It’s also possible to avoid SSL connection. To do that, first you must unlock http access:

[oracle@hostname bin]$ ./emctl secure unlock -console
Oracle Enterprise Manager 11g Release 1 Grid Control
Copyright (c) 1996, 2010 Oracle Corporation. All rights reserved.
Enter Enterprise Manager Root (SYSMAN) Password :******
OMS Console is unlocked. HTTP ports too can be used to access console.
http://hostname.local:7202/em/console/home


Login without SSL (default port 7202):
http:// hostname.local:7202/em

7. Start/stop the environment: On OMS Server

  • to start Oracle Enterprise Manager Grid Control services:

$<OMS_HOME>/bin/ emctl start oms –all

  • to stop Oracle Enterprise Manager Grid Control services:

$<OMS_HOME>/bin/ emctl stop oms –all