Monday, April 1, 2019

Enabling Flashback Database and checking the status

Enabling Flashback Database and checking the status
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Flashback status of a database can be checked from the below query and system parameters.


Enabling Flashback Database
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1. you can either revert the entire database to a prior point in time by restoring a backup and doing point-in-time recovery,
2. or you can enable Flashback Database.

When you enable Flashback Database, the database generates flashback logs in the fast recovery area.
These logs are used to flash back the database to a specified time.
During usual operation, the database occasionally logs images of data blocks to the flashback logs.
The database automatically creates, deletes, and resizes flashback logs.


command to check if Flashback Database is enabled for your target database:


To enable Flashback Database:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ensure that you configure a fast recovery area and that the database is running in ARCHIVELOG mode.


Connect Oracle Recovery Manager (RMAN) to the target database

Optionally, specify the length of the desired flashback window (in minutes) by setting the DB_FLASHBACK_RETENTION_TARGET initialization parameter.
The default value for this parameter is 1440 minutes, which is one day.
The following command specifies that the flashback window must be 3 days.




Enable the Flashback Database feature for the whole database using the following command:



You can also execute the commands in this section by connecting to the target database using SQL*Plus instead of RMAN.




Thursday, March 28, 2019

ORA-00314: log 42 of thread 2, expected sequence# 37363 doesn’t match 37361 and ORA-01624: log 1 needed for crash recovery of thread 1

ORA-00314: log 42 of thread 2, expected sequence# 37363 doesn’t match 37361
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ORA-01624: log 1 needed for crash recovery of thread 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

recover database until  cancel give above error
and clear log file gives below error

ERROR at line 1:
ORA-01624: log 1 needed for crash recovery of thread 1
ORA-00312: online log 1 thread 1: '//'
ORA-00312: online log 1 thread 1: '//'

To implement the solution, please execute the following steps:

1) Switch the logfile on primary so that group can become non-current.

connect / as sysdba
alter system switch logfile;



2) Copy from primary to standby.
If you are  working with Group 1 on the primary then copy both  files for group 1 from the primary to the standby machine into an alternate location at operating system level.


3) Move current group one files on the standby to a different location


4) Rename the logfile- Move the copied  redo logs into the group 1 current location

ALTER DATABASE RENAME FILE
'/FULL_PATH_OF_OLD_LOCATION/AND_REDO_LOG_NAME.LOG'
TO
'/FULL_PATH_OF_NEW_LOCATION/AND_REDO_LOG_NAME.LOG';



5) Clear the logfile :

alter database clear logfile group;


6)alter database drop standby logfile group1 .



Clear standby redo with ora-314 error.

Stop recovery on standby side.

SQL> Alter database recover managed standby database cancel;

clear standby redo group 404. -



SQL>  alter database clear logfile group 404


You may have to use the 'unarchived'-Keyword to be able to clear the Standby RedoLog Group in most Cases, eg.

SQL> alter database clear unarchived logfile group 404;



another good solution is to copy the requested archive log into restored database, and recover database

1. copy the next 2-3 archives to target database same location or  different location(if it is different location, register the archive location through RMAN using below command )
CATALOG START WITH 'location path';


2.alter database recover database until cancel;
enter auto, when prompted

3.open database with resetlogs.

for better safety, shut immediate and startup the database.




ORA-00313: open failed for members of log group string of thread string tips

ORA-00313: open failed for members of log group string of thread string tips

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

At this article I shall present how to resolve open failed for members of log groups. 
So last night i have seen many errors about those groups. 
I wanted to recreate my redo log groups however as my research there was an other solution. 


The Oracle docs note this on the ora-00313 error:
ORA-00313: open failed for members of log group string of thread string

Cause: The online log cannot be opened. May not be able to find file.

Action: See accompanying errors and make log available.


1.solution

 1-Check status of log file group

SQL> select group#,thread#,status from v$log ;

GROUP# THREAD# STATUS
---------- ---------- ----------------
1 1 INACTIVE
2 1 ACTIVE
3 1 CURRENT


2- Clear logfile.
SQL> alter  database clear unarchived logfile group 1;
Database altered.


3-check again groups.

SQL> select group#,thread#,status from v$log ;
GROUP# THREAD# STATUS
---------- ---------- ----------------
1 1 UNUSED
2 1 ACTIVE
3 1 CURRENT


5-Switch log file to use

SQL>Alter system switch logfile;


6-check again groups.

SQL> select group#,thread#,status from v$log ;
GROUP# THREAD# STATUS
---------- ---------- ----------------
1 1 CURRENT
2 1 INACTIVE
3 1 ACTIVE

So, that's it. if you have problem with an other log try for others to. 
İf so you have problem again try 2 solution.



2.Solution

1-CLOSE DATABASE.

SQL>shu immediate;
Database closed.

2-Check the status of the logile 
select
 b.group#, a.archived, a.status, b.status, b.member
from
 v$log a, v$logfile b
where a.group#=b.group#
order by 1,2;

    GROUP# ARC STATUS           STATUS  MEMBER
---------- --- ---------------- ------- ----------------------------
         1 YES   INACTIVE            /u01/app/oracle/oradata/redo01.log
         2 YES   ACTIVE               /u01/app/oracle/oradata/redo02.log
         3 NO    CURRENT            /u01/app/oracle/oradata/redo03.log

 If the status is CURRENT don't try do drop.


3. Drop log group
SQL>ALTER DATABASE DROP LOGFILE GROUP 1;


4-Add new Redo Log by :

SQL>ALTER DATABASE ADD LOGFILE GROUP 1 ' /u01/app/oracle/oradata/redo01.log' SIZE 50M;


4-Recover DB and Open

SQL>RECOVER DATABASE UNTIL CANCEL;
SQL>ALTER DATABASE OPEN RESETLOGS;





Monday, February 18, 2019

DataPump Export (EXPDP) Creates Excessive Traces Even If It Runs Successfully (Doc ID 1154963.1)

DataPump Export (EXPDP) Creates Excessive Traces Even If It Runs Successfully (Doc ID 1154963.1) To BottomTo Bottom


APPLIES TO:
Oracle Database - Enterprise Edition - Version 11.2.0.1 and later
Information in this document applies to any platform.

SYMPTOMS



Traces are typically < 100K in length. If the EXPDP run was successful the traces contain no error messages, if EXPDP raises an internal 600/7445 or other errors the traces might contain some equivalent information.


SOLUTION
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




Monday, February 11, 2019

RANGE - Interval Partitioning In Oracle

Range Interval Partitioning In Oracle

Interval Partitioning has been introduced in oracle 11g.
With this method, we can automate the creation of range partition .
While creating the partitioned table, we just need to define one partition.
New partitions will be created automatically based on interval criteria when the data is inserted to the table. We don’t need to create the future partitions.

1. Lets create a monthly partitioned table ( with interval).





Here the date 2016-05-01 is known as TRANSIT POINT . Any data inserted beyond this transit point will led to creation of a new partition automatically.

INTERVAL clause used to calculate the range for new partitions when the values go beyond the existing transition point



2. Now check dba_tab_partitions




3. Lets insert some data and check the dba_tab_partitions:




We can see a new monthly partition has been created automatically .

Similarly

for weekly partition use the parameter – INTERVAL (numtodsinterval(7,’day’))
for yearly partition use the parameter – INTERVAL (NUMTOYMINTERVAL(1,’YEAR’))



Convert Existing Range partitioned table to interval partition:



Restriction of Interval Partitioning:

1. Cannot be created for Index organized table(IOT)

2. The partitioning column can be only one and it must be of type NUMBER or DATE

3. Cannot use the MAXVALUE clause