Tuesday, June 17, 2025

 RMAN Recovery Catalog

About Recovery Catalog

RMAN recovery catalog Is another database which is out of your normal databases or which is on a separate server and which will save only the details of your backups in terms of metadata of the backup.

Whenever you trigger the backup, RMAN will Update the information in the control file. Your control files can store the backup details for the last 30 days only which is the default 30 days retention period.

Suppose you want to have the details of the backups which are taken before 30 days. The recovery catalog will help you in this case to store the history backup details.

Importance of Recovery Catalog

  • RMAN stores the backup information into the control file
  • If we lose control file, we lose all the backup information
  • Even though the backups are available, they are not usable. If you lose the control file, the backups are of no use as Oracle or RMAN doesn’t know which backup belongs to which database. The reason behind this is the information is stored in the control file which you lost
  • To resolve all the above three issues, we use recovery catalog.
  • Recovery catalog is a separate database that stores backup information
  • One recovery catalog can store multiple target database backup information
  • You don’t have to create multiple recovery catalog for multiple target databases. You can create one recovery catalog database for all the databases or servers

 

Benefits of Recovery catalog

  • It helps in database recovery when you lose the control file
  • You can use recovery catalog for backups reporting also
  • You can write RMAN scripts in recovery catalog and save them
  • You can store RMAN scripts in recovery catalog
  • Store long term backup history
  • Cloning with PITR (Point in time recovery) becomes easier as the recovery catalog knows which Control file is required
Note: These RMAN scripts are your backup scripts or your recovery scripts. You don’t have to use OS level scripts to take the database backup. The primary requirement to have the RMAN scripts is to have the recovery catalog
 

Recovery catalog configuration

Below are the steps to configure RMAN recovery catalog on a separate machine, install Oracle database. Then Create a small database with SID as rcat. 

 

Remember recovery catalog resides on a separate server and that is why you need to configure a separate machine

Create a default tablespace under rcat database which will be used for backup information storage

SQL> create tablespace rmantbs datafile '/u01/app/oracle/oradata/rcat/rmantbs01.dbf' size 50mb;

You can create a small tablespace and keep on adding the space when You get some alerts or when the database throws some errors. We are going with the very small size of 50 MB.

Next, Create a user which will be used to connect recovery catalog and store backup information. We will create the user rman_rc to connect to the recovery catalog. This user rman_rc will store the information into rmantbs tablespace

SQL> create user rman_rc identified by rman_rc default tablespace rmantbs temporary tablespace temp;

Grant permissions to rman_rc user

SQL> grant connect,resource,recovery_catalog_owner to rman_rc;

 

In this command, recovery_catalog_owner should be granted a permission to the user rman_rc otherwise we cannot use the user for the recovery catalog.

Next, Configure networking between target server and catalog server. Make sure to add tns entry details of catalog server on target server. In my case, below is the tns entry of catalog server

rcat = 
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.102)(PORT = 1521)
      )
    (CONNECT_DATA =
      (SERVICE_NAME = rcat)
    )
  )    

On target server, start RMAN utility and connect only the catalog database. We will not create catalog on the catalog database

rman catalog rman_rc/rman_rc@rcat

RMAN> create catalog;

This will create all the necessary tables and views which are required to store the backup information in the user rman_rc and into the database rman_rc@rcat

Exit RMAN and now connect both target and catalog database

rman target / catalog rman_rc/rman_rc@rcat

We need to register our target database to the recovery catalog database. Use below command to register target database into catalog database:

RMAN> register database;








You can see the statement in the above screenshot: starting full resync of recovery catalog. It means that whatever backup information available in the proddb file is now updated also in the recovery catalog.

Full resync complete means that your control files backup information and the recovery file backup information are updated.

 

Wednesday, November 27, 2024

 

RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time

https://shivanandarao-oracle.com/2012/12/05/rman-20207-until-time-or-recovery-window-is-before-resetlogs-time/

KB0013276

When you are performing a PITR (Point In Time Recovery), you might have undergone the error “RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time”. The reason that RMAN throws this error is when you are trying to perform a PITR of the database to a time before the database was last opened with RESETLOGS. In other words, the time you specify in the “until time” clause of RMAN is the time that the database was in its previous incarnation and not the CURRENT incarnation.


RMAN threw an error saying “RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time”.

executing command: SET until clause
Starting restore at 01-DEC-12
Starting implicit crosscheck backup at 01-DEC-12
RMAN-00571: ===================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =======
RMAN-00571: ===================================================
RMAN-03002: failure of restore command at 12/01/2012 20:26:41

RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time

