Wednesday, 17 January 2018

Backing Up Oracle Database (Physical Backup RMAN Utility)

Backup Oracle Database

There are 2 main types of backup in Oracle.
1- Physical Backup 
2- Logical Backup

But in this blog we will focus on physical Backup. In physical backup, all files such as datafiles, controlfile and archive redolog files are stored physically on other disk or some other medium like tape storages. Further we can take 2 types of physical backup. i.e cold backup and hot backup.

--Cold backup: It is type of backup when we stop the database server to perform any operations on database and we close the database, that is database is in mount stage, it is
the most safiest way of complete/full backup. It can be called as offline backup.

--Hot backup: It is type of backup when operations are being performed on database by the users and we take the backup, but for this type of backup to be full/completed we need database
to be in archive log mode (please read archive log mode blog), This type of backup is also called as hot backup.

Backup through RMAN:

--Cold backup:

Sqlplus / as sysdba

sql> alter database close; or

sql> shutdown immediate;

sql> startup mount;

this will take you to mount state, now you are ready to go offline or cold backup:

$ rman target /

rman> backup database;

exit

--Hot backup:

Full Datafiles backup:

$ rman target /
      or
$ rman target user/password

rman> backup database;

rman> exit;

Full Datafiles backup plus archivelog:

$rman target /

rman> backup database plus archivelog;

rman> exit;

Dropping ASM Disk Group in detail (Step by Step)

--check following parameter before dropping ASM DG:

Before dropping the ASM DiskGroup please check the below parameter as any one of them is pointing to the Disk group which you are going drop, if there are some parameter found point to that DG, we have to set new location for it.

Sqlplus / as sysdba

--Checking Oracle OMF Location

SQL> show parameter create

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
create_bitmap_area_size              integer     8388608
create_stored_outlines               string
db_create_file_dest                  string      +FRA_TESTDB/TESTDB
db_create_online_log_dest_1          string
db_create_online_log_dest_2          string
db_create_online_log_dest_3          string
db_create_online_log_dest_4          string
db_create_online_log_dest_5          string

we have to update the old DG name with new DG as:

alter system set db_create_file_dest='+FRA_TESTDB_01/TESTDB' scope=both;

SQL> show parameter create

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
create_bitmap_area_size              integer     8388608
create_stored_outlines               string
db_create_file_dest                  string      +FRA_TESTDB_01/TESTDB
db_create_online_log_dest_1          string
db_create_online_log_dest_2          string
db_create_online_log_dest_3          string
db_create_online_log_dest_4          string
db_create_online_log_dest_5          string

-- Now check the postion of Flash recovery Area

SQL> show parameter recovery

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      +FRA_TESTDB
db_recovery_file_dest_size           big integer 8016M
recovery_parallelism                 integer     0
remote_recovery_file_dest            string

This location should also be changed to new DG as:

alter system set db_recovery_file_dest='+FRA_TESTDB_01' scope=both;

Similarly check Controlfiles,log_archive_destination if you have set, change it to new disk group.

For controlfile movement (follow the blog moving data accross the disk groups)

-- Checking all the datafiles, there shouldn't exists any datafile on this DG:


select name from v$controlfile
union
select name from v$datafile
union
select name from v$tempfile
union
select member from v$logfile
union
select filename from v$block_change_tracking
union
select name from v$flashback_database_logfile;


-- Delete a directory and all its contents.

ALTER DISKGROUP disk_group_1 DROP DIRECTORY '+FRA_TESTDB/backup' FORCE;

When its all clear that there is no DB parameter pointing to the DG going to be dropped and no live data is there we can drop that disk group.

-- To check dependancy & Remove Dependacny


#./srvctl config database -d DBTESTQ

SQL> drop diskgroup PLAY force including contents;

Or we can do it by Srv utility

Stopping the FRA resources

[root@testdb bin]# ./srvctl stop diskgroup -g FRA

Dropping the Disk

[root@testdb bin]# ./srvctl remove diskgroup -g FRA

Checking the Status

[root@testdb bin]# ./srvctl config database -d testdb
Database unique name: testdb
Database name: testdb
Oracle home: /u01/app/oracle/product/11.2.0
Oracle user: grid
Spfile: +DATA/testdb/spfiletestdb.ora
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Disk Groups: DATA,ARCH
Services:
[root@testdb bin]# 

Installing Oracle 11g on Linux

Unpack Files Unzip the files. # 11.2.0.1 unzip linux.x64_11gR2_database_1of2.zip unzip linux.x64_11gR2_database_2of2.zip #11.2.0.2 u...