Trocar a porta do OHS – infra ou middle

Criar um apelido para aplicacao portconfig, na verdade para as classes utilizadas.
como usuario oracle execute o comando:

$ alias portconfig=’/u01/app/oracle/j2ee1/jdk/bin/java -cp /u01/app/oracle/j2ee1/sysman/webapps/emd/WEB-INF/lib/emd.jar:/u01/app/oracle/j2ee1/dcm/lib/dcm.jar:/u01/app/oracle/j2ee1/sso/lib/ossoreg.jar oracle.sysman.ias.sta.tools.PortConfigCmdLine’

Depois execute o novo portconfig:
$ portconfig -oracleHome $ORACLE_HOME -oldPort 7779 -newPort 80 -webCache

Alterar o arquivo portlist para a nova realidade

$ gedit $ORACLE_HOME/install/portlist.ini

Reiniciar os processos:

emctl stop iasconsole
opmnctl stopall

opmnctl startall
emctl start iasconsole

agora verificar a url:

http://nomehost:80/

Fazendo o plano de execucao da consulta

Ola,

O plano da execucao das consultas podera sera executado atraves de ferramentas de terceiros ou atraves do proprio oracle. Primeiramente precisamos ter a tabela que contera os planos gerados pelo oracle ou pelas ferramentas. Para isso vamos executar o script $ORACLE_HOME/rdbms/admin/utlxplan.sql:

cd $ORACLE_HOME/rdbms/admin
sqlplus “/ as sysdba”

SQL> create user query identified by query;

Usußrio criado.

SQL> grant resource,connect to query;

ConcessÒo bem-sucedida.

SQL> grant dba to query;

ConcessÒo bem-sucedida.

SQL> create table TBLDADOS as select * from dba_tables;

Tabela criada.

SQL> create table TBLJOIN as select * from dba_tables;

Tabela criada.

SQL>

SQL>@utlxplan.sql;

Agora execute o comando:

SQL> set autotrace on

SQL> explain plan for select * from TBLDADOS, TBLJOIN
where TBLDADOS.TABLE_NAME = TBLJOIN.TABLE_NAME
ORDER BY 1,2,3;

Após a query ser executada, aparecerá no final do SQL*Plus o plano de execução pronto, sem que seja necessário mais nenhum passo.

Para remover é so editar o seguinte comando:

SQL> set autotrace off

Ou ver o resultado que foi inserido na table PLAN_TABLE com a consulta:

SQL>
select
substr (lpad(‘ ‘, level-1) || operation || ‘ (‘ ||
options || ‘)’,1,30 ) “Operation”,
object_name
“Object”
from plan_table
start with id = 0
connect by prior id=parent_id;

ou como na saida dos melhores programas de terceiros:

SQL> select * from table (dbms_xplan.display);

O custo de CPU somente aparece quando as estatísticas de sistema estão habilitadas. “Dynamic sampling used for this statement” significa que esta tabela não esta com estatísticas. O banco também esta configurado para gerar um sample das estatísticas se não existir na tabela. Para ativa-lo coloque na inicializacao este parametro para TRUE mas tome cuidado pode reduzir o performance se for em um ambiente em producao, portanto use e depois volte para false.

TIMED_STATISTICS = TRUE — Parametro de inicializacao do banco

Ou na sessao:

alter session
set timed_statistics=true
alter session
set max_dump_file_size=unlimited
*** DUMP FILE SIZE IS LIMITED TO 1048576 BYTES ***

Resolva o problema criando um indice para as clausulas envolvidas na junção.

SQL> create index TBLJOINIDX1 on TBLJOIN(TABLE_NAME);

SQL> create index TBLDADOSIDX1 on TBLDADOS(TABLE_NAME);

Refaça o plano para verificar as devidas

SQL> explain plan for select * from TBLDADOS, TBLJOIN
where TBLDADOS.TABLE_NAME = TBLJOIN.TABLE_NAME
ORDER BY 1,2,3;

