本章讲:

  • Starting and Exiting RMAN
  • Specifying the Location of RMAN Output                                                        指定RMAN输出位置
  • Setting Globalization Support Environment Variables for RMAN            设置RMAN全局变量
  • Entering RMAN Commands                                                                                      进入RMAN命令
  • Making Database Connections with RMAN                                                        用RMAN连接数据库
  • Using the RMAN Pipe Interface                                                                                使用RMAN 管道接口

1.Starting and Exiting RMAN 打开RMAN
    RMAN随数据库一起安装,路径在$ORACLE_HOME/bin下.打开方式
    % rman                                                                         进入后再输入用户名密码
    % rman TARGET /                       # operating system authentication        操作系统验证,即在数据库服务器上使用RMAN
    % rman TARGET SYS@prod NOCATALOG      # RMAN prompts for SYS password          使用SYS用户登录RMAN
    % rman TARGET / CATALOG rco@catdb     # RMAN prompts for rco password          在数据库服务器上使用操作系统验证连接数据库并连接catalog

   退出:RMAN> EXIT



2.Specifying the Location of RMAN Output  指定RMAN输出位置
    默认下,RMAN将输出内容写到标准输出(命令台),可以将内容输出到日志文件:
    % rman LOG /tmp/rman.log

    上面的方式只会将RMAN的输出内容写到日志,如果想把输入内容也写到日志,可以使用linux的tee命令:
    % rman | tee rman.log
    RMAN>


3.Setting Globalization Support Environment Variables for RMAN 设置RMAN全局变量
    在使用RMNA之前,可能需要设置NLS_DATE_FORMAT 和NLS_LANG 参数来设置RMAN使用的语言和时间格式
    NLS_LANG=american                            如果RMAN客户端可以数据库的语言不同,会报错
    NLS_DATE_FORMAT='Mon DD YYYY HH24:MI:SS'



4.Entering RMAN Commands 输入RMAN命令
    本节内容:
  • Entering RMAN Commands at the RMAN Prompt                            使用RMAN提示输入命令
  • Using Command Files with RMAN                                                 使用命令文件
  • Entering Comments in RMAN Command Files                                编辑命令文件
  • Using Substitution Variables in Command Files                              在命令文件使用变量
  • Checking RMAN Syntax                                                                检查RMAN语法

1)Entering RMAN Commands at the RMAN Prompt 
    RMAN> BACKUP DATABASE
    2> INCLUDE CURRENT
    3> CONTROLFILE
    4> ;



2)Using Command Files with RMAN
    可以将命令保存在文件中,然后用@调用,如cmdfil1中:
    BACKUP DATABASE PLUS ARCHIVELOG;

  调用:
    % rman TARGET / @cmdfile1

命令执行完毕后,RMAN会自动退出
也可以在RMAN提示符下使用文件:
    RMAN> @cmdfile1



3)Entering Comments in RMAN Command Files
    # Command file name: mybackup.rman                    #是注释符号
    # The following command backs up the database
    BACKUP DATABASE;
    # The following command backs up the archived redo logs
    BACKUP ARCHIVELOG ALL;



4)Using Substitution Variables in Command Files
    可以设置变量,使RMAN变得更加灵活,如&1代表第一个变量,&2代表第二个变量.&1.3的意义:&1表示传入的第一个变量,如backup,.3表示接在变量后面的字符,&1.3表示backup3.
    <1>创建RMAN脚本,包含变量


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>创建shell脚本来调用 RMAN脚本
#!/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>执行shell

% runbackup.sh archival_backup bck0906 FY06Q3




5).Checking RMAN Syntax

    在执行命令之前可以用CHECKSYNTAX 来检查命令的正确性
    启动RMAN时指定CHECKSYNTAX 选项
    % rman CHECKSYNTAX
     输入脚本
RMAN> backup database;
此命令不存在任何语法错误

检查脚本语法

    % rman CHECKSYNTAX @filename
    

 5. Making Database Connections with RMAN
  • About RMAN Database Connections
  • Connecting RMAN to an Auxiliary Database
  • Making RMAN Database Connections Within Command Files
  • Diagnosing RMAN Connection Problems

    1)About RMAN Database Connections 关于RMAN连接
    RMAN连接选项
    
Type of Database Connection Keyword Description

target database

TARGET

A database to be backed up or restored by RMAN

recovery catalog database

CATALOG

A database that provides an optional backup store for the RMAN repository in addition to the control file.

auxiliary instance or auxiliary database

AUXILIARY

physical standby database, or a database instance created for performing a specific task such as creating a duplicate database, transporting tablespaces, or performingtablespace point-in-time recovery (TSPITR).

