ITPub博客

首页 > Linux操作系统 > Linux操作系统 > RMAN(一)Starting and Interacting with the RMAN Client

RMAN(一)Starting and Interacting with the RMAN Client

原创 Linux操作系统 作者:muke77 时间:2010-09-10 10:41:06 0 删除 编辑

Starting and Exiting RMAN

  • 直接启动rman

    % rman
    
  • Start the RMAN executable at the operating system command line while connecting to a target database and, possibly, a recovery catalog, as in the following examples:

    % rman TARGET /                       # operating system authentication 
[oracle@localhost ~]$ rman TARGET /   

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Sep 10 10:56:29 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: T1DB (DBID=139407305)

RMAN>
  • % rman TARGET SYS@prod NOCATALOG      # RMAN prompts for SYS password 
[oracle@localhost ~]$ rman target sys/123@t1db nocatalog

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Sep 10 10:57:47 2010

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: T1DB (DBID=139407305)
using target database control file instead of recovery catalog

RMAN>
  • % rman TARGET / CATALOG rco@catdb     # RMAN prompts for rco password
    
该种连接方式不太明了。


Specifying the Location of RMAN Output

By default, RMAN writes command output to standard output. To redirect output to a log file, enter the LOG parameter on the command line when starting RMAN, as in the following example:
默认rman写命令输出到标准输出,可以重定位输出到log文件
% rman LOG /tmp/rman.log or % rman | tee rman.log

Setting Globalization Support Environment Variables for RMAN

If you are going to use RMAN to connect to an unmounted database and 
mount the database later while RMAN is still connected, then set the 
NLS_LANG environment variable so that it also specifies the character
set used by the database.
rman连接一个unmount状态的数据库,设置了NLS_LANG将对数据库
mount之后的状态起作用

A database that is not mounted assumes the default character set,
which is US7ASCII. If your character set is different from the default,
then RMAN returns errors after the database is mounted.
数据库再unmount状态下默认字符集是US7ASCII.如果你数据库的字符集
不一样,就会报错。这就是设置NLS_LANG环境变量的原因

NLS_LANG=american NLS_DATE_FORMAT='Mon DD YYYY HH24:MI:SS'
NLS_LANG and NLS_DATE_FORMAT must be set for to be used.

Entering RMAN Commands:

Entering RMAN Commands at the RMAN Prompt

Most RMAN commands take a number of parameters and must end with a semicolon. Some commands, such as , , and , can be used with or without a semicolon.
大多数rman命令以分号结束。
RMAN> BACKUP DATABASE
2> INCLUDE CURRENT 
3> CONTROLFILE
4> ;

Using Command Files with RMAN

创建命令文件cmdfile1,内容是:BACKUP DATABASE PLUS ARCHIVELOG;
  1. OS promot执行命令文件(执行完,自动退出rman)
    % rman TARGET / @cmdfile1
    
  2. rman promot执行命令文件
    RMAN> @cmdfile1

Using Substitution Variables in Command Files

To create and use a dynamic shell script.:

  1. Create an RMAN command file that uses substitution variables.

    The following example shows the contents of a command file named quarterly_backup.cmd, which is run every quarter. The script. uses substitution variables for the name of the tape set, for a string in the FORMAT specification, and for the name of the restore point to be created.

    # quarterly_backup.cmd CONNECT TARGET / RUN { ALLOCATE CHANNEL c1 DEVICE TYPE sbt PARMS 'ENV=(OB_MEDIA_FAMILY=&1)'; BACKUP DATABASE TAG &2 FORMAT '/disk2/bck/&1%U.bck' KEEP FOREVER RESTORE POINT &3; } EXIT;
  2. Create a shell script. that you can use to run the RMAN command file created in the previous step.

    The following example creates a shell script. named runbackup.sh. The example creates shell variables for the format and restore point name and accepts the values for these variables as command-line arguments to the script.

    #!/bin/tcsh
    # name: runbackup.sh
    # usage: use the tag name and number of copies as arguments
    set media_family = $argv[1]
    set format = $argv[2]set restore_point = $argv[3]
    rman @'/disk1/scripts/whole_db.cmd' USING $media_family $format $restore_point
    
  3. Execute the shell script. created in the previous step, specifying the desired arguments on the command line.

    The following example runs the runbackup.sh shell script. and passes it archival_backup as the media family name, bck0906 as the format string, and FY06Q3 as the restore point name.

    % runbackup.sh archival_backup bck0906 FY06Q3
    

Checking RMAN Syntax at the Command Line

  • To check RMAN syntax at the command line:
Start RMAN with the CHECKSYNTAX parameter.

% rman CHECKSYNTAX
RMAN> run [ backup database; ]
RMAN-00571:
RMAN-00569:
RMAN-00571:
RMAN-00558: error encountered while parsing input commands RMAN-01006: error signalled during parse
RMAN-02001: unrecognized punctuation symbol "[" RMAN> run { backup database; } The command has no syntax errors





来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/24419958/viewspace-673125/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: at命令用法
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2010-08-11

  • 博文量
    14
  • 访问量
    14383