Após a query ser executada, aparecerá no final do SQL*Plus o plano de execução pronto, sem que seja necessário mais nenhum passo.

Para remover é so editar o seguinte comando:

SQL> set autotrace off

Ou ver o resultado que foi inserido na table PLAN_TABLE com a consulta:

SQL>
select
substr (lpad(‘ ‘, level-1) || operation || ‘ (‘ ||
options || ‘)’,1,30 ) “Operation”,
object_name
“Object”
from plan_table
start with id = 0
connect by prior id=parent_id;

Voce deve apagar o conteudo da tabela PLAN_TABLE depois de analisar o resultado, caso utilize a sintaxe sql para consulta-la ao inves da dbms_xplan.

SQL> DELETE FROM plan_table;

Se tiver usando um programa para visualizar a saida o melhor é colocar em uma fonte fixa, como fixedsys ou Misc Fixed.

Create table do PLAN_TABLE que vem com o 9i R2:

create table PLAN_TABLE (
statement_id varchar2(30),
timestamp date,
remarks varchar2(80),
operation varchar2(30),
options varchar2(255),
object_node varchar2(128),
object_owner varchar2(30),
object_name varchar2(30),
object_instance numeric,
object_type varchar2(30),
optimizer varchar2(255),
search_columns number,
id numeric,
parent_id numeric,
position numeric,
cost numeric,
cardinality numeric,
bytes numeric,
other_tag varchar2(255),
partition_start varchar2(255),
partition_stop varchar2(255),
partition_id numeric,
other long,
distribution varchar2(30),
cpu_cost numeric,
io_cost numeric,
temp_space numeric,
access_predicates varchar2(4000),
filter_predicates varchar2(4000));

Para o 10G release 2 ficou mais facil:

A new feature of Oracle 10g Release 2 is that

set autotrace traceonly explainis using DBMS_XPLAN now.

Quote from http://www.oracle.com/technology/oramag/oracle/05-sep/o55asktom.html

SQL> set autotrace traceonly explain

SQL> select *
2 from emp, dept
3 where emp.deptno = dept.deptno
4 and emp.job = ‘CLERK’;

Execution Plan
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

Plan hash value: 877088642

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
| Id | Operation | Name | Rows | Bytes | Cost (%CPU) | Time |
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
| 0 | SELECT STATEMENT | | 4 | 468 | 7 (15) | 00:00:01 |
|* 1 | HASH JOIN | | 4 | 468 | 7 (15) | 00:00:01 |
|* 2 | TABLE ACCESS FULL | EMP | 4 | 348 | 3 (0) | 00:00:01 |
| 3 | TABLE ACCESS FULL | DEPT | 4 | 120 | 3 (0) | 00:00:01 |
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
Predicate Information (identified by operation id):
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
1 – access(“EMP”.”DEPTNO”=”DEPT”.”DEPTNO”)
2 – filter(“EMP”.”JOB”=’CLERK’)
Note
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
– dynamic sampling used for this statement

Usando o tkprof com o trace da sessao corrente

Para usar o tkprof é bastante simples, primeiro coloque sua sessao em trace, onde sera gerado um arquivo com um numero sequencia em

sqlplus “/ as sysdba”

SQL> show parameter user_dump_dest
user_dump_dest string /u00/oracle/banco/admin/orcl/udump

Assim rode o script para colocar a sessao em trace:

begin
for cur_rec in (select sid, Serial# serial from v$session where osuser
like ‘%oracleuser%’) loop
dbms_System.Set_Sql_Trace_In_Session(cur_rec.sid,cur_rec.serial,True);
end loop;
end;

OU:

begin
for cur_rec in (select sid, Serial# serial from v$session where machine like
‘%TESTEMACHINE%’) loop
dbms_System.Set_Sql_Trace_In_Session(cur_rec.sid,cur_rec.serial,True);
end loop;
end;

