Skip Headers

Oracle9i Recovery Manager User's Guide
Release 2 (9.2)

Part Number A96566-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback

Go to previous page Go to next page

2
Connecting to Databases with RMAN

This chapter describes how to start and stop the Recovery Manager (RMAN) command-line interface and make database connections. This chapter contains these topics:

Starting RMAN: Overview

You have the following basic options for starting RMAN:

If you connect to the target database on the command line when you start RMAN, then after the RMAN prompt is displayed you can begin executing commands.

If you start RMAN without connecting to the target database, then you must issue CONNECT TARGET command at the RMAN prompt before you can begin performing backup and recovery operations.

Types of Database Connections

You can connect to the following types of databases.

Database Connection

Target database

RMAN connects you to the target database with the SYSDBA privilege. If you do not have this privilege, then the connection fails.

Recovery catalog database

This database is optional: you can also use RMAN with the default NOCATALOG option.

Auxiliary database

You can connect to a standby database, duplicate database, or auxiliary instance (standby instance or tablespace point-in-time recovery instance).

Authentication for Database Connections

When connecting to a target or auxiliary database, you must have the SYSDBA privilege. You can connect as SYSDBA using a password file or using operating system authentication.


Note:

You do not need to specify the SYSDBA option because RMAN uses this option implicitly and automatically. You must have the SYSDBA privilege to connect to the target database.


If the target database uses password files, then you can connect using a password. Use a password file for either local or remote access. You must use a password file if you are connecting remotely as SYSDBA using a net service name.

If you connect to the database using operating system authentication, remember to set the environment variable specifying the Oracle SID. For example, to set the SID to trgt at the UNIX command line enter:

% ORACLE_SID=trgt; export ORACLE_SID

Note that a SYSDBA privilege is not required when connecting to the recovery catalog. The only requirement is that the RECOVERY_CATALOG_OWNER role be granted to the schema owner.

See Also:

The first chapter of the Oracle9i Database Administrator's Guide to learn how to authenticate users on a database, and to create a password file

Command-Line Options When Starting RMAN

RMAN provides a number of command-line options that you can specify when starting RMAN. For example, you can start RMAN:

Starting RMAN Without Connecting to a Database

You can start Recovery Manager at the operating system command line without connecting to a database by issuing the RMAN command without any arguments. For example, enter:

% rman

If you did not specify the LOG option at the command line, then RMAN displays the RMAN prompt:

RMAN>

After the RMAN prompt is displayed, you can issue further commands to connect to the target database, recovery catalog database, or auxiliary database.

If you start RMAN without specifying either CATALOG or NOCATALOG on the command line, then RMAN makes no repository connection. The first time a command is issued that requires the repository, if no CONNECT CATALOG command has been issued yet, then RMAN automatically connects in the default NOCATALOG mode. After that point, the CONNECT CATALOG command is not valid in the session.

Connecting to the Target Database Without a Recovery Catalog

In these examples, assume that these variables have the following meanings.

Variable Meaning

SYS

User with SYSDBA privileges

oracle

The password for connecting as SYSDBA specified in the target database's orapwd file

trgt

The net service name for the target database

Connecting to the Target Database Without a Catalog from the Command Line

To connect from the operating system command line, enter the connection as in the following examples:

# example of operating system authentication
% rman TARGET / NOCATALOG   

# example of Oracle Net authentication
% rman TARGET SYS/oracle@trgt NOCATALOG   

Note that you can also start RMAN without specifying either NOCATALOG or CATALOG as follows:

# example of operating system authentication
% rman TARGET /   

# example of Oracle Net authentication
% rman TARGET SYS/oracle@trgt   

If you do not specify the NOCATALOG keyword on the command line, and if you also do not specify CONNECT CATALOG after RMAN has started, then RMAN connects in NOCATALOG mode by default the first time that you run a command that requires a repository. For example:

% rman TARGET /
RMAN> BACKUP DATABASE;    # RMAN defaults to NOCATALOG mode

Connecting to the Target Database Without a Catalog from the RMAN Prompt

Alternatively, start RMAN and connect to the target database from the RMAN prompt, as in this example:

% rman NOCATALOG
RMAN> CONNECT TARGET

This example connects to the target database by using a password file:

% rman NOCATALOG
RMAN> connect target SYS/oracle@trgt

Connecting to the Target Database and Recovery Catalog

In these examples, assume that you maintain a recovery catalog and that these variables have the following meanings.

Variable Meaning

SYS

User with SYSDBA privileges

oracle

The password for connecting as SYSDBA specified in the target database's orapwd file