For many tasks that use an auxiliary database, RMAN creates an automatic auxiliary instance for use during the task, connects to it, performs the task, and then destroys it when the task is completed. You do not give any explicit command to connect to automatic auxiliary instances.



    2)连接数据库的验证方式
    RMAN连接数据库的方式与SQLPLUS 一样,不过RMAN需要以SYSDB的身份连接.
    为了使用操作系统身份验证,首先设置ORACLE_SID
% ORACLE_SID=prod; export ORACLE_SID

    连接
% ORACLE_SID=prod; export ORACLE_SID


    使用密码验证:
% rman TARGET SYS@prod
 
target database Password:
passwordconnected to target database: PROD1 (DBID=39525561)



3)连接数据库
    连接语法
Value Used in Example Meaning

SYS

User with SYSDBA privileges

prod

The net service name for the target database

rco

User that owns the recovery catalog schema. This is a user defined in the recovery catalog database that has been granted the RECOVERY_CATALOG_OWNER role.

catdb

The net service name for the recovery catalog database

aux

The net service name for an auxiliary instance



    连接target,操作系统验证
% rman TARGET / NOCATALOG
 
connected to target database: PROD (DBID=39525561)
using target database control file instead of recovery catalog
 
RMAN>

    
    连接target,密码验证
% rman TARGET SYS@prod NOCATALOG
 
target database Password:
password
connected to target database: PROD (DBID=39525561)
 
RMAN>

    
    同时连接target和catalog
% rman TARGET SYS@prod CATALOG rco@catdb
 
target database Password:
password
connected to target database: PROD (DBID=39525561)
recovery catalog database Password:
password
connected to recovery catalog database
 
RMAN>



    在命令提示符中连接:
RMAN> CONNECT TARGET /
RMAN> CONNECT CATALOG rco@catdb

RMAN> CONNECT TARGET SYS@prod


    连接辅助数据库.
    在duplicateo(复制)数据库和执行基于时间点的表空间恢复(TSPITR)时,必须使用auxiliary instance连接辅助数据库
% rman
RMAN> CONNECT TARGET /
RMAN> CONNECT AUXILIARY SYS@aux
 
auxiliary database Password:
passwordconnected to auxiliary database: PROD (DBID=30472568)


    在脚本中连接数据库.
    脚本内容如下
cat > listbkup.rman << EOF
CONNECT TARGET /
LIST BACKUP;
EOF

    执行
% rman @listbkup.rman

    显示
RMAN> CONNECT TARGET *
2> LIST BACKUP;
3>
connected to target database: RDBMS (DBID=771530996)
 
using target database control file instead of recovery catalog
 
List of Backup Sets
===================




6.Using the RMAN Pipe Interface 使用RMAN通道接口
    RMAN管道接口就是通过DBMS_PIPE 包来执行RMAN命令并输出结果,直接在SQLPLUS中执行.
 DECLARE
2 V_INPUT VARCHAR2(32767) := 'BACKUP DATABASE;';
3 V_OUT NUMBER;
4 BEGIN
5 DBMS_PIPE.PACK_MESSAGE(V_INPUT);
6 V_OUT := DBMS_PIPE.SEND_MESSAGE('ORA$RMAN_P1_IN');
7 DBMS_OUTPUT.PUT_LINE(V_OUT);
8 COMMIT;
9 END;
10 /
0
启动 backup 于 02-4月 -06
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: sid=16 devtype=DISK
通道 ORA_DISK_1: 正在启动 full 数据文件备份集
通道 ORA_DISK_1: 正在指定备份集中的数据文件
在备份集中包含当前的 SPFILE
备份集中包括当前控制文件
输入数据文件 fno=00001 name=F:ORACLEORADATATESTSYSTEM01.DBF
输入数据文件 fno=00002 name=F:ORACLEORADATATESTUNDOTBS01.DBF
输入数据文件 fno=00006 name=F:ORACLEORADATATESTYANGTK01.DBF
输入数据文件 fno=00003 name=F:ORACLEORADATATESTINDX01.DBF
输入数据文件 fno=00005 name=F:ORACLEORADATATESTUSERS01.DBF
输入数据文件 fno=00004 name=F:ORACLEORADATATESTTOOLS01.DBF
通道 ORA_DISK_1: 正在启动段 1 于 02-4月 -06
通道 ORA_DISK_1: 已完成段 1 于 02-4月 -06
段 handle=F:ORACLEORACLE920DATABASEIHFHTAE_1_1 comment=NONE
通道 ORA_DISK_1: 备份集已完成, 经过时间:00:01:47
完成 backup 于 02-4月 -06
RMAN-00572: waiting for dbms_pipe input
PL/SQL 过程已成功完成。


感觉管道没啥用




