Tuesday, December 14, 2010

Implementation of RMAN (Recovery Manager)

To get the full benefits of Rman we should recovery catalog.

Recovery Catalog

The recovery catalog is an optional repository of information about your target databases that RMAN uses and maintains.

Physical location of the catalog

We should place the catalog database on a different server than the target database. If we fail to do this, we jeopardize backup and recovery options, because we make it possible to lose both the catalog and the target database.

The catalog database should be created with the latest version of Oracle in your production environment. This helps to minimize compatibility issues and complexity when you start to back up your target databases.


Creating a catalog

The examples in this section provide details for creating a catalog database and registering a target database within the catalog. These examples assume that your catalog database is on a different host than your target database.

Catalog database: Oracle 9.2.0.4 (GEK1) on gecko
Target database: Oracle 10.1.0.2 (AKI1) on akira

To create a recovery catalog follow these steps

1. Create a specific tablespace to hold the catalog objects.
2. Create a catalog schema.
3. Issue appropriate grants
4. Create the schema objects.

Oracle@akira:~> sqlplus system/manager@GEK1

CREATE TABLESPACE rman_cat
DATAFILE ‘/U01/oracle/db/GEK1/CAT/rman_cat_01.dbf’
SIZE 50M;

Now that we have a tablespace to store our schema objects, we can create the schema

CREATE USER rmancat
IDENTIFIED BY rmancat
DEFAULT TABLESPACE rman_cat
TEMPORARY TABLESPACE temp
QUOTA UNLIMITED ON rman_cat;

Before we create the catalog objects, we need to grant special privileges to new schema. These privileges, granted through the RECOVRY_CATALOG_OWNER role, let the schema manage its catalog objects.

GRANT RECOVERY_CATALOG_OWNER TO rmancat;
GRANT CREATE TYPE TO rmancat;

We can now create the catalog objects within our new schema. In order to perform this step, invoke RMAN, connect to newly created catalog schema, and issue the create catalog command. If we don't specify a tablespace with the create catalog command, the catalog objects are created in the default tablespace assigned to the catalog owner.

Oracle@akira:~> rman catalog rmancat/rmancat@GEK1

Recovery Manager: Release 10.1.0.2.0 - Production
Copyright (c) 1995,2004, Oracle. All rights reserved.
connected to recovery catalog database
recovery catalog is not installed

RMAN> create catalog;
Recovery catalog created

RMAN> exit;

At this point, we now have an operational RMAN catalog

Registering a target database

After creating a catalog, the next logical step is to register a target database. We won’t be able to backup the target with the catalog unless the target database is registered.

Invoke RMAN, connect to both the target and the catalog and issue the register database command.

Oracle@akira:~> rman target / catalog rmancat@rmancat@GEK1

RMAN> Register Database;

RMAN> Exit;




Configuring the RMAN Environment

Configure command

We can configure persistent settings in the Rman environment. The configuration setting is done once, and used by Rman to perform all subsequent operations.

To display the pre configured settings type the command SHOW ALL

RMAN> SHOW ALL

There are various parameters that can be used to configure RMAN operations to suit our needs.

Some of the things that we can configure are

1. Required number of backups for each datafile.
2. Number of server processes that will do backup/restore operations in parallel.
3. Directory where on disk backups will be stored.
Etc.,

We can return any CONFIGURE command to it’s default setting by running the command with the CLEAR option.

$ rman target / catalog rmancat/rmancat@GEK1

RMAN> CONFIGURE DEFAULT DEVICE TYPE TO DISK;

RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 3;

RMAN> CONFIGURE DEVICE TYPE DISK PARALLELISM 2;

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT
'/u01/oracle/db/AKI1/bck/ora_df%t_s%s_s%p';

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO
'/u01/oracle/db/AKI1/bck/ora_cf%F';

RMAN> CONFIGURE BACKUP OPTIMIZATION ON;

RMAN> SHOW ALL;


Working with RMAN

There are few things we need to have in place before instructing RMAN to connect to the target.

1. Appropriate target environment variables must be established.
2. We must have access to an O/S account or a schema that has SYSDBA privilege.