trgt

The net service name for the target database

rman

Owner of the recovery catalog having RECOVERY_CATALOG_OWNER privilege

cat

The password for user RMAN specified in the recovery catalog's orapwd file

catdb

The net service name for the recovery catalog database

Connecting to the Target Database and Recovery Catalog from the Command Line

To connect to the target and recovery catalog databases from the operating system command line, enter the connection as in the following examples:

# operating system authentication
% rman TARGET / CATALOG rman/cat@catdb

# Oracle Net authentication
% rman TARGET SYS/oracle@trgt CATALOG rman/cat@catdb

Connecting to the Target Database and Recovery Catalog from the RMAN Prompt

Alternatively, start RMAN and connect to the target database from the RMAN prompt. This example uses operating system authentication:

% rman
RMAN> CONNECT TARGET
RMAN> CONNECT CATALOG rman/cat@catdb

This example uses Oracle Net authentication:

% rman
RMAN> CONNECT TARGET SYS/oracle@trgt 
RMAN> CONNECT CATALOG rman/cat@catdb

Note:

If you run CONNECT TARGET and then do not run CONNECT CATALOG, RMAN connects in NOCATALOG mode by default the first time that you run a command that requires a repository (for example, BACKUP). Thereafter, you cannot run CONNECT CATALOG in the RMAN session.


Connecting to a Target Database in an Oracle Real Application Cluster

RMAN can only connect to one instance in an Oracle Real Application Clusters database at a time. Assume that trgt1, trgt2, and trgt3 are net service names for three instances in an Oracle Real Application Clusters configuration. In this case, you can connect to the target database using only one of these net service names. For example, you can connect as follows:

% rman TARGET SYS/oracle@trgt2 CATALOG rman/cat@catdb 

Each net service name must specify one and only one instance. You cannot specify a net service name that uses Oracle Net features to distribute connections to more than one instance.

Note that the fact that RMAN connects to only one instance for its initial target connection does not preclude running a backup using all three instances. For example, you can configure automatic channels to connect to each cluster instance as follows:

CONFIGURE DEFAULT DEVICE TYPE TO sbt;
CONFIGURE DEVICE TYPE sbt PARALLELISM 3;
CONFIGURE CHANNEL 1 DEVICE TYPE sbt CONNECT = 'SYS/oracle@trgt1';
CONFIGURE CHANNEL 2 DEVICE TYPE sbt CONNECT = 'SYS/oracle@trgt2';
CONFIGURE CHANNEL 3 DEVICE TYPE sbt CONNECT = 'SYS/oracle@trgt3';

Then, make a whole database backup by running the following command:

BACKUP DATABASE;

Connecting to an Auxiliary Database

To use the DUPLICATE command or to perform RMAN TSPITR, you need to connect to an auxiliary instance. In these examples, assume that these variables have the following meanings.

Variable Meaning

SYS

User with SYSDBA privileges

oracle

The password for connecting as SYSDBA specified in the target database's orapwd file

trgt

The net service name for the target database

rman

Owner of the recovery catalog having RECOVERY_CATALOG_OWNER privilege

cat

The password for user RMAN specified in the recovery catalog's orapwd file

catdb

The net service name for the recovery catalog database

aux

The password for connecting as SYSDBA specified in the auxiliary database's orapwd file

auxdb

The net service name for the auxiliary database

If the auxiliary database uses password files for authentication, then you can connect using a password for either local or remote access. If you are connecting remotely through a net service name, then authentication through a password file is mandatory.

Connecting to an Auxiliary Database from the Command Line

To connect to an auxiliary instance from the operating system command line, enter the following:

% rman AUXILIARY SYS/aux@auxdb

To connect to the target, auxiliary, and recovery catalog databases, issue the following (all on one line):

% rman TARGET SYS/oracle@trgt CATALOG rman/cat@catdb AUXILIARY SYS/aux@auxdb

Connecting to an Auxiliary Database from the RMAN Prompt

Alternatively, you can start RMAN and connect to the auxiliary database from the RMAN prompt:

% rman
RMAN> CONNECT AUXILIARY SYS/aux@auxdb

To connect to the target, auxiliary, and recovery catalog databases, issue:

% rman
RMAN> CONNECT TARGET SYS/oracle@trgt
RMAN> CONNECT CATALOG rman/cat@catdb
RMAN> CONNECT AUXILIARY SYS/aux@auxdb
See Also:

Hiding Passwords When Connecting to Databases

To connect to RMAN from the operating system command line and hide authentication information, you must first start RMAN and then perform either of the following actions:

