首页 > 代码库 > 官方文档 恢复备份指南四 Starting and Interacting with the RMAN Client
官方文档 恢复备份指南四 Starting and Interacting with the RMAN Client
- 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 管道接口
% 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 LOG /tmp/rman.log
% rman | tee rman.log
RMAN>
NLS_DATE_FORMAT
和NLS_LANG
参数来设置RMAN使用的语言和时间格式 NLS_LANG=american 如果RMAN客户端可以数据库的语言不同,会报错
NLS_DATE_FORMAT=‘Mon DD YYYY HH24:MI:SS‘
本节内容:
- 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语法
RMAN> BACKUP DATABASE
2> INCLUDE CURRENT
3> CONTROLFILE
4> ;
% rman TARGET / @cmdfile1
RMAN> @cmdfile1
# 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;
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;
<3>执行shell
#!/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
5).Checking RMAN Syntax
% runbackup.sh archival_backup bck0906 FY06Q3
CHECKSYNTAX
来检查命令的正确性CHECKSYNTAX
选项检查脚本语法
RMAN> backup database;
此命令不存在任何语法错误
- About RMAN Database Connections
- Connecting RMAN to an Auxiliary Database
- Making RMAN Database Connections Within Command Files
- Diagnosing RMAN Connection Problems
Type of Database Connection | Keyword | Description |
---|---|---|
target database |
| A database to be backed up or restored by RMAN |
recovery catalog database |
| A database that provides an optional backup store for the RMAN repository in addition to the control file. |
auxiliary instance or auxiliary database |
| A 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. |
% 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)
Value Used in Example | Meaning |
---|---|
| User with |
| The net service name for the target database |
| User that owns the recovery catalog schema. This is a user defined in the recovery catalog database that has been granted the |
| The net service name for the recovery catalog database |
| The net service name for an auxiliary instance |
% rman TARGET / NOCATALOG
connected to target database: PROD (DBID=39525561)
using target database control file instead of recovery catalog
RMAN>
% rman TARGET SYS@prod NOCATALOG
target database Password:
password
connected to target database: PROD (DBID=39525561)
RMAN>
% 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
% 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
===================
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 过程已成功完成。