RMAN is trowing this error because the incarnations of the database not matching with PITR. 
Run the “list incarnation” command at RMAN prompt.

 
rman target / catalog /@<rman catalog>

RMAN>spool log to <caseid>_restore.log
RMAN>set echo on
RMAN>ALTER SESSION SET NLS_DATE_FORMAT = 'dd/mm/yyyy hh24:mi:ss';
RMAN>list incarnation of database;
 

DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
294105469 294105470 AMALPRD1 1914393966       PARENT  1          21-AUG-2023 01:21:50
294105469 625758845 AMALPRD1 1914393966       CURRENT 9029509056 26-NOV-2024 15:39:15

** reset database to incarnation <n>;  <-- only if required; n = the appropriate INC Key that your restore until_time falls into, i.e. before resetlogs time)

RMAN> reset database to incarnation 1;

run {
  allocate channel ch00 type disk;
  set until time= "to_date('14/06/2022 14:30:00','dd/mm/yyyy hh24:mi:ss')";
  restore database preview summary;
  release channel ch00;
}

shutdown immediate;
** set dbid=<dbid>;  <-- only required if the DBID is different, otherwise no need to set it.

run {
startup nomount;
set until time= "to_date('14/06/2022 14:30:00','dd/mm/yyyy hh24:mi:ss')";
restore controlfile;
alter database mount;
restore database;
recover database;
}
alter database open resetlogs;
select * from v$instance;
select con_id, dbid, name, open_mode, restricted, open_time from v$containers;

spool log off;
exit;

Wednesday, April 10, 2024


Query to Check available Space of an Oracle Database


Login to the database as SYS user

sqlplus as / sysdba

Then copy and paste below sql query in the command line or PL/SQL editor

select round(sum(used.bytes) / 1024 / 1024 / 1024 ) || ' GB' "Database Size",
round(sum(used.bytes) / 1024 / 1024 / 1024 ) -
round(free.p / 1024 / 1024 / 1024) || ' GB' "Used space",
round(free.p / 1024 / 1024 / 1024) || ' GB' "Free space"
from (select    bytes
from v$datafile
union all
select bytes
from v$tempfile
union all
select bytes
from v$log) used,
(select sum(bytes) as p from dba_free_space) free
group by free.p;

Wednesday, October 26, 2022

 

Windows: How To Delete and Recreate the TNS Listener Service When the Service Fails To Start Consistently At Machine Reboot (Doc ID 313250.1)


APPLIES TO:

Oracle Net Services - Version 8.1.7.4.0 and later
Microsoft Windows x64 (64-bit) - Version: 2008 R2
Microsoft Windows (32-bit)
Microsoft Windows (32-bit)Microsoft Windows

GOAL

Oracle TNS Listener service fails to start automatically at boot time (e.g. after moving Windows Server to new location) or fails to start manually.

SOLUTION

You need to re-create the Windows service associated to the Oracle listener by deleting the Windows service and creating a new service for the Oracle TNS Listener.

1. Deleting the service

At your earliest convenience, or next scheduled maintenance window, delete and recreate the Windows service associated to the Oracle TNS Listener. You can do this either with the help of a tool (recommended) or by hand-editing the registry. In both cases you need to stop the listener service before making any changes.

Using a tool
There are quite a few tools to manipulate Windows services, in the Resource Kit or from third parties. Also there is a tool called SC and which is available in the base Windows distribution (at least for Windows XP and Windows 2003).

  1. Lookup the windows service name that you want to remove — use Properties in the Windows Services panel to copy the full name
  2. Open a Command Prompt window and run the following:
    sc delete <your_windows_Service_name>
  3. Check that the Windows service has been removed — use F5/Refresh in the Windows Services panel

In case you do not have the SC tool available then you need to download the Windows Resource Kit — there you will find the instsrv.exe tool.

  1. Lookup the windows service name that you want to remove — use Properties in the Windows Services panel to copy the full name
  2. Open a Command Prompt Window and run the following:
    instsrv /deleteService <your_windows_Service_name>
  3. Check that the Windows service has been removed — use F5/Refresh in the Windows Services panel


Manually editing the Windows Registry

Warning: editing the Windows Registry by hand is dangerous and may render your system unusable. Proceed at your own risk !


You need to follow these steps:

  • Launch the Registry Editor (e.g. Start / Run / regedit )
  • Drill down to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services
  • Locate and delete the the key which contains your Oracle Home name and your listener name (e.g. OracleOraHomeTNSListenerName)
  • Reboot the system

 

2. Creating the new service

When started and logged on as the Oracle user, go to a Command Prompt and start the listener:

lsnrctl start <listener_name>

