22 Mart 2014 Cumartesi

ORA-00314: log % of thread 1, expected sequence# % doesn't match


When switch to standby database

alert occur in alert logfile for standby redologs.

problem in alert.log file:

Errors in file /u01/oracle/diag/rdbms/oradb/oradb/trace/uc4prod_arc4_27349.trc:
ORA-00314: log 7 of thread 1, expected sequence# 292376 doesn't match 292348
ORA-00312: online log 7 thread 1: '/u02/oradata/oradb/std_redo01.log'


solution:

alter database clear unarchived logfile group 7;

9 Temmuz 2013 Salı

Re-link fails on target "client_sharedlib" when applying PSU




Verifying the update...
Make failed to invoke "/usr/bin/make -f ins_rdbms.mk client_sharedlib ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/db_1"....'genclntsh: genclntsh: Could not locate  /u01/app/oracle/product/11.2.0.3/dbhome_1/network/admin/shrept.lst
make: *** [client_sharedlib] Error 1
'
Make failed to invoke "/usr/bin/make -f ins_net_client.mk client_sharedlib ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/db_1"....'genclntsh: genclntsh: Could not locate  /u01/app/oracle/product/11.2.0.3/dbhome_1/network/admin/shrept.lst
make: *** [client_sharedlib] Error 1
'

The following make actions have failed :

Re-link fails on target "client_sharedlib".
Re-link fails on target "client_sharedlib".


check your shrep.lst file in $ORACLE_HOME/network/admin

11.2.0.3 shrep.lst   file entries should be:

# function entry points for genclntsh.sh

network : snaumihi_inithostinfo
network : snaumbg_gmt
network : naedpwd_encrypt
network : naumbsb_bld_singlebyte
network : ztapis
network : nlgh
network : ztvp52


5 Temmuz 2013 Cuma

ORA-00245: control file backup failed; target is likely on a local file system




with RAC environment

error:

INF - RMAN-03009: failure of backup command on ch00 channel at 06/04/2011 13:50:04
INF - ORA-00245: control file backup failed; target is likely on a local file system


check your SNAPSHOT CONTROLFILE parameter with RMAN
replace parameter shared location  or ASM location.



[oracle@testdb01 oracle]$ rman 

RMAN> connect target /

RMAN> show SNAPSHOT CONTROLFILE NAME;

CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0.3/db_1/dbs/snapcf_testdb1.f'; # default

RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+DATADG/snapcf_testdb.f';




4 Temmuz 2013 Perşembe

Linux dns TTL time control




[oracle@testdb01 ~]$   host -a testdb02


result sample of command:

;; QUESTION SECTION:
;testdb02 IN   A

;; ANSWER SECTION:
testdb02 492 IN A      192.168.3.24


492 is remaining time  of TTL.   if you try againg TTL is reduced




You can control on windows and unix with nslookup set debug on.





3 Temmuz 2013 Çarşamba

Create AWR report by sqlplus




set heading off;
set feedback off;
set linesize 1500;

select snap_id,dbid,begin_interval_time,end_interval_time from DBA_HIST_SNAPSHOT
order by 1;

replace your snap_id and dbid wtih following sql:

spool awr.html
select output from
table(dbms_workload_repository.awr_report_html(dbid,1,,));
spool off





Copy Table Statistics (DBMS_STATS)



--before 11g


DBMS_STATS.CREATE_STAT_TABLE ('APPUSER','MYSTATS_TAB');

delete from MYSTATS_TAB;
commit;

exec dbms_stats.unlock_table_stats('APPUSER','MYPART_TAB');

--export
exec dbms_stats.export_table_stats('APPUSER','MYPART_TAB','MYPART_TAB_201303','MYSTATS_TAB',NULL,TRUE,NULL);

update APPUSER.MYSTATS_TAB set c2='MYPART_TAB_201304';
commit;

--import
exec dbms_stats.import_table_stats('APPUSER','MYPART_TAB','MYPART_TAB_201304','MYSTATS_TAB',NULL);
commit;

exec dbms_stats.lock_table_stats('APPUSER','MYPART_TAB');



--11g or newer

exec dbms_stats.unlock_table_stats('APPUSER','MYPART_TAB');

exec DBMS_STATS.COPY_TABLE_STATS ('APPUSER','MYPART_TAB','MYPART_TAB_201303','MYPART_TAB_201304');

exec dbms_stats.lock_table_stats('APPUSER','MYPART_TAB');



28 Haziran 2013 Cuma

Change scan_listener port in 11.2



check current port

$GRID_HOME/bin/srvctl config scan_listener
SCAN Listener LISTENER_SCAN1 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN2 exists. Port: TCP:1521
SCAN Listener LISTENER_SCAN3 exists. Port: TCP:1521


--change port

$GRID_HOME/bin/srvctl modify scan_listener -p 8003

--change remote listener parameter

alter system set remote_listener=':' scope=both;


--restart scan_listener

$GRID_HOME/bin/srvctl stop scan_listener
$GRID_HOME/bin/srvctl start scan_listener


