Thursday, March 3, 2011

RMAN Concepts


 RMAN is a oracle utility (tool) that is used to take backup, or 
do restore database or perform recovery.

Features of RMAN
--------------
i) It is free, comes with server software.
ii) It provides faster and safest backup.
iii) It provides faster recovery.
iv) It provides centralized backup restore and recovers the database.
v) Only with the help of rman we can take physical incremental   backup.

Some basic terms
-----------------
TARGET DATABASE:   Database that rman uses to take backup, recovery operations.
CATALOG DATABASE SCHEMA:  Is a schema where rman stores set of tables to keep information of the target database.

          RMAN                           PROD

        machine1        -------->       machine2 

        Client                           Server

RMAN REPOSITORY
---------------
 It is a collection of metadata of the target database that includes database name, database id, complete database schema information.

    machine1 (UK)        machine2 (USA)      machine3 (Singapore)

Configure the listener

|       register             |                          |
|                            |                          |                               
                     Machine (RMAN client)
                (Catalog database information)

 tnsnames.ora must be configured on the client side. Here you have to install oracle server software (client side)                         
RMAN keeps repository information in the target database control file itself. Optionally it is stored in catalog database schema.
The backups are stored in the server only.
 First preference goes to flash_recovery_area(default backup location is FRA)

RMAN BACKUP LOCATION:
--------------------
 If you have not given any instructions to store the backup files.Then in this case the target database side server process initially it will look for the flash_recovery_area (FRA),  if it is not configured it will keep all backup files  in this location $ORACLE_HOME/dbs

How to configure server for RMAN
--------------------------------
CATALOG                                          TARGET                                                                                                      

                                                SYS user
 machine1                                       machine2
PRD (client)                                   SALES (server)

Client side: tnsnames.ora required    Server side: listener.ora       
                                                   required and      
                                                   configure 
                                                   password file.
                                                  Target database  
                                                   must be in  
                                                 Archive Log Mode.


i)                    Create one user rman, here schema name is rman
ii)                  Go to OS level
$cd $ORACLE_HOME/bin
 ]$./rman
RMAN> connect catalog rman/rman;
 RMAN> create catalog;
---------------------------------------------------------------
    Next we have to connect to the server to perform administrative tasks on the remote server
     We have to create a password file the target (server) side.

      ]$cd $ORACLE_HOME/dbs
 Syntax:
      ]$orapwd file=ora<sid> password=<password>
      ]$orapwd file=orapwsales password=sales
-----------------------------------------------------------------
 Syntax for remote server connection

         RMAN>connect target sys/password@connectstring;
         RMAN>connect target sys/sales@to_sales;
         here to_sales is a connect string.

       RMAN>register database;
        I am registering target database info on the client side.
    -------------------------------------------------------- 
       sql>connect rman/rman;
        sql>select * from rc_database;
     here u will find how many databases are registered with the client.
  ---------------------------------------------------------------
Practical Demo:
---------------
  Server side

]$sqlplus '/as sysdba'
sql>startup
sql> select name from v$database;
sql> select name from v$controlfile;
sql>archive log list;
       Archive log mode
sql>host

]$cd /home/oracle/product/10.2.0/db_1/network/admin
admin]$netca
        listener name is listener
        use default portno i.e 1521
( listener is a server process to handle the client requests)
admin]$lsnrctl stop
          stop the listener
admin]$ls
admin]$vi listener.ora
 --------------------------------------------

SID_LIST_LISTENER=
     (SID_LIST=
        (SID_DESC=
           (SID_NAME= sales)
            (ORACLE_HOME=/home/oracle/product/10.2.0/db_1)
  )
)

LISTENER =
  (DESCRIPTION_LIST=
(DESCRIPTION=
      (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.2)(PORT=1521)
   )
)
]$lsnrctl start

Creating password file on the serverside
 ]$cd $ORACLE_HOME/dbs
dbs]$orapwd file=orapwsales password=sales
dbs]$
              client side (catalog side)
            ----------------------------------
configure tnsnames.ora on the client side
]$cd $ORACLE_HOME/network/admin
admin]$netca
         - select local netservice name configuration
         - service name: sales  (server database name)
         - hostname: 192.168.100.2
        - don't test it
        - Net service name: to_sales (connect string)
         - Next àNext  à Finish

admin]$vi tnsnames.ora
-----------------------------------------
TO_SALES =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.2)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = sales)
    )
  )
------------------------------------------
Syntax for connectivity
------------------------
admin]$tnsping connectstring
admin]$tnsping to_sales
[oracle@dbaschool admin]$ tnsping to_sales

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 29-AUG-2009 17:11:27
Copyright (c) 1997, 2005, Oracle.  All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.2)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = sales)))
OK (0 msec)

[oracle@dbaschool admin]$
]$sqlplus '/as sysdba'
sql>startup
sql>select * from all_users;
create one tablespace on the client side
sql>create tablespace catlg datafile '/home/prd/catlg.dbf' size  200m (min 30mb required);
sql> create user rman identified by rman default tablespace catlg;
sql>grant connect,resource , recovery_catalog_owner to rman;
sql>select * from all_users;

]$cd $ORACLE_HOME/BIN
BIN]$./rman
RMAN>connect catalog rman/rman@to_sales;
RMAN>create catalog;
recovery catalog created
RMAN>connect target sys/sales@to_sales
--------------------------------------------------------------------------
     RMAN> connect target sys/sales@to_sales

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-06004: ORACLE error from recovery catalog database: RMAN-20001: target data base not found in recovery catalog

RMAN>
---------------------------------------------------------------------------    
         bcz we didn't register
-------------------------------------------------------------------
sql>select * from rman.rc_database;
      no database is registered
----------------------------------
RMAN>register database;
------------------------------
sql>select * from rc_database;
       Database is registered
----------------------------------
RMAN>report schema;
for checking backups
---------------------
RMAN>list backup;
        Nothing

RMAN>
 BACKUP: Backup command is used to take the backup of the database.
 RESTORE:  RESTORE command is used to take restore the backup file. (Physically copied into the respective locations)

 RECOVER: RECOVER command is used to recover the database.

No comments:

Post a Comment

Oracle Database & Applications R12.2 Log file locations

Many times, we forget the path for the log files since there are too many.  Below is the list of frequently used log files which can help us...