Before you connect to your target database, you must ensure that the standard Unix environment variables are established. These variables include: ORACLE_SID, ORACLE_HOME, PATH, NLS_LANG, and NLS_DATE_FORMAT. They govern the name of the instance, the path to the RMAN executable; and the behavior of backup, restore, and reporting commands.

When using RMAN, NLS_LANG should be set to the character set that your database was created with. If you do not set NLS_LANG, you may encounter problems when issuing BACKUP, RESTORE, and RECOVER commands.

Once you have the appropriate environment variables set, you then need access to an O/S account or a database schema that has SYSDBA privileges. You must have access to the SYSDBA privilege before you can connect to the target database using RMAN. There are two methods of administering the SYSDBA privilege:

1. Locally via O/S authentication
2. Remotely via password file

For local connections, RMAN automatically connects you to the target database with SYSDBA privileges.

Setting up a password file is the other method by which we can administer the SYSDBA privilege. There are two good reasons to use RMAN with a password file.

1. Oracle has deprecated the use of CONNECT INTERNAL and Server Manager.
2. We may want to administer RMAN remotely through a network connection.


For example, if you're in an environment where you want to back up all of your target databases from one place and not has to log on to each host and back up the database, you must do it via a network connection. To remotely administer RMAN through a network connection, you need to do the following:

• Create a password file
• Enable remote logins for password file users





Create a password file for Target

To create the password file, as the Oracle software owner or as a member of the dba group.

$ cd $oracle_home/dbs
$ orapwd file=sidname password=password entries=n

There are three user-provide variables in this example

1. sidname : The SID of the target instance
2. password : The password to be used when we connect a user SYS with SYSDBA privilege.
3. n : The maximum number of schemas allowed in the password files.

Example

$ cd $ORACLE_HOME/dbs
$ orapwd file=orapwAKI1 password=goofi entries=30

After we create a password file, we need to enable remote logins. To do this, set the instance’s REMOTE_LOGIN_PASSWORDFILE initialization parameter to EXCLUSIVE.

Setting this parameter to exclusive signifies that only one database can use the password file and that users other than sys and internal can reside in it. We can now use a network connection to connect to your target database as SYSDBA.

Test the connection, try to connect from a PC to the remote database as SYS with SYSDBA privileges:

$ sqlplus "sys/goofi@AKI1 as sysdba"

Note that we have to create a password file only for the target database and not for the catalog. This is because when you connect to the target, you need to connect as an account that has the SYSDBA privilege. When you connect remotely to a target database, the SYSDBA privilege is enabled through the password file. This is unlike a connection to the catalog, for which SYSDBA is not required, because you log in as the owner of the catalog schema.

When the SYSDBA privilege is granted to a specified user, the user can be queried in the V$PWFILE_USERS view.

SQL> GRANT SYSDBA TO rmancat;
SQL> select * from v$pwfile_users where username='RMANADMIN';

Invoking the RMAN Executable


In order to use Rman we have to invoke the executable. Once we have invoked the executable, we get an RMAN prompt, from which we can execute RMAN commands.

The executable of RMAN is located with all of the other oracle executables, in the BIN directory of oracle installation.

From O/S command prompt issue the command RMAN

$ rman

Connecting to target with no catalog

O/S Authentication

$ rman target / nocatalog

We can use O/S authentication only from an O/S account on the database server

Password file authentication

client-pc> rman target sys/goofi@AKI1 nocatalog

Hiding the password

Connect to the database after RMAN has been invoked prevents any password information from showing up in a process list.

SQLPLUS> $ rman nocatalog
RMAN> connect target sys/pwd@SID


Connecting to both Target and Catalog

If we are using catalog, we will typically connect to the target and the catalog at the same time. This is because when we are performing backup and recovery operations both the target and the catalog need to be aware of your activities.

O/S authentication

$ rman target / catalog rmancat/rmancat@GEK1

This connects us to the target and catalog database at the same time. Alternatively we can invoke RMAN first and then issue connect commands for the target and catalog separately.

$ rman
RMAN> connect catalog rmancat/rmancat@GEK1
RMAN> connect target /

Password Authentication

client-pc> rman target sys/goofi@AKI1 catalog rmancat/rmancat@GEK1

No comments:

Post a Comment