Assim, copiei o arquivo novo gerado no local de trace de usuario, para uma outra maquina, so pra rodar o tkprof mas poderia ter rodado também direto no servidor:

c:>tkprof orcl_ora_29475.trc tk.txt explain=sistema/senha@conectar
sys=no sort=fchela

Assim foi gerado o novo arquivo tk.txt e o que se deve analisar é o tempo de processamento inicialmente, onde ate a clausula insert podera estar acarretando demora na hora do insert.

Estagios de montagem do banco de dados Oracle

Os Estagios de montagem do banco de dados oracle sao:

Nomount.

Neste estagio o banco de dados le o arquivo de inicializacao, sendo primeiro o spfileSID.ora,
se ausente, o arquivo spfile.ora e por ultimo procura pelo initSID.ora. Lendo o arquivo de inicializacao o que ocorre a seguir é a abertura dos arquivos de controle, que por padrao sao multiplexados em tres arquivos para manter seguranca. A instancia entao é aberta em memoria, e os procesos de segundo plano tambem sao iniciados, estes dos quais mantem a instancia no ar.
Entao fica assim:
– Abertura do arquivo de inicializacao – spfileSID.ora
– A especificacao do parametro PFILE com a instrucao startup altera o comportamento padrao, ou seja faz com que o PFILE especificado seja carregado: startup c:pfile.ora
– Alocacao da SGA em memoria
– Incializacao dos processos de segundo plano.
– Abertura do alertSID.log
– Abertura dos logs de rastreamento.

startup mount

Parametros para instalar o ORACLE 10G em linux

[root@aluno09 ~]# cat /etc/issue
Red Hat Enterprise Linux ES release 4 (Nahant Update 4)
Kernel r on an m

criar o usuario oracle, tem que se logar como root:

groupadd oinstall
groupadd dba
groupadd oper

Crie o usuario oracle:

useradd -g oinstall -G dba,oper -d /home/oracle oracle

troque a senha do oracle

passwd oracle

Adicionar essa configuracao ao arquivo /etc/sysctl.conf, ao finalizar digite: sysctl -p
Para confirmar as alteracoes sem precisar de boot,

# Oracle Configurations
kernel.sem = 256 32000 100 128
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.msgmax = 8192
kernel.msgmnb = 65535
kernel.msgmni = 2878
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_max = 262144
# End Oracle Configurations

Crie um arquivo .bash_profile para o seu usuario com o conteudo abaixo:

vi /home/oracle/.bash_profile

################################################## ACRESCENTAR ao .bash_profile
umask 022

LD_LIBRARY_PATH=/usr/lib:/usr/X11R6/lib
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
ORACLE_SID=orcl
PATH=$ORACLE_HOME/jdk/jre/lib/i386/server:$ORACLE_HOME/rdbms/lib:$ORACLE_HOME/lib:$LD_LIBRARY_PATH:$PATH
PATH=$ORACLE_HOME/bin:$PATH

export PATH LD_LIBRARY_PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID
unset USERNAME

################################################## TERMINO .bash_profile

Alterar Datafile de Local fisico

startup restrict mount

ALTER DATABASE DATAFILE ‘D:ORACLEORADATAGINFUNDOTBS01.DBF’ to ‘C:ora92oradataGINFUNDOTBS01.DBF’;

ALTER DATABASE rename TEMPFILE ‘d:oracleoradataGINFTEMP01.dbf’ to ‘C:ora92oradataGINFTEMP01.dbf’;

ALTER DATABASE rename FILE ‘d:oracleoradataGINFCWMLITE01.DBF’ to ‘C:ora92oradataGINFCWMLITE01.DBF’;

ALTER DATABASE rename FILE ‘d:oracleoradataGINFDRSYS01.DBF’ to ‘C:ora92oradataGINFDRSYS01.DBF’;