官方文档 恢复备份指南四 Starting and Interacting with the RMAN Client的更多相关文章

  1. 官方文档 恢复备份指南三 Recovery Manager Architecture

    本节讨论以下问题: About the RMAN Environment                        关于RMAN环境 RMAN Command-Line Client        ...

  2. 官方文档 恢复备份指南二 Getting Started with RMAN

    本章对RMAN进行基本的熟悉和了解   1.Overview of the RMAN Environment    RMAN运行时需要的最小环境:      target database       ...

  3. 官方文档 恢复备份指南一 Introduction to Backup and Recovery

    1.备份分为:物理备份和逻辑备份    物理备份:备份数据文件  控制文件  归档日志文件     逻辑备份:EXP EXPDP备份等 物理备份为主,逻辑做补充     2.错误的类型         ...

  4. 官方文档 恢复备份指南八 RMAN Backup Concepts

    本章内容 Consistent and Inconsistent RMAN Backups Online Backups and Backup Mode Backup Sets Image Copie ...

  5. 官方文档 恢复备份指南六 Configuring the RMAN Environment: Advanced Topics

    RMAN高级设置. 本章内容: Configuring Advanced Channel Options  高级通道选项 Configuring Advanced Backup Options 高级备 ...

  6. 官方文档 恢复备份指南七 Using Flashback Database and Restore Points

    本章内容: Understanding Flashback Database, Restore Points and Guaranteed Restore Points Logging for Fla ...

  7. 官方文档 恢复备份指南五 Configuring the RMAN Environment

    本章内容: Configuring the Environment for RMAN Backups    配置RMAN环境 Configuring RMAN to Make Backups to a ...

  8. 《KAFKA官方文档》入门指南(转)

    1.入门指南 1.1简介 Apache的Kafka™是一个分布式流平台(a distributed streaming platform).这到底意味着什么? 我们认为,一个流处理平台应该具有三个关键 ...

  9. Protocol Buffers(Protobuf) 官方文档--Protobuf语言指南

    Protocol Buffers(Protobuf) 官方文档--Protobuf语言指南 约定:为方便书写,ProtocolBuffers在下文中将已Protobuf代替. 本指南将向您描述如何使用 ...

随机推荐

  1. 如何用Redlock实现分布式锁

    转载请标明出处: http://blog.csdn.net/forezp/article/details/70305336 本文出自方志朋的博客 之前写过一篇文章<如何在springcloud分 ...

  2. Python常用模块之os和sys

    1.OS常用方法 os.access(path, mode) # 检验权限模式 os.getcwd() #获取当前工作目录,即当前python脚本工作的目录路径 os.chdir("dirn ...

  3. 牛B的swift屏幕旋转经验终结者(OC统一思路)

    牛B的swift屏幕旋转经验终结者(OC统一思路) 1.AppDelegate (1)定义变量 var blockRotation: Bool = false (2)定义方法 Swift代码 func ...

  4. iOS之ShareSDK各社交平台申请AppKey的网址及申请流程汇总

    平台 开放平台地址 APPkey 申请流程 新浪微博 http://open.weibo.com http://bbs.mob.com/thread-89-1-4.html 新浪微博开放平台接入tip ...

  5. 伪造Http请求IP地址

    注意:伪造Http请求IP地址一般为非推荐使用手段 一般使用:简单投票网站重复投票,黑别人网站 在项目开发中(web项目),我负责的系统(简称PC),需要调其它系统接口,并且该系统需要获取客户端(浏览 ...

  6. 《瞿葩的数字游戏》T3-三角圣地(Lucas)

    题目背景 国王1带大家到了数字王国的中心:三角圣地. 题目描述 不是说三角形是最稳定的图形嘛,数字王国的中心便是由一个倒三角构成.这个倒三角的顶端有一排数字,分别是1~N.1~N可以交换位置.之后的每 ...

  7. <逆向学习第二天>如何手动脱UPX、Aspack壳

    UPS.AsPack压缩壳介绍: UPX .AsPack是一款先进的可执行程序文件压缩器.压缩过的可执行文件体积缩小50%-70% ,这样减少了磁盘占用空间.网络上传下载的时间和其它分布以及存储费用. ...

  8. raid概述与CentOS7.4中raid5的搭建与测试

    前言 一.raid的定义与作用 raid(独立冗余磁盘阵列).raid技术通过把多个硬盘设备组合成一个容量更大的,安全性更好的磁盘阵列.把数据切割成许多区段后分别放在不同的物理磁盘上,然后利用分散读写 ...

  9. thinkphp验证码实现。

    作为我大天朝的程序员,如果不会点thinkphp框架确实有点说不过去了(虽然作为菜鸟的我才入坑没几个月).不过不会也没关系,很简单的一个php框架.今天为大家介绍的是thinkphp如何实现验证码的功 ...

  10. Centos6 Ruby 1.8.7升级至Ruby 2.3.1的方法

    本文章地址:https://www.cnblogs.com/erbiao/p/9117018.html#现在的版本 [root@hd4 /]# ruby --version ruby (-- patc ...