Replace <listener_name> with the name of your listener; if you are operating on the default listener then you may use the value LISTENER or leave it empty.

An OS error 1060 will be seen (which is normal as the Windows service is missing and is being created); the listener should start correctly.

3. Test the listener

Once started the listener is started, check that a Windows service for the TNS Listener was created in the Window Services panel and set to startup automatically (change if necessary). Then test the automatic listener startup by performing another reboot.

Tuesday, September 27, 2022

 

How to recover missing datafiles?

ORA-01110: ORA-01565:  ORA-27041

Recovery of SID went wrong though the DB opened successfully because unfortunately we used old control file and missed almost 11 data files in controlfile.sql file and which created soft link in dbs path.

In order to overcome the situation below steps performed and database become consistent. If in case in the future if we face same issue, we can use below steps confidently.

1) Find the missing datafiles:

SQL> set line 250

SQL> col FILE_NAME for a45
SQL> select FILE_NAME,FILE_ID,TABLESPACE_NAME,ONLINE_STATUS from dba_data_files;
/oracle/SID/121/dbs/MISSING00268                     268 PSAPSID  ONLINE
/oracle/SID/121/dbs/MISSING00269                     269 PSAPSID ONLINE
 
2) Take tablespace or datafiles offline:
Come with below error because data file already in offline
SQL> alter database datafile ‘/oracle/SID/sapdata/sapdata2/gp1_242/gp1.data242’ offline;
Database altered.
SQL> alter database datafile ‘/oracle/SID/sapdata/sapdata2/gp1_243/gp1.data243’ offline;
Database altered.
 
3) Rename missing datafiles with original files: 
SQL> alter database rename file ‘/oracle/SID/121/dbs/MISSING00268’ to ‘/oracle/SID/sapdata/sapdata2/gp1_242/gp1.data242’;
SQL> alter database rename file ‘/oracle/SID121/dbs/MISSING00269’ to ‘/oracle/SID/sapdata/sapdata2/gp1_243/gp1.data243’;
4) Shutdown and mount the database:
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 6.4425E+10 bytes
Fixed Size                  3729840 bytes
Variable Size            7381976656 bytes
Database Buffers         5.6908E+10 bytes
Redo Buffers              130486272 bytes
Database mounted.
5) Perform media recovery:
SQL> recover datafile 268;
Media recovery complete.
SQL> recover datafile 279;
Media recovery complete.
6) Open the database:
SQL> alter database open;
Database altered.
7) check the status of datafiles:
SQL> set line 250
SQL> col FILE_NAME for a45
SQL> select FILE_NAME,FILE_ID,TABLESPACE_NAME,ONLINE_STATUS from dba_data_files;  – After recovery data files online_status went recover to offline.
8) Bring the datafiles online:
SQL> alter database datafile ‘/oracle/SID/sapdata/sapdata2/gp1_242/gp1.data242’ online;
Database altered.
SQL> alter database datafile ‘/oracle/SID/sapdata/sapdata2/gp1_243/gp1.data243’ online;
Database altered.
9) check again the status of datafiles:
SQL> set line 250
SQL> col FILE_NAME for a45
SQL> select FILE_NAME,FILE_ID,TABLESPACE_NAME,ONLINE_STATUS from dba_data_files;

Friday, September 2, 2022

 

ORA-12557: TNS:protocol adapter not loadable


Question:  What causes the ORA-12577 error below?  I am running on Windows.

ORA-12557: TNS:protocol adapter not loadable

The ORA-12577 error is related to Windows Environment or Oracle Home PATH because sqlplus command works smoothly when I execute it inside ORACLE_HOME\bin.

Answer:  There are two solutions to this issue:

1 - put the Oracle DB Home in front of the other paths in the PATH environment variable.

2 - Remove ORACLE_HOME From environment Variable and re-boot PC

Oracle author Osama Mustafa notes a solution to the ORA-12577 error.

RUN: SYSDM.CPL to open Windows System Properties

Click on Advanced Tab > Environment Variables…

Click the Path variable under System Variable, then click Edit…

Change the order between Oracle Client Home and Oracle DB Home:

From: D:\oracle\product\10.2.0\client_1\bin;D:\oracle\product\10.2.0\db_1\bin;

To: D:\oracle\product\10.2.0\db_1\bin;D:\oracle\product\10.2.0\client_1\bin;

In other words, put the Oracle DB Home in front of the other path.

Wednesday, July 6, 2022

 How to set FILESYSTEMIO_OPTIONS for use with RSA Identity Governance and Lifecycle on a remote Oracle database where Automatic Storage Management (ASM) is not being used for better storage performance 