ALTER DATABASE rename FILE ‘d:oracleoradataGINFEXAMPLE01.DBF’ to ‘C:ora92oradataGINFEXAMPLE01.DBF’;

ALTER DATABASE rename FILE ‘d:oracleoradataGINFINDX01.DBF’ to ‘C:ora92oradataGINFINDX01.DBF’;

ALTER DATABASE rename FILE ‘d:oracleoradataGINFginftest.ora’ to ‘C:ora92oradataGINFginftest.ora’;

ALTER DATABASE rename FILE ‘d:oracleoradataGINFODM01.DBF’ to ‘C:ora92oradataGINFODM01.DBF’;

ALTER DATABASE rename FILE ‘d:oracleoradataGINFSYSTEM01.DBF’ to ‘C:ora92oradataGINFSYSTEM01.DBF’;

ALTER DATABASE rename FILE ‘d:oracleoradataGINFTOOLS01.DBF’ to ‘C:ora92oradataGINFTOOLS01.DBF’;

ALTER DATABASE rename FILE ‘d:oracleoradataGINFUSERS01.DBF’ to ‘C:ora92oradataGINFUSERS01.DBF’;

ALTER DATABASE rename FILE ‘d:oracleoradataGINFXDB01.DBF’ to ‘C:ora92oradataGINFXDB01.DBF’;

ALTER DATABASE rename FILE ‘d:oracleoradataGINFREDO01.LOG’ to ‘C:ora92oradataGINFREDO01.LOG’;

ALTER DATABASE rename FILE ‘d:oracleoradataGINFREDO02.LOG’ to ‘C:ora92oradataGINFREDO02.LOG’;

ALTER DATABASE rename FILE ‘d:oracleoradataGINFREDO03.LOG’ to ‘C:ora92oradataGINFREDO03.LOG’;

alter database clear unarchived logfile ‘C:ora92oradataGINFREDO03.LOG’;

Rebuild dos indices do Oracle Portal

Login como PORTAL

set pagesize 0
set linesize 250