For example, if you are running RMAN in an UNIX environment, then you can use the following procedure:

  1. Start RMAN without connecting to any databases:
    % rman
    
    
  2. Place the connection information in a text file. For example, place the following lines in a file called connect.rman:
    CONNECT TARGET SYS/oracle@trgt 
    CONNECT CATALOG rman/cat@catdb
    
    
  3. Change the permissions on the connect script so that everyone can execute the script but only the desired users have read access. For example, enter:
    % chmod 711 connect.rman
    
    
    
  4. Run the script from the RMAN prompt to connect to the target and catalog databases. For example:
    RMAN> @connect.rman
    

Executing RMAN Commands Through a Pipe

The RMAN pipe interface is an alternative method for issuing commands to RMAN and receiving the output. By using a pipe, RMAN can interface with the DBMS_PIPE PL/SQL package and avoid the operating system command shell altogether.

RMAN does not permit the pipe interface to be used with public pipes, because they are a potential security problem. With a public pipe, any user who knows the name of the pipe can send commands to RMAN and intercept its output.

If the pipes are not already initialized, then RMAN creates them as private pipes. If you want to put commands on the input pipe before starting RMAN, be careful to first create the pipe by calling DBMS_PIPE.CREATE_PIPE. Whenever a pipe is not explicitly created as a private pipe, the first access to the pipe automatically creates it as a public pipe, and RMAN returns an error if it is told to use a public pipe.


Note:

If multiple RMAN sessions can run against the target database, then use unique pipe names for each session of RMAN. The DBMS_PIPE.UNIQUE_SESSION_NAME function is one method that can be used to generate unique pipe names.


Note that the order of steps in the procedure does not have to be exactly as shown in scenario 1. In scenario 2, you put commands into the pipe and then connect to the database.

To use RMAN in pipe mode (scenario 1):

  1. Start RMAN by connecting to a target database (required) and specifying the PIPE option. For example, issue:
    % rman PIPE abc TARGET SYS/oracle  @trgt
    
    

    You can also specify the TIMEOUT option, which forces RMAN to exit automatically if it does not receive any input from the input pipe in the specified number of seconds. For example, enter:

    % rman PIPE abc TARGET SYS/oracle@trgt TIMEOUT = 60
    
    
  2. Connect to the target database and put the desired commands on the input pipe by using DBMS_PIPE.PACK_MESSAGE and DBMS_PIPE.SEND_MESSAGE. In pipe mode, RMAN issues message RMAN-00572 when it is ready to accept input instead of displaying the standard RMAN prompt.
  3. Read the RMAN output from the output pipe by using DBMS_PIPE.RECEIVE_MESSAGE and DBMS_PIPE.UNPACK_MESSAGE.
  4. Repeat steps 2 and 3 to execute further commands with the same RMAN instance that was started in step 1.
  5. Send the EXIT command to force RMAN to terminate. Alternatively, use the TIMEOUT option, in which case RMAN terminates automatically after not receiving any input for the specified length of time).

To use RMAN in pipe mode (scenario 2):

  1. After connecting to the target database, create a pipe (if it does not already exist under the name ORA$RMAN_pipe_IN).
  2. Put the desired commands on the input pipe. In pipe mode, RMAN issues message RMAN-00572 when it is ready to accept input instead of displaying the standard RMAN prompt.
  3. Start RMAN with the PIPE option, and specify TIMEOUT = 0. For example, enter:
    % rman PIPE abc TARGET SYS/oracle@trgt TIMEOUT = 0
    
    
  4. RMAN reads the commands that were put on the pipe and executes them by using DBMS_PIPE.PACK_MESSAGE and DBMS_PIPE.SEND_MESSAGE. When it has exhausted the input pipe, RMAN exits immediately.
  5. Read RMAN output from the output pipe by using DBMS_PIPE.RECEIVE_MESSAGE and DBMS_PIPE.UNPACK_MESSAGE.

    See Also:

    Oracle9i Supplied PL/SQL Packages and Types Reference for documentation on the DBMS_PIPE package and "RMAN Pipe Interface" for a brief overview of RMAN pipes

Exiting RMAN

To quit RMAN and terminate the program, type EXIT or QUIT at the RMAN prompt. For example:

RMAN> exit
See Also:

Oracle9i Recovery Manager Reference for EXIT syntax or Oracle9i Recovery Manager Reference for QUIT syntax


Go to previous page Go to next page
Oracle
Copyright © 1996, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents
Go To Index
Index

Master Index

Feedback