Tuesday, July 5, 2022

 

ORA-01012: not logged on error

HOME » ORA-01012: NOT LOGGED ON ERROR

ORA-01012: not logged on error while trying to start the oracle database.







Solution:

To resolve this error  remove the orphaned shared memory segment using sysresv utility. sysresv command will list the currently allocated IPC resources for shared memory and remove the shared memory segment using ipcrm -m command.





Now start the database



 

Wednesday, April 20, 2022

 Determine an index needs to be rebuilt


First, the relevant index should be analyzed. You can do this with the following command.

SQL> analyze index <username>.<index_name> validate structure;

Index analyzed.


The analysis process fills the table “sys.index_stats”. This table contains only one row and therefore only one index can be analyzed at a time. Information about the relevant index can be obtained from the sys.index_stats table in the analyzed session.


SQL> select del_lf_rows,lf_rows,height,lf_rows,lf_blks from sys.index_stats;


DEL_LF_ROWS    LF_ROWS    HEIGHT    LF_ROWS LF_BLKS

----------- ---------- ---------- ---------- --------------------------------------------------

  842     41356545           3       41356545 109441



After the analysis, according to the data in the “sys.index_stats” table, if any of the following conditions occur you can decide whether rebuild the index or not.


If the percentage of deleted rows exceeds 30% of the total. So if del_lf_rows / lf_rows> 0.3 in the sys.index_stats table.

If ‘HEIGHT’ is greater than 4.

If the number of rows in the index(LF_ROWS) is much less than (LF_BLKS). This indicates that too many records have been deleted from the index.

When one of these conditions occurs you can rebuild the index as follows.


SQL> alter index <username>.<index_name> rebuild online;


Index altered.

Wednesday, November 10, 2021

 

How to use the purge command in adrci


Active Diagnostic Repository (ADR), which serves as a common repository for all log files, tracefiles, incidents etc, that the database produces.

ADR has a "short" and a "long" purging policy. The default values are:

• 720 hours (30 days) for SHORTP_POLICY
• 8760 hours (356 days) for LONGP_POLICY

Each policy controls different types of content:

These files are controlled by the value of LONGP_POLICY:

ALERT
INCIDENT
SWEEP
STAGE
HM

These files are controlled by the value of SHORTP_POLICY:

TRACE
CDUMP
UTSCDMP
IPS

Sometimes it may be necessary to manually purge the ADR. The following example will delete all trace files older than 48 hours:
adrci> purge -age 48 -type trace
Other examples (2160 hrs = 90 days):
purge -age 2160 -type alert
purge -age 2160 -type incident
purge -age 2160 -type cdump
purge -age 2160 -type stage
purge -age 2160 -type sweep
purge -age 2160 -type hm

The policies can be adjusted according to need by using the following commands :
adrci> show control

ADR Home = /u01/oracle/diag/rdbms/proddb01/proddb01:

*************************************************************************
ADRID                SHORTP_POLICY        LONGP_POLICY
-------------------- -------------------- --------------------
597879840            720                  8760

Set a new policy (2 and 3 days, respectively):
set control (SHORTP_POLICY = 48)
set control (LONGP_POLICY = 72)

An example from one of my databaes:
adrci> show incident -mode basic

ADR Home = /u01/oracle/diag/rdbms/proddb01/proddb01:
*************************************************************************

INCIDENT_ID          PROBLEM_KEY                                                 CREATE_TIME
-------------------- ----------------------------------------------------------- ----------------------------------------
30858                ORA 603                                                     2014-03-19 11:26:41.287000 +01:00
30857                ORA 600 [kqlidchg0]                                         2014-03-19 11:26:38.226000 +01:00
27284                ORA 603                                                     2014-03-18 14:42:28.228000 +01:00
27283                ORA 600 [kqlidchg0]                                         2014-03-18 14:42:23.706000 +01:00
.
.
.
17044                ORA 603                                                     2013-09-26 15:37:30.870000 +02:00
17043                ORA 600 [kqlidchg0]                                         2013-09-26 15:37:27.255000 +02:00
17042                ORA 603                                                     2013-09-26 15:35:45.918000 +02:00
17041                ORA 600 [kqlidchg0]                                         2013-09-26 15:35:42.239000 +02:00

45 rows fetched
Remove incidents that are older than 90 days:
adrci> purge -age 2160 -type incident
Another check of the incident list shows that the number has been reduced:
adrci> show incident -mode basic

ADR Home = /u01/oracle/diag/rdbms/sergat/sergat:
*************************************************************************