--confirm change

$GRID_HOME/bin/srvctl config scan_listener

SCAN Listener LISTENER_SCAN1 exists. Port: TCP:8003
SCAN Listener LISTENER_SCAN2 exists. Port: TCP:8003
SCAN Listener LISTENER_SCAN3 exists. Port: TCP:8003

ORA-12012: error on auto execute of job "EXFSYS"."RLM$EVTCLEANUP"


Catalog db has an error in alert.log like :

Errors in file /u01/diag/rdbms/rmandb/rmandb/trace/rmandb_j000_25520.trc:
ORA-12012: error on auto execute of job "EXFSYS"."RLM$EVTCLEANUP"
ORA-04068: existing state of packages has been discarded
ORA-04065: not executed, altered or dropped stored procedure "EXFSYS.DBMS_RLMGR_DR"
ORA-06508: PL/SQL: could not find program unit being called: "EXFSYS.DBMS_RLMGR_DR"
ORA-06512: at line 1

check invalid objects and compile it or run utlrp.sql

SQL> select count(*) from dba_objects where status='INVALID';

  COUNT(*)
----------
        0

SQL> @?/rdbms/admin/utlrp.sql

try againg and same error...
and flush shared_pool.

SQL> alter system flush shared_pool;
SQL> alter system flush buffer_cache;

try again and it works.

27 Haziran 2013 Perşembe

Debuging PL/SQL Procedure

Which privileges do you need?

grant debug any procedure to appuser;
grant debug connect session to appuser;

You must compile with debug option procedure before to run.

alter procedure my_proc compile debug;


http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_9013.htm#i2062318

DEBUGGING:
DEBUG CONNECT SESSION
Connect the current session to a debugger.
DEBUG ANY PROCEDURE
Debug all PL/SQL and Java code in any database object. Display information on all SQL statements executed by the application.
Note: Granting this privilege is equivalent to granting the DEBUG object privilege on all applicable objects in the database.



Interval partition


Interval partitioning is an extension to range partitioning.
You can use interval partition to automatically add new partitions.

Sample


CREATE TABLE mypart_table
(
  TARIH         DATE                            NOT NULL,
  KOD           NUMBER(5)                       NOT NULL,
  ALAN          VARCHAR2(600 BYTE),

)
PARTITION BY RANGE (TARIH)
(  
  PARTITION mypart_table_201303 VALUES LESS THAN (TO_DATE('2013-04-01', 'YYYY-MM-DD')),
  PARTITION mypart_table_201304 VALUES LESS THAN (TO_DATE('2013-05-01', 'YYYY-MM-DD')),
  PARTITION mypart_table_201305 VALUES LESS THAN (TO_DATE('2013-06-01', 'YYYY-MM-DD')),
  PARTITION mypart_table_201306 VALUES LESS THAN (TO_DATE('2013-07-01', 'YYYY-MM-DD'))
)
;


CREATE INDEX BANKDB.IDX_mypart_table_01 ON mypart_table
(TARIH, KOD)
LOCAL;


--add partition interval 1 day

alter table mypart_table set INTERVAL( NUMTODSINTERVAL(1,'DAY'));

You can't modify interval partitions. You can disable and enable again.

--disable interval 
ALTER TABLE mypart_table SET INTERVAL ();


When to Use Range or Interval Partitioning


24 Haziran 2013 Pazartesi

Export DDL with DBMS_METADATA



SQL>
exec dbms_metadata.set_transform_param(dbms_metadata.session_transform, 'SQLTERMINATOR', true);
exec dbms_metadata.set_transform_param(dbms_metadata.session_transform, 'STORAGE', false);
exec dbms_metadata.set_transform_param(dbms_metadata.session_transform, 'TABLESPACE', false);
exec dbms_metadata.set_transform_param(dbms_metadata.session_transform, 'SEGMENT_ATTRIBUTES', false);

select
  dbms_metadata.get_ddl('FUNCTION','SAMPLE_FUNC','APPUSER')
from dual;


14 Haziran 2013 Cuma

ORA-01111: name for data file 350 is unknown - rename to correct file



Error in alert.log

ORA-01111: name for data file 350 is unknown - rename to correct file
ORA-01110: data file 350: '/u01/app/oracle/product/11.2.0.3/dbs/UNNAMED00350'
ORA-01157: cannot identify/lock data file 350 - see DBWR trace file
ORA-01111: name for data file 350 is unknown - rename to correct file
ORA-01110: data file 350: '/u01/app/oracle/product/11.2.0.3/dbs/UNNAMED00350'
Recovery Slave PR00 previously exited with exception 1111
MRP0: Background Media Recovery process shutdown (ORCL)

--check broken filename on standby
SQL> select name from v$datafile where file#=350;

NAME
-------------------------------------------------------
/u01/app/oracle/product/11.2.0.3/dbs/UNNAMED00350

--modify parameter
alter system set standby_file_management=manual; 

--create datafile with correct filename

alter database create datafile '/u01/app/oracle/product/11.2.0.3/dbs/UNNAMED00350' as '/dev/ORCL/datadf130';

