Thursday 23 May 2013

ORA-16038: log 1 sequence# 35 cannot be archived ORA-19809: limit exceeded for recovery files

ORA-16038: log 1 sequence# 35 cannot be archived
ORA-19809: limit exceeded for recovery files

This error comes if there is no space  in  flash_recovery_area

  • Delete expired  archive log
  • Increase size of  flash_recovery_area


SQL> startup
ORACLE instance started.

Total System Global Area  910163968 bytes
Fixed Size                  2024976 bytes
Variable Size             281020912 bytes
Database Buffers          620756992 bytes
Redo Buffers                6361088 bytes
Database mounted.
ORA-16038: log 1 sequence# 35 cannot be archived
ORA-19809: limit exceeded for recovery files
ORA-00312: online log 1 thread 1:
'/home/oracle/10.2.0/product/oradata/MYDB/redo01.log'


You can check the total and used size using below query

SQL> select name
,floor(space_limit / 1024 / 1024) "Size MB"
,ceil(space_used / 1024 / 1024) "Used MB"
from v$recovery_file_dest
order by name  2    3    4    5
  6  /

NAME
--------------------------------------------------------------------------------
   Size MB    Used MB
---------- ----------
/home/oracle/10.2.0/product/flash_recovery_area
      2048       2034

Now you can increase the size of    flash_recovery_area

SQL> alter system set db_recovery_file_dest_size = 5G scope=both;

System altered.

SQL>  alter database open;

Database altered.


You can also  delete the  expired archive logs

 RMAN> crosscheck archivelog all;
 RMAN> delete expired archivelog all;

Wednesday 15 May 2013

how to check nls_characterset parameter of database

SQL> SELECT value$ FROM sys.props$ WHERE name = 'NLS_CHARACTERSET';
VALUE$
--------------------------------------------------------------------------------
WE8ISO8859P1

SQL>  SELECT value$ FROM sys.props$ WHERE name = 'NLS_NCHAR_CHARACTERSET';
VALUE$
--------------------------------------------------------------------------------
AL16UTF16

Resize / recreate / crate/ drop redo log files

We cannot resize the redo log files. We must drop the redo log file and recreate them .This is only method to resize the redo log files.
We cannot the drop redo log file if its status is current or active. We need to change the status to "inactive" then only we can drop it.
A database requires at least two groups of redo log files , regardless the number of the members.
When a redo log member is dropped from the database, the operating system file is not deleted from disk. Rather, the control files of the associated database are updated to drop the member from the database structure. After dropping a redo log file, make sure that the drop completed successfully, and then use the appropriate operating system command to delete the dropped redo log file.

  • Here we are changing 1GB to 2GB redolog size  first check datafile size and status from v$redolog

SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 25 1073741824 2 NO CURRENT 794921 20-SEP-12
2 1 24 1073741824 2 NO ACTIVE 794904 20-SEP-12
3 1 23 1073741824 2 NO ACTIVE 794833 20-SEP-12


  • We can find the redo log group member information from v$logfile hare is two members in redo log file


SQL> select * from v$logfile;

GROUP# STATUS TYPE MEMBER
---------- ------- ------- ---------------------------------------------------
3 ONLINE E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL10G\REDO03.LOG
2 ONLINE E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL10G\REDO02.LOG
1 ONLINE E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL10G\REDO01.LOG
1 ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL10G\RDO01A.LOG
2 ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL10G\RDO02A.LOG
3 ONLINE C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL10G\RDO03A.LOG


  • We collect the information about redo log member now we have needed to drop and recreate the redo with bigger size.


NOTE:  don’t drop current or active member first change it into

SQL> alter database drop logfile group 1;
alter database drop logfile group 1
*
ERROR at line 1:
ORA-01623: log 1 is current log for instance orcl10g (thread 1) - cannot drop
ORA-00312: online log 1 thread 1: 'E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL10G\REDO01.LOG'
ORA-00312: online log 1 thread 1: 'C:\RDO01A.LOG'



  • Switch logfile from current status means now log writer start writing in next redolog group .

SQL>alter system switch logfile;
SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 25 209715200 2 NO ACTIVE 794921 20-SEP-12
2 1 24 209715200 2 NO ACTIVE 794904 20-SEP-12
3 1 26 209715200 2 NO CURRENT 794996 20-SEP-12


  • To make active to inactive you need to be perform checkpoint on the system .means all changes from redolog group to written into datafile

SQL> alter system checkpoint;
System altered.

SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 25 209715200 2 NO INACTIVE 794921 20-SEP-12
2 1 24 209715200 2 NO INACTIVE 794904 20-SEP-12
3 1 26 209715200 2 NO CURRENT 794996 20-SEP-12


  • Now you can drop the redo log group

