Connecting to
RMAN
RMAN is an O/S level tool and is available at the $ORACLE_HOME/bin
folder. If Oracle Home is not set, than you need to give a
complete path for the binary to fire it up. Otherwise, it can
just be started by simply typing over the command (terminal over
Linux) prompt as:
This would bring you to the RMAN prompt from where you can
connect to the target database both by using or not using the
recovery catalog. Note that
just typing RMAN would not actually get you connected and you do
need an explicit connect command to be given before you can use
RMAN.
Connecting to RMAN Without Using Recovery Catalog
If you have not created the recovery catalog yet, you can still
work with RMANwithout any
issues. To connect to RMAN without using the catalog, all you need
to do is pass on the target databases sys user name and its
password with the correct network alias if you are firing up RMAN
while sitting at another machine other than the actual server. All
the following commands assume that you are on the same machine
where the database is installed whom you want to backup.
E:\> set ORACLE_SID=ORCL
E:\>rman target / catalog=rcat/rcat@<catalog database>
connected to target database: ORCL (DBID=1214859607)
using target database control file instead of recovery catalog
RMAN>
This shows that you have been told by RMAN that you are not
using the recovery catalog but the target databases control file.
The switch nocatalog is the default option and can be skipped if
you do not intend to use the catalog. If this would have been a
client machine, you could use the connection string and the sys
user with its password to get connected like below:
E:\>rman target
sys/oracle@orcl
connected to target database: ORCL (DBID=1214859607)
using target database control file instead of recovery catalog
RMAN>
One thing which must have crossed your mind is that the above
command displays the password wide open for any one which surely
is not a good idea. This can be changed by just typing the user
name sys and entering the password in the next line without it
being displayed to anyone.
E:\>rman target
sys@orcl
target database Password:
connected to target database: ORCL (DBID=1214859607)
RMAN>
Connecting to RMAN using a Recovery Catalog
If you want to use RMAN with the recovery catalog,
there is nothing much that you need to do except to use one switch
with the user name and password of the catalog user. This user
should be created in the catalog database.
E:\>rman target / catalog=rcat/rcat
connected to target database: ORCL (DBID=1214859607)
connected to recovery catalog database
RMAN>
This time, you are clearly told that you are using the catalog,
not the control file of the target database. This topic is
explained in detail in Chapter 8, Managing the Recovery Catalog?.
You can also use a log file for future reference to see all the
commands and their outputs which you entered. By default, entire
output is printed on the screen of the RMAN prompt itself, which
would get lost once you close the session. Using the log file
helps preserve that output for any kind of reference or debugging
that you would like to do. The file can be written in the append
mode as well so that the previously written content will not get
erased.
Here is how you can use the log file. Note how nothing is
printed on the rmans prompt but gets logged into the log file.
E:\>rman target / catalog=rcat/rcat
LOG=E:\RMAN.LOG
RMAN> report schema;
RMAN> exit
E:\>more RMAN.log
connected to target database: ORCL (DBID=1214859607)
connected to recovery catalog database
RMAN>
starting full resync of recovery catalog
full resync complete
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- -------
------------------------
1 500 SYSTEM YES
E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF
2 30 UNDOTBS1 YES
E:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF
If you want to run some specific command while connecting to the
RMAN prompt, you can do so by using the switch cmdfile parameter
which is similar to running a SQL file while connecting to the SQL
prompt. This does require a RMAN script file to be available which
can be created using any editor of your choice. The file should be
usable by the user who is running the RMAN with proper permissions
and correct syntax. Here is a simple script that shows how it can
be used while firing up RMAN.
E:\>copy con samplefile
report schema;
1 file(s) copied.
E:\> set ORACLE_SID=ORCL
E:\>rman target / catalog=rcat/rcat@<catalog database>
cmdfile='e:\samplefile'
connected to target database: ORCL (DBID=1214859607)
connected to recovery catalog database
RMAN> report schema;
<.....output trimmed .....>
# The output is the same is in the above command. RMAN will
automatically run the command from e:\sampefile file
If you are going to create a duplicate database, you can use
the auxilary mode of the RMAN connection. Using this, you can
connect to the auxilary instance, which is required to create a
duplicate database. This can be done like this:
E:\ rman
AUXILIARY SYS/aux@remote
This type of connection is described further in Chapter 5.