--modify parameter again to auto
alter system set standby_file_management=auto;

--start recovery
alter database recover managed standby database disconnect from session;

--check mrp
select process, status , sequence# from v$managed_standby;

11 Haziran 2013 Salı

Using JDBC with Firewalls

from Oracle® Database JDBC Developer's Guide and Reference

http://docs.oracle.com/cd/B19306_01/java.102/b14355/apxtblsh.htm#CHDBBDDA

Firewall timeout for idle-connections may sever a connection. This can cause JDBC applications to hang while waiting for a connection. You can perform one or more of the following actions to avoid connections from being severed due to firewall timeout:
  • If you are using connection caching or connection pooling, then always set the inactivity timeout value on the connection cache to be shorter than the firewall idle timeout value.
  • Pass oracle.net.READ_TIMEOUT as connection property to enable read timeout on socket. The timeout value is in milliseconds.
  • For both JDBC OCI and JDBC Thin drivers, use net descriptor to connect to the database and specify the ENABLE=BROKEN parameter in the DESCRIPTIONclause in the connect descriptor. Also, set a lower value for tcp_keepalive_interval.
  • Enable Oracle Net DCD by setting SQLNET.EXPIRE_TIME=1 in the sqlnet.ora file on the server-side.

14 Aralık 2012 Cuma

Handling PL/SQL Errors


Good article to understand error management with PL/SQL




http://www.oracle.com/technetwork/issue-archive/2005/05-mar/o25plsql-093886.html

8 Ağustos 2012 Çarşamba

How to call External Procedure from Oracle Database




create a file which has name "shell.c"

content of shell.c file
------------------------------------
#include
#include
#include

void sh(char *);

void sh( char *cmd )
{
int num;

num = system(cmd);
}
------------------------------------

--create object file
[oracle@host01 lib]$  gcc -fPIC -g -c -Wall shell.c

--create shared library file
[oracle@host01 lib]$  gcc -shared -o shell.so shell.o


modify parameter in $ORACLE_HOME/hs/admin/extproc.ora file

SET EXTPROC_DLLS=/home/oracle/lib/shell.so

--create lib and procedure for test

CREATE OR REPLACE LIBRARY SHELL_LIB
 IS '/home/oracle/lib/shell.so'
/

CREATE OR REPLACE PROCEDURE "SHELL" (cmd IN char)
as external
name "sh"
library shell_lib
language C
parameters (cmd string);
/


SQL> exec shell('/bin/pwd > /home/oracle/lib/aa.txt');


output file looks like

[oracle@host01 lib]$ more aa.txt
/u01/oracle/11.2.0.3/dbs



ORA-28575: unable to open RPC connection to external procedure agent


10 Temmuz 2012 Salı

RMAN ORA-01008: not all variables bound


Recovery Manager: Release 11.2.0.2.0 - Production on Tue Jul 10 10:33:11 2012

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

RMAN> connect target /


DBGSQL:     TARGET> select count(*) into :dbstate from v$parameter where lower(name) = '_dummy_instance' and upper(value) = 'TRUE'
DBGSQL:        sqlcode = 1008
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
ORA-01008: not all variables bound




workaround:

SQL>alter system flush shared_pool;


20 Haziran 2012 Çarşamba

Oracle database trigger order


Oracle Database fires multiple triggers in an unspecified, random order, if more than one trigger of the same type exists for a given statement; that is, triggers of the same type for the same statement are not guaranteed to fire in any specific order.

Execution steps of trigger.
http://docs.oracle.com/cd/B28359_01/server.111/b28318/triggers.htm#CNCPT418


 DBA_TRIGGER_ORDERING description
http://docs.oracle.com/cd/B28359_01/server.111/b28320/statviews_2107.htm#REFRN20581

sample:

create or replace trigger trigger_01
before insert on test
for each row
follows trigger_02
....


create or replace trigger trigger_02
before insert on test
for each row




15 Haziran 2012 Cuma

sqlplus ORA-01031: insufficient privileges


You want to connect intance to start.(oracle 11g)

but there is an error.

like


[oracle@oratest01 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.2.0 Production on Tue Jun 23 02:00:05 2009

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

ERROR:
ORA-01031: insufficient privileges


1-Check groups in linux.(if dba group doesn't exist firstly create it)

more /etc/group
.
....

oinstall:x:500:
dba:x:501:oracle


2-Check your oracle user groups

more /etc/passwd
.
....
oracle:x:500:500::/home/oracle:/bin/bash



[root@oratest01 ~]# id oracle
uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba)




12 Haziran 2012 Salı

RMAN-20032: checkpoint change# too low



If you use catalog for backup


RMAN> resync database;
RMAN-20032: checkpoint change# too low

If database returned from cold backup resync can't be succesful.

solution

connect target /
connect catalog user@catdb

unregister database;
register database;



Veritas Volume Manager


Useful command samples for Veritas Volume Manager.

http://www.hyborian.demon.co.uk/notes/vx_cli.html