INCIDENT_ID          PROBLEM_KEY                                                 CREATE_TIME
-------------------- ----------------------------------------------------------- ----------------------------------------
30858                ORA 603                                                     2014-03-19 11:26:41.287000 +01:00
30857                ORA 600 [kqlidchg0]                                         2014-03-19 11:26:38.226000 +01:00
27284                ORA 603                                                     2014-03-18 14:42:28.228000 +01:00
27283                ORA 600 [kqlidchg0]                                         2014-03-18 14:42:23.706000 +01:00
.
.
.
24 rows fetched

Wednesday, October 13, 2021

 

Enable and disable data guard broker


https://logic.edchen.org/how-to-stop-data-guard-services/


1. Login to primary db server


$ dgmgrl sys/Manager_1@sslcdb

DGMGRL> show configuration

2. Check the apply and transport status:


Disable Data Guard with Broker


DGMGRL> show database sslcdb

Database - SSLCDBDR

Role:               PRIMARY

 ----------------------------------------------

@stanby

$ dgmgrl sys/Manager_1@sslcdbdr

DGMGRL> show database sslcdbdr

Database - SSLCDBDR

  Role:               PHYSICAL STANDBY


3. DGMGRL Stop Transport

disable transport service of the primary database.

dgmgrl sys/Manager_1@sslcdb


DGMGRL> EDIT DATABASE sslcdbdr SET STATE='TRANSPORT-OFF';

Succeeded.


4. DGMGRL Stop Apply

dgmgrl sys/Manager_1@sslcdbdr


DGMGRL> edit database SSLCDBDR set state='APPLY-OFF';

Succeeded.


5. Disable DG Configuration


DGMGRL> DISABLE CONFIGURATION;

Disabled.


Enable Data Guard with Broker


6. Disable DG Configuration


DGMGRL> ENABLE CONFIGURATION;

Enableabled.


7. DGMGRL Start Transport


Enableable transport service of the primary database.

dgmgrl sys/Manager_1@sslcdb


DGMGRL> EDIT DATABASE sslcdbdr SET STATE='TRANSPORT-ON';

Succeeded.


8. DGMGRL Start Apply


dgmgrl sys/Manager_1@sslcdbdr


DGMGRL> edit database SSLCDBDR set state='APPLY-ON';

Succeeded.


SQL> show parameter dg_broker_start

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

dg_broker_start                      boolean     TRUE


SQL> select name, value from v$parameter where name = 'dg_broker_start';


NAME                       VALUE

-----------------------------------------------------------------

dg_broker_start            TRUE


Tuesday, October 12, 2021

 SQL query to get DB info

spool dbinfo.html
set markup html on
select * from v$version;
select * from v$instance;
select * from v$parameter;
select * from v$resource_limit;
select * from dba_users;
select * from dba_registry;
SET linesize 235
col Parameter FOR a50
col SESSION FOR a28
col Instance FOR a55
col S FOR a1
col I FOR a1
col D FOR a1
col Description FOR a90

SELECT
a.ksppinm "Parameter",
decode(p.isses_modifiable,'FALSE',NULL,NULL,NULL,b.ksppstvl) "Session",
c.ksppstvl "Instance",
decode(p.isses_modifiable,'FALSE','F','TRUE','T') "S",
decode(p.issys_modifiable,'FALSE','F','TRUE','T','IMMEDIATE','I','DEFERRED','D') "I",
decode(p.isdefault,'FALSE','F','TRUE','T') "D",
a.ksppdesc "Description"
FROM x$ksppi a, x$ksppcv b, x$ksppsv c, v$parameter p
WHERE a.indx = b.indx AND a.indx = c.indx
AND p.name(+) = a.ksppinm
ORDER BY a.ksppinm;

set markup html off
spool off

Monday, October 11, 2021

 

ORA-10873: file 1 needs to be either taken out of backup mode or media recovered


Scenario :

Database went down due to power fluctuation and during that time hot backup was running.So once we started the database we face the following issue.

Error :

ORA-10873: file 1 needs to be either taken out of backup mode or media recovered

ORA-01110: data file 1: ‘D:\ORADB\RECTCDB\system01.dbf’

Cause :

Database is in backup mode while it went down.

Solution :

Step 1 : Sqlplus  ‘/as sysdba’

Step 2 : startup mount

Step 3 : Check backup file using below command.

select * from V$BACKUP

Step 4 : The following command can be used to take all of the data files out of hot backup mode:


SQL> ALTER DATABASE END BACKUP;

Step 5 :  SQL> Alter database open;






























 RMAN Recovery Catalog About Recovery Catalog RMAN recovery catalog Is another database which is out of your normal databases or which is o...