RMAN is a oracle utility to backup, restore & recovery of database.
The following Steps will be demonstrated the configuration of oracle RMAN backup (for first time configuration)
Lets
assume the database is in NOARCHIVELOG mode, by default the database is
in NOARCHIVELOG mode, we need to change it to ARCHIVELOG mode for RMAN
backup configuration.
We can configure RMAN backup with catalog/repository database as well as control file. It is strongly recommended & very good practice to configure RMAN backup with catalog/repository database.
catalog/repository database: It’s central repository & it requires separate database for backup operation. All registered target databases information stored in catalog database.
Control file: It contains registered target database information at server level itself & RMAN utility directly connects to target database by command “RMAN target /”
Note: Create catalog/repository database with the help of DBCA.
Lets consider following Step by Step syntax to do so:
Step # 1: Connect to Target database(Target DB: The database on which Backup & Recovery to be performed) as sysdba.
Step # 4: Startup the database in mount state.
Step # 5: Configure database in ARCHIVELOG mode.
Step # 6: Alter database to open state.
Step # 7: Ensure ARCHIVELOG destination.
In case you wish to change default archive log destination then issue the following command.
Step # 8: Ensure the flash/fast recovery area location.
Step # 9: Connect to RMAN prompt with target database.
Step # 10: Configure RMAN with controlfile auto-backup feature that will be auto-backup controlfile in case of major changes done in database.
Step # 11: To enable backup optimization run the following command, by default backup optimization has been configured OFF.
Step # 12: Configure retention policy for backup.
Step # 13: Connect to the recovery catalog database(RMAN Repository) & Create a tablespace
to store RMAN catalog database objects.
Step # 14: Create a RMAN user, assign RMAN tablespace to RMAN user as a default & grant recovery catalog owner,connect & resource privileges to RMAN user.
Step # 15: Connect to RMAN on target and recovery catalog database.
Step # 16: create catalog by issuing the following command in RMAN prompt.
Step # 17: After creating catalog, Ensure RMAN repository tables by logging into repository database as RMAN user. This is only for the first time.
Step # 18: Register database with recovery catalog.
Step # 19: Check whether registration was successful.
OR
Target database is registered with the RMAN.
Now you can backup your target(registered) database as per your convenience.
With RMAN, we backup database as “backup set” OR backup database as “backup as copy”. While backup, by default RMAN creates “backup sets”, backup sets consist of backup piece[s], backup piece means physical file genrated and readable by only RMAN.
With the help of “backup as copy” RMAN command, we can backup database as copy of that database, In which each files would be copy as image. Image copy are similar to copies generated with OS command like cp/copy. Usable by RMAN only. We can use “backup as copy” while database in open mode.
Lets Consider hands-on on Database backup in NoArchive log mode:
While database is running under NoArchive log mode, than only way to consider consistent backup is to take your database in mount state after consistant shutdown. ( i.e. ‘shutdown’ OR ‘shutdown immediate’ ) So that restoring database backup would not required any kind of recovery.
To backup your database in NoArchivelog mode ( i.e. consistent backup ), consider following:
Switch to oracle user:
[root@ol11g ~]# su - oracle
Connect to database and shutdown database consistently:
-bash-4.1$ sqlplus / as sysdba SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
Start your database in mount state:
SQL> startup mount;
ORACLE instance started.
Total System Global Area 442601472 bytes Fixed Size 2214176 bytes Variable Size 331351776 bytes Database Buffers 104857600 bytes Redo Buffers 4177920 bytes Database mounted.
SQL> exit
Connect to RMAN prompt with target database ( i.e. galaxy ) and start database backup:
-bash-4.1$ rman target / connected to target database: GALAXY (DBID=3647455456, not open) RMAN> backup database;
OR
RMAN> backup as copy database;
Lets Consider hands-on on Database backup in Archive log mode:
Note:
To backup your database in archive log mode, your database must be configured in archive log mode. If not, follow above steps to convert database in archivelog mode.
As we know, Redo logs are required at the time of recovery to open database in consitent state, thats why we called this backup as inconsistent.
To backup database along with archive log, issue the following RMAN command:
RMAN> backup database plus archivelog;
These is all about backup database with the help of RMAN backup utility in Archive log and NoArchive log mode.
[oracle@ora1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu Apr 8 12:02:52 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 25
Current log sequence 27
SQL>
SQL> show parameter recovery_file_dest;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/app/oracle/flash_recovery
_area
db_recovery_file_dest_size big integer 3852M
SQL>
SQL> alter system set db_recovery_file_dest_size=75g scope=both;
System altered.
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u02/app/oracle/oradata/orcl/arch
Oldest online log sequence 25
Current log sequence 27
SQL>
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 849530880 bytes
Fixed Size 1339824 bytes
Variable Size 511708752 bytes
Database Buffers 331350016 bytes
Redo Buffers 5132288 bytes
Database mounted.
SQL>
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 /u02/app/oracle/oradata/orcl/arch
Oldest online log sequence 25
Next log sequence to archive 27
Current log sequence 27
SQL> exit;
[oracle@ora1 ~]$RMAN target /;
The following Steps will be demonstrated the configuration of oracle RMAN backup (for first time configuration)
We can configure RMAN backup with catalog/repository database as well as control file. It is strongly recommended & very good practice to configure RMAN backup with catalog/repository database.
catalog/repository database: It’s central repository & it requires separate database for backup operation. All registered target databases information stored in catalog database.
Control file: It contains registered target database information at server level itself & RMAN utility directly connects to target database by command “RMAN target /”
Note: Create catalog/repository database with the help of DBCA.
Lets consider following Step by Step syntax to do so:
Step # 1: Connect to Target database(Target DB: The database on which Backup & Recovery to be performed) as sysdba.
[oracle@centos ~]$ sqlplus "/ as sysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Fri Jan 3 11:28:24 2014
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
Step # 2: Ensure the database has been configured with ARCHIVELOG mode or not?SQL> select log_mode from v$database;
LOG_MODE
------------
NOARCHIVELOG
Database is in NOARCHIVELOG mode.
Step # 3: If the database has been configured with ARCHIVELOG
mode then skip the Step number 3 to 6, If not then Shutdown the
database.SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
Step # 4: Startup the database in mount state.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 308981760 bytes
Fixed Size 2212896 bytes
Variable Size 163580896 bytes
Database Buffers 138412032 bytes
Redo Buffers 4775936 bytes
Database mounted.
Step # 5: Configure database in ARCHIVELOG mode.
SQL> alter database archivelog;
Database altered.
Step # 6: Alter database to open state.
SQL> alter database open;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
Step # 7: Ensure ARCHIVELOG destination.
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 2
Next log sequence to archive 4
Current log sequence 4
In case you wish to change default archive log destination then issue the following command.
SQL> alter system set log_archive_dest_1='location=/home/oracle/arch' scope=both;
System altered.
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /home/oracle/arch
Oldest online log sequence 2
Next log sequence to archive 4
Current log sequence 4
Step # 8: Ensure the flash/fast recovery area location.
SQL> show parameter db_recovery_file_dest
Step # 9: Connect to RMAN prompt with target database.
[oracle@centos ~]$ rman target /
Recovery Manager: Release 11.2.0.1.0 - Production on Fri Jan 3 11:46:22 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1363580714)
RMAN>
Step # 10: Configure RMAN with controlfile auto-backup feature that will be auto-backup controlfile in case of major changes done in database.
RMAN> configure controlfile autobackup on;
Step # 11: To enable backup optimization run the following command, by default backup optimization has been configured OFF.
RMAN> configure backup optimization on;
Step # 12: Configure retention policy for backup.
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
Step # 13: Connect to the recovery catalog database(RMAN Repository) & Create a tablespace
to store RMAN catalog database objects.
[oracle@centos ~]$ sqlplus "/ as sysdba"
SQL> select global_name from global_name;
GLOBAL_NAME
--------------------------------------------------------------------------------
CATALOGD
SQL> create tablespace catalogtbs datafile '/home/oracle/dbfile/catalogtbs1.dbf' size 100M autoextend on maxsize unlimited;
Tablespace created.
Step # 14: Create a RMAN user, assign RMAN tablespace to RMAN user as a default & grant recovery catalog owner,connect & resource privileges to RMAN user.
SQL> create user recoveryman identified by recoveryman;
User created.
SQL> alter user recoveryman default tablespace catalogtbs temporary tablespace temp;
User altered.
SQL> grant recovery_catalog_owner to recoveryman;
Grant succeeded.
SQL> grant connect,resource to recoveryman;
Grant succeeded.
Step # 15: Connect to RMAN on target and recovery catalog database.
[oracle@oracle ~]$ rman target / catalog recoveryman/recoveryman@catalogdb
Recovery Manager: Release 11.2.0.1.0 - Production on Sat Jan 4 14:30:28 2014
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1363580714)
connected to recovery catalog database
Step # 16: create catalog by issuing the following command in RMAN prompt.
RMAN> create catalog;
recovery catalog created
Step # 17: After creating catalog, Ensure RMAN repository tables by logging into repository database as RMAN user. This is only for the first time.
[oracle@oracle ~]$ sqlplus "recoveryman/recoveryman@catalogdb"
SQL> show user;
USER is "RECOVERYMAN"
SQL> select table_name from user_tables;
Step # 18: Register database with recovery catalog.
RMAN> register database;
database registered in recovery catalog
starting full resync of recovery catalog
full resync complete
Step # 19: Check whether registration was successful.
RMAN> report schema;
Report of database schema for database with db_unique_name ORCL
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 670 SYSTEM YES /home/oracle/app/oracle/oradat /orcl/system01.dbf
2 490 SYSAUX NO /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
3 30 UNDOTBS1 YES /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
4 5 USERS NO /home/oracle/app/oracle/oradata/orcl/users01.dbf
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- ----------- --------- -------------------------------
1 20 TEMP 32767 /home/oracle/app/oracle/oradata/orcl/temp01.dbf
OR
RMAN> LIST INCARNATION OF DATABASE;
List of Database Incarnations
DB Key Inc Key DB Name DB ID STATUS Reset SCN Reset Time
------- ------- -------- ---------------- ------------ --- --------
89 102 ORCL 1363580714 PARENT 1 15-AUG-09
89
90 ORCL 1363580714 CURRENT 945184 02-JAN-14
Target database is registered with the RMAN.
Now you can backup your target(registered) database as per your convenience.
How to backup database in Archivelog and NoArchivelog mode with RMAN backup utility – RMAN Part-2
We can backup database file with the help “backup database” RMAN command. This will backup your database files to already configured device type. i.e. Disk or SBT, default is Disk.With RMAN, we backup database as “backup set” OR backup database as “backup as copy”. While backup, by default RMAN creates “backup sets”, backup sets consist of backup piece[s], backup piece means physical file genrated and readable by only RMAN.
With the help of “backup as copy” RMAN command, we can backup database as copy of that database, In which each files would be copy as image. Image copy are similar to copies generated with OS command like cp/copy. Usable by RMAN only. We can use “backup as copy” while database in open mode.
Lets Consider hands-on on Database backup in NoArchive log mode:
While database is running under NoArchive log mode, than only way to consider consistent backup is to take your database in mount state after consistant shutdown. ( i.e. ‘shutdown’ OR ‘shutdown immediate’ ) So that restoring database backup would not required any kind of recovery.
To backup your database in NoArchivelog mode ( i.e. consistent backup ), consider following:
Switch to oracle user:
[root@ol11g ~]# su - oracle
Connect to database and shutdown database consistently:
-bash-4.1$ sqlplus / as sysdba SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
Start your database in mount state:
SQL> startup mount;
ORACLE instance started.
Total System Global Area 442601472 bytes Fixed Size 2214176 bytes Variable Size 331351776 bytes Database Buffers 104857600 bytes Redo Buffers 4177920 bytes Database mounted.
SQL> exit
Connect to RMAN prompt with target database ( i.e. galaxy ) and start database backup:
-bash-4.1$ rman target / connected to target database: GALAXY (DBID=3647455456, not open) RMAN> backup database;
OR
RMAN> backup as copy database;
Lets Consider hands-on on Database backup in Archive log mode:
Note:
To backup your database in archive log mode, your database must be configured in archive log mode. If not, follow above steps to convert database in archivelog mode.
As we know, Redo logs are required at the time of recovery to open database in consitent state, thats why we called this backup as inconsistent.
To backup database along with archive log, issue the following RMAN command:
RMAN> backup database plus archivelog;
These is all about backup database with the help of RMAN backup utility in Archive log and NoArchive log mode.
SHORT CUT METHOD
[oracle@ora1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Thu Apr 8 12:02:52 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 25
Current log sequence 27
SQL>
SQL> show parameter recovery_file_dest;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/app/oracle/flash_recovery
_area
db_recovery_file_dest_size big integer 3852M
SQL>
SQL> alter system set db_recovery_file_dest_size=75g scope=both;
System altered.
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u02/app/oracle/oradata/orcl/arch
Oldest online log sequence 25
Current log sequence 27
SQL>
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 849530880 bytes
Fixed Size 1339824 bytes
Variable Size 511708752 bytes
Database Buffers 331350016 bytes
Redo Buffers 5132288 bytes
Database mounted.
SQL>
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 /u02/app/oracle/oradata/orcl/arch
Oldest online log sequence 25
Next log sequence to archive 27
Current log sequence 27
SQL> exit;
[oracle@ora1 ~]$RMAN target /;
RMAN> backup database plus archivelog;
No comments:
Post a Comment