RMAN ---Backup and recovery Methods being followed
These are to be done in the machine where you want to keep the RMAN catalog.
Step 1:
Create a Database in the machine where you want to keep the RMAN catalog.
1.1: Create a folder with the Database name. (say TEST)
$ mkdir '/d01/oracle/visdb/9.2.0/test/
within that folder make 3 sub folders
. bdump
. cdump
. udump
$ mkdir '/d01/oracle/visdb/9.2.0/test/bdump
$ mkdir '/d01/oracle/visdb/9.2.0/test/cdump
$ mkdir '/d01/oracle/visdb/9.2.0/test/udump
1.2 Make a parameter file and save it in 'RDBMS_ORACLE_HOME/dbs'
name it as 'initTEST.ora'
The file will be something like this.......
db_name = PROD
control_files = /d01/oracle/proddata/cntrl01.dbf,
/d01/oracle/proddata/cntrl02.dbf,
/d01/oracle/proddata/cntrl03.dbf
db_block_size = 8192
compatible = 9.2.0
user_dump_dest = /d01/oracle/proddb/9.2.0/test/udump
background_dump_dest = /d01/oracle/proddb/9.2.0/test/bdump
core_dump_dest = /d01/oracle/proddb/9.2.0/test/cdump
db_cache_size = 163577856
log_buffer = 10485760
undo_management =AUTO
undo_tablespace =UNDOTS1
shared_pool_size = 300000000
java_pool_size = 52428800
1.3
Make the password file
$ orapwd file = /oracle_home/dbs/orapwdtest password = ******* entries = 3;
1.4 Set the environment variables
$ ORACLE_SID = test
$ export ORACLE_SID
to check if set or not
$ echo ORACLE_SID
1.5 Log in to sqlplus as sysdba
$ sqlplus “/ as sysdba”;
1.6 Run the database creation command
SQL>create database test;
1.7 Now we need to run 3 SQL scripts
. catalog.sql (Location: ORACLE_HOME/rdbms/admin)
. catproc.sql (Location: ORACLE_HOME/rdbms/admin)
. pupbld.sql (Location: ORACLE_HOME/sqlplus/admin)
SQL> @/d01/oracle/visdb/9.2.0/rdbms/admin/catalog.sql;
SQL> @/d01/oracle/visdb/9.2.0/rdbms/admin/catproc.sql;
SQL> @/d01/oracle/visdb/9.2.0/sqlplus/admin/pupbld.sql;
DATABASE creation complete.
STEP 2: Creating tablespaces
We need to create 2 tablespaces, default and temporary
login to sqlplus as sysdba
SQL>create tablespace tab1
2 datafile '/d01/oracle/visdata/datatab1.dbf'
3 size 200M
4 extent management local uniform size 128K
5 autoextend on;
SQL>create temporary tablespace temp1
2 tempfile '/d01/oracle/visdata/temptab1.dbf'
3 size 200M;
STEP 3: Cerating a user rman and grant privileges
SQL>create user rman identified by rman
2 default tablespace tab1
3 temporary tablespace temp1
4 quota unlimited on tab1
5 password expire;
SQL>grant connect,resource,recovery_catalog_owner to rman;
STEP 4: Edit the tnsnames.ora, listener.ora and sqlnet.ora
$ cd /d01/oracle/visdb/9.2.0/network/admin/VIS_bbs2/
$ vi listener.ora
add this
TEST =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROCTEST))
(ADDRESS = (PROTOCOL = TCP)(Host = bbs2)(Port = 3003))
)
SID_LIST_TEST =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = TEST)
(ORACLE_HOME = /d01/oracle/proddb/9.2.0)
(SID_NAME = TEST)
)
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /d01/oracle/proddb/9.2.0)
(PROGRAM = extproc)
)
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROCTEST))
(ADDRESS = (PROTOCOL = TCP)(Host = 192.168.1.25[ip of the machine which cantains the target database])(Port = 3003))
)
$ vi tnsnames.ora
add this
TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(Host = bbs2)(Port = 3003))
)
(CONNECT_DATA =
(SERVER = SHARED)
(SERVICE_NAME = TEST)
(INSTANCE_NAME =TEST)
)
)
$ vi sqlnet.ora disable this
#tcp.validnode_checking = yes
#tcp.invited_nodes=(BBS2.ora1.com)
STEP 5: Login to rman and create the catalog
$ export ORACLE_SID
$ ORACLE_SID=TEST
$ rman catalog rman/rman@test
RMAN>create catalog;
These are to be done in the machine where the target database resides.
STEP 6: Now in the machine where the target database resides we need to edit tnsnames.ora, listener.ora and sqlnet.ora
$ cd /d01/oracle/visdb/9.2.0/network/admin/VIS_bbs2/
$ vi listener.ora
add this
TEST =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROCTEST))
(ADDRESS = (PROTOCOL = TCP)(Host = 192.168.1.25[ip of the machine which the catalog resides])(Port = 3003))
)
$ vi tnsnames.ora
add this
TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(Host = 192.168.1.25[ip of the machine which the catalog resides])(Port = 3003))
)
(CONNECT_DATA =
(SERVER = SHARED)
(SERVICE_NAME = TEST)
(INSTANCE_NAME =TEST)
)
)
$ vi sqlnet.ora disable this
#tcp.validnode_checking = yes
#tcp.invited_nodes=(BBS2.ora1.com)
STEP 7: Login to rman and register the database
$ export ORACLE_SID
$ ORACLE_SID=
$ rman target / catalog rman/rman@test
RMAN>register database;
STEP 8: Take the database to Archivelog mode
$sqlplus sys as sysdba
SQL>shutdown normal;
SQL>startup mount;
SQL>alter databse archivelog;
SQL>alter database open;
STEP 6: Configure the channel for rman backup
$ rman target / catalog rman/rman@test
RMAN>configure channel device type disk
2 format = '/backup/df0_%d_%s_%t';
NOTE : We were have configured the channel to a different disk that we had add. So we need to mount that HDD: by giving the command $fdisk -l as root user it showed the disk as hdb1. So we had to add the following in /etc/fstab
/dev/hdb1 /backup ext3 defaults 0 0
We had created a directory “backup”in / where we mounted the HDD
Also we had to change the permissions to 777 $chmod -R 777 /backup
STEP 7: Backup the database
RMAN>backup database;
After rman takes the backup it will prompt Backup Complete
STEP 8: To see if backup is done
RMAN>list backup;
Now suppose a datafile is corrupted or lost. You want to shutdown the database it shows error that a datafile is missing. Then you aborted the database and started it again. Now the database starts only to mount stage.
STEP 9: Restore the database
Login to rman
$ rman target / catalog rman/rman@test
RMAN> restore database;
STEP 10 : Recover database
RMAN>recover database;
RMAN>exit
STEP 11: Login to sqlplus
SQL>alter database open;
And now the database opens
No comments:
Post a Comment