SQL> alter database drop logfile group 1;

Database altered.
       
  • Add the redolog group with required size

SQL> alter database add logfile group 1 ('E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL10G\REDO01.LOG','C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL10G\RDO01A.LOG') size 2G reuse;

Database altered.

Now resize the other redo group also


SQL> alter database drop logfile group 2;

Database altered.

SQL> alter database add logfile group 2 ('E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL10G\REDO02.LOG','C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL10G\RDO02A.LOG') size 1G reuse;

Database altered.

SQL> alter database drop logfile group 3;

Database altered.

SQL> alter database add logfile group 3 ('E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL10G\REDO03.LOG','C:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL10G\RDO03A.LOG') size 1G reuse;

Database altered.

SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------

1 1 14 2147483648 1 NO CURRENT 786787 20-SEP-12

2 1 12 2147483648 1 NO INACTIVE 786729 20-SEP-12

3 1 13 2147483648 1 NO INACTIVE 786746 20-SEP-12

TNS-01189 the listener could not authenticate the user lsnrctl


Error:

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 15-MAY-2013 04:56:27
Copyright (c) 1991, 2011, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=servername)(PORT=1522)))
TNS-01189: The listener could not authenticate the user

Analysis:

This happened after the oracle home was cloned.

The listener is still using the old server in the listener.ora. The fix is to update the server name in the listener.ora of new server to have the values of the  new server name.

Thursday 9 May 2013

ORA-04030: out of process memory when trying to allocate

What does an ORA-4030 mean?

This error indicates that the oracle server process is unable to allocate more memory from the operating system.This memory consists of the PGA (Program Global Area) and its contents depend upon the server configuration.For dedicated server processes it contains the stack and the UGA (User Global Area) which holds user session data, cursor information and the sort area. In a multithreaded configuration (shared server), the UGA is allocated in the SGA (System Global Area) and will not be responsible for ORA-4030 errors.

What causes this error?

Since you run into this error, you can't allocate memory from the operating system. This could be caused by your process itself, like your process is just requesting too much memory, or some other reasons cause the operating system memory to be depleted, like a too big SGA or too many processes to be accomodated for the systems virtual memory (physical memory + swap space). Many operating systems impose limits on the amout of memory a single process can acquire to protect itself.This leads to the following questions:

Is there an operating system limit set?

You can check limit information’s using >ulimit –a  and find the information  related to memory using vmstat

vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
 1  0 5511440 243988 213924 92768888    1    1  1860   639    0    0  7  0 91  2  0


vmstat output contains the following fields:

Procs – r: Total number of processes waiting to run
Procs – b: Total number of busy processes
Memory – swpd: Used virtual memory
Memory – free: Free virtual memory
Memory – buff: Memory used as buffers
Memory – cache: Memory used as cache.
Swap – si: Memory swapped from disk (for every second)
Swap – so: Memory swapped to disk (for every second)
IO – bi: Blocks in. i.e blocks received from device (for every second)
IO – bo: Blocks out. i.e blocks sent to the device (for every second)
System – in: Interrupts per second
System – cs: Context switches
CPU – us:CPU user time
sy:system time
id:idle time
wa:wait time



Which process is requesting too much memory?

It's usually a good idea to confirm the process memory usage from the Operating System point of view. After all, it might no be an oracle server process that is using too much memory.Usually, for server processes, oracle and the operating system more or less agree on memory usage. The following command will allow you to find out the memory usage for processes from the operating system.

SELECT SID,NAME,VALUE
        FROM          v$statname n,v$sesstat s
        WHERE    n.STATISTIC# = s.STATISTIC# AND
             NAME LIKE 'session%memory%'        ORDER BY 3 ASC;


How to collect information on what the process is actually doing

You can check in v$sqlarea what is beeing executed with the following query:


SELECT
           sql_text
         FROM
            v$sqlarea a, v$session s
         WHERE a.address = s.sql_address AND
                  s.SID =&SID

an trace using event 4030
Alter session set events '4030 trace name heapdump level 5';
Wecan collect Incident details from the location of oracle diagnostic and send to oracle support
We  can generate ARD report and summit to oracle support for solution  


General suggestions on avoiding this error

·          We can force a heapdump and have it examined by oracle support services:

·          Use ADRCI or Support Workbench to package the incident.

·          As mentioned before, some operations just require a lot of memory. For sort issues, decreasing SORT_AREA_SIZE can help. The Oracle server process will allocate SORT_AREA_SIZE bytes in the PGA for sort operations. When more memory is required to complete the search, the server process will use a temporary segment. This means that lowering SORT_AREA_SIZE can have a performance impact on queries requiring huge sort operations.

·          With 9i and higher, the automatic SQL execution memory management feature is enabled by setting the parameter WORKAREA_SIZE_POLICY to AUTO and by specifying a size of PGA_AGGREGATE_TARGET in the initialization file. Using automatic PGA memory management will help reduce the possibility of ORA-4030 errors. Please note that PGA_AGGREGATE_TARGET is NOT supported on OpenVMS in Oracle 9i, but it is in Oracle 10g.  Refer to the following notes for more details:

·          "Performance Issues After Increasing Workload",
·          "Automatic PGA Memory Managment",
·          "Top Oracle 9i init.ora Parameters Affecting Performance"

·          PL/SQL procedures can also allocate lots of memory, so it might be required to rewrite some parts of your application. While a PL/SQL table is easy to use, it does require memory to be allocated in the PGA.

·          Review the optimizer strategy, some access paths might need more memory due to sort operations, the use of functions on more rows,...

·          On some operating systems, like Microsoft windows, the size of the SGA might be decreased to allow bigger PGA's.

·          Make sure your operating system and oracle limits are set reasonably.

·          Make sure there is enough memory available (physical memory and swapspace)

   

Recove datafile without backup

IF you newly created datafile has gone and you didn’t get change to take backup after creation if your database in archive mode then you will be recover the datafile just you need to create the datafile before recovery.   


SQL> startup
ORACLE instance started.

Total System Global Area  910163968 bytes
Fixed Size                  2024976 bytes
Variable Size             268438000 bytes
Database Buffers          633339904 bytes
Redo Buffers                6361088 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/home/oracle/10.2.0/product/oradata/MYDB/users02.dbf'

You cant restore the datafile as you don’t have backup .hence you have to create a datafile as reference of old datafile. And recover datafile

SQL>  alter database create datafile '/home/oracle/10.2.0/product/oradata/MYDB/users02.dbf' AS '/home/oracle/10.2.0/product/oradata/MYDB/users02.dbf'  ;

Database altered.

SQL> reocver datafile 5;
SP2-0734: unknown command beginning "reocver da..." - rest of line ignored.
SQL> recover datafile 5;
ORA-00279: change 578628 generated at 05/08/2013 09:17:47 needed for thread 1
ORA-00289: suggestion :
/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_09/o1_mf
_1_5_%u_.arc
ORA-00280: change 578628 for thread 1 is in sequence #5


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
auto
ORA-00279: change 623425 generated at 05/08/2013 10:26:43 needed for thread 1
ORA-00289: suggestion :
/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_09/o1_mf
_1_6_%u_.arc
ORA-00280: change 623425 for thread 1 is in sequence #6
ORA-00278: log file
'/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_08/o1_m
f_1_5_8rmprcx7_.arc' no longer needed for this recovery


ORA-00279: change 727053 generated at 05/08/2013 11:11:46 needed for thread 1
ORA-00289: suggestion :
/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_09/o1_mf
_1_7_%u_.arc
ORA-00280: change 727053 for thread 1 is in sequence #7
ORA-00278: log file
'/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_08/o1_m
f_1_6_8rmsdtrz_.arc' no longer needed for this recovery


ORA-00279: change 727988 generated at 05/08/2013 11:12:26 needed for thread 1
ORA-00289: suggestion :
/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_09/o1_mf
_1_8_%u_.arc
ORA-00280: change 727988 for thread 1 is in sequence #8
ORA-00278: log file
'/home/oracle/10.2.0/product/flash_recovery_area/MYDB/archivelog/2013_05_08/o1_m
f_1_7_8rmsg2lw_.arc' no longer needed for this recovery


Log applied.
Media recovery complete.

SQL>  alter database open;

Database altered.



After open the database you can check the status of  datafile


SQL>  select file_name,status from v$datafile;
 select file_name,status from v$datafile
        *
ERROR at line 1:
ORA-00904: "FILE_NAME": invalid identifier


SQL> select name ,status from v$datafile;

NAME
--------------------------------------------------------------------------------
STATUS
-------
/home/oracle/10.2.0/product/oradata/MYDB/system01.dbf
SYSTEM

/home/oracle/10.2.0/product/oradata/MYDB/undotbs01.dbf
ONLINE

/home/oracle/10.2.0/product/oradata/MYDB/sysaux01.dbf
ONLINE


NAME
--------------------------------------------------------------------------------
STATUS
-------
/home/oracle/10.2.0/product/oradata/MYDB/users01.dbf
ONLINE

/home/oracle/10.2.0/product/oradata/MYDB/users02.dbf
ONLINE