spool rebuild_index1.sql
select ‘alter index ‘||INDEX_NAME||’ rebuild;’
from dba_indexes
where TABLE_NAME in (‘WWNLS_STRINGS$’,
‘WWPOB_ITEM$’,
‘WWPOB_PAGE_CUSTOMIZATION$’,
‘WWPOB_PAGE$’,
‘WWPOB_PORTLET_INST$’,
‘WWV_THINGS’,
‘WWV_DOCINFO’,
‘WWV_SEC_SYS_PRIV$’,
‘WWSEC_FLAT$’,
‘WWSBR_SITES$’,
‘WWSBR_URL$’,
‘WWDOC_DOCUMENT$’)
and OWNER = ‘PORTAL’
and INDEX_NAME not like ‘%_PK’ — exclude the primary keys indexes
and INDEX_NAME not like ‘WWSBR%CTX%’ — exclude the intermedia indexes
and INDEX_NAME not like ‘SYS_%’ — exclude the LOB indexes (check Note #159995.1 why)
;
spool off

spool rebuild_index2.sql
select ‘alter index ‘||INDEX_NAME||’ rebuild;’
from dba_indexes
where TABLE_NAME like ‘WWUTL%’
and OWNER = ‘PORTAL’
and INDEX_NAME not like ‘%_PK’ — exclude the primary keys indexes
and INDEX_NAME not like ‘SYS_%’ — exclude the LOB indexes (check Note #159995.1 why)
;
spool off

execute rebuild_index1.sql
execute rebuild_index2.sql

Estatisticas do Oracle Portal

Tenha certeza que o portal esta coletando as estatisticas.

Faça o login como PORTAL e execute:

SQL> exec dbms_stats.delete_schema_stats (ownname=>’PORTAL’); — analyzing PORTAL schema statistics is *NOT* supported
SQL> exec wwsbr_stats.delete_stats; — delete Portal statistics
SQL> exec wwsbr_stats.gather_stats; — create Portal statistics
SQL> exec wwsbr_stats.enable_monitoring; — Habilitar o DML sobre as tabelas se for necessário
SQL> exec wwsbr_stats.gather_stale;
SQL> commit;

Nota:
+ Para desabilitar Portal DML monitoring : exec wwsbr_stats.disable_monitoring
+ Para configurar o JOB: $ORACLE_HOME/portal/admin/plsql/wws/statsjsub.sql ‘START’ ‘NOW’ ’24’ => a cada 24 horas.

Apache – Performance

No arquivo de configuração httpd.conf existem vários parametros dentre eles podemos destacar os parametros:

No UNIX e Linux:
StartServers
MaxClients
MaxSpareServers / MinSpareServers
MaxRequestsPerChild

No Windows NT:
ThreadsPerChild

Em todos os sistemas operacionais:
KeepAlive
KeepAliveTimeout
MaxKeepAliveRequests

Para cada um deles, os parametros adequados são:

StartServers: configura o numero de processos filhos criados quando o Oracle HTTP Server é iniciado. O default é 5.
MaxClients: Limits the number of requests that are handled simultaneously. The default value is 150.
MaxRequestsPerChild: Each child version handles this number of requests and then dies. If the value is 0, the process lasts until the machine is rebooted. The default value is 30.
MaxSpareServers: No more than this number of child servers should be left running and unused. The default value is 10.
MinSpareServers: At least this number of child servers should be kept functional. The default value is 5. If fewer than this number exist, new ones are started at an increasing rate each second until the rate defined by MAX_SPAWN_RATE is reached (default: 32).

For example, if the number of requests to be handled simultaneously is 100, and the number of child server processes created is 10, then the maximum number of requests to be handled per child can be 10

Dicas interessantes sobre o OHS

ThreadsPerChild: This directive sets the number of threads created by each child process. The child creates these threads at startup and never creates more.

If you are using an MPM like mpm_winnt, where there is only one child process, this number should be high enough to handle the entire load of the server.

If you are using an MPM like mpm_worker, where there are multiple child processes, the total number of threads should be high enough to handle the common load on the server.

MinSpareThreads: This value is only used with mpm_worker. Since Oracle Access Manager plug-in initialization is deferred until the first request, there is minimal advantage of keeping high value for this directive.

However, it is useful to keep this parameter as high as possible.

MaxSpareThreads: This value is only used with mpm_worker. The value for MaxSpareThreads must be greater than or equal to the sum of MinSpareThreads and ThreadsPerChild or the Apache HTTP Server automatically corrects it.

Recommendation: Keep the value high. For a dedicated server this will not be a problem.

MaxSpareServers: With Apache v2, this is used only with the prefork MPM model. To preserve as much state as possible in the server, set the MaxSpareServers to a high value. Setting this value to the maximum of 255 keeps all Apache worker-processes available indefinitely, but it does not provide an opportunity for worker-process recycling during low-load periods.

MinSpareServers: With Apache v2, this is used only with the prefork MPM model. Since Oracle Access Manager plug-in initialization is deferred until the first request, using a high value for the MinSpareServers parameter provides minimal advantage.

However, it is useful to keep this parameter as high as possible. For dedicated Web server systems, this should pose no great burden.

MaxClients: With IHS v2 and the worker MPM, MaxClients restricts the total number of threads that will be available to serve clients.

For hybrid MPMs, the default value is 16 (ServerLimit) multiplied by a value of 25 (ThreadsPerChild). To increase MaxClients to a value that requires more than 16 processes, you must also raise ServerLimit.

Os valores abaixo sao os recomendados para a maioria dos sites:

Recommended values that are sufficient for most sites:

MinSpareServers 5
MaxSpareServers 10

StartServers 5

Na grande maioria das instalacoes a recomendaçao é definir keepalive como OFF
KeepAlive OFF