Monday, 29 August 2016

Step By Step Oracle 11g RMAN Configuration with Incremental and whole Backup

STEP-1
Logon to SYS user
First of all make sure your database is running ARCHIVELOG mode. If it is not running then logon to sys user and follow bellow code.
SQL> conn sys as sysdba;
Enter password:
Connected.

SQL> STARTUP MOUNT EXCLUSIVE;
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> ALTER DATABASE ARCHIVELOG;
ALTER DATABASE ARCHIVELOG
*
ERROR at line 1:
ORA-01126: database must be mounted in this instance and not open in any
instance

SQL>  archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     1
Current log sequence           3

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.
Total System Global Area  167772160 bytes
Fixed Size                  1247876 bytes
Variable Size              75498876 bytes
Database Buffers           83886080 bytes
Redo Buffers                7139328 bytes
Database mounted.

SQL> alter database archivelog;
Database altered.

SQL> alter database open;
Database altered.

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     1
Next log sequence to archive   3
Current log sequence           3
SQL>

SQL> create tablespace rec_catalog
     datafile ‘E:\oracle\product\10.2.0\db_1\oradata\klm\rec_catalog.dbf’
     size 10M autoextend on
     extent management local uniform size 1M;

Next we create the recovery catalog owner. The user SYS cannot be the owner of the recovery catalog.
SQL> create user rcat identified by rcat   default tablespace rec_catalog
    quota unlimited on rec_catalog;

User created.

SQL> GRANT connect, resource, recovery_catalog_owner TO rcat;

Grant succeeded.

SQL> grant recovery_catalog_owner to rcat;
Grant succeeded.
The role RECOVERY_CATALOG_OWNER has all of the privileges need to query and maintain the recovery catalog.
SQL> select privilege from dba_sys_privs where grantee = 'RECOVERY_CATALOG_OWNER';
PRIVILEGE
—————————————-
CREATE SYNONYM
CREATE CLUSTER
ALTER SESSION
CREATE DATABASE LINK
CREATE PROCEDURE
CREATE SEQUENCE
CREATE TABLE
CREATE SESSION
CREATE TYPE
CREATE VIEW
CREATE TRIGGER

STEP-2
Now open CMD or Command Prompt
C:\>rman catalog=rcat/rcat@klm

connected to recovery catalog database

RMAN> create catalog tablespace "REC_CATALOG";
recovery catalog created

RMAN> exit
Recovery Manager complete.

C:\>rman catalog=rcat/rcat@KLM target=sys/sys@KLM
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

RMAN> exit
Recovery Manager complete.

STEP-3
Configure the persistent parameters.
RMAN> configure retention policy to recovery window of 7 days;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN> configure default device type to disk;
new RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN> configure controlfile autobackup on;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

RMAN> configure channel device type disk format 'F:\ssuet_backup\rmanbackup\Backup%d_DB_%U_%S_%P';
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT 'F:\Rmanbackup\Backup%d_DB_%U_%S_%P';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete

STEP-4
Now We have created two .rcv files backup.rcv and backup1.rcv with two Batch file daily and weekly basis backup and add in schedule of windows 2003 server.

WEEKLY BACKUP FILE SCRIPT
Open notepad and write bellow code and save it bellow name with .bat extension.
weeklybackupRMAN.bat
echo off
rman target=sys/sys@klm cmdfile F:\Rmanbackup\backup1.rcv

Now open notepad and write bellow rman script and save it with bellow with .rcv extension.
backup1.rcv
run {
backup incremental level 0 DATABASE plus ARCHIVELOG DELETE INPUT  TAG WEEKLY_BACKUP;
sql "alter system archive log current";
DELETE NOPROMPT OBSOLETE;
backup spfile;
backup current controlfile;
}



DAILY BACKUP FILE SCRIPT
Open notepad and write bellow code and save it bellow name with .bat extension.

dailybackupRMAN.bat
echo off
rman catalog=rcat/rcat@klm target=sys/sys@klm cmdfile F:\Rmanbackup\backup.rcv
backup.rcv
Now open notepad and write bellow rman script and save it with bellow with .rcv extension.

run {
backup incremental level 1 DATABASE plus ARCHIVELOG DELETE INPUT  TAG DAILY_BACKUP;
sql "alter system archive log current";
DELETE NOPROMPT OBSOLETE;
backup spfile;
backup current controlfile;


}

Performance Tuning Interview Questions and Answers

performance tuning questions and solutions 1. A tablespace has a table with 30 extents in it. Is this bad? Why or why not? Expected answ...