RMAN链接及简单操做

1、RMAN的进入与退出sql

一、启动RMAN并链接到本地目标数据库数据库

 
C:\Users\Administrator>set oracle_sid=orcl(若是只有一个实例,则不须要指定,RMAN会自动链接到默认实例)

C:\Users\Administrator>rman target/

恢复管理器: Release 11.2.0.1.0 - Production on 星期二 10月 7 11:42:57 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

链接到目标数据库: ORCL (DBID=1385990360)

RMAN>
 

二、能够先启动RMAN,再经过CONNECT建立链接oracle

 
C:\Users\Administrator>RMAN

恢复管理器: Release 11.2.0.1.0 - Production on 星期二 10月 7 11:51:53 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

RMAN> CONNECT TARGET/

链接到目标数据库: ORCL (DBID=1385990360)

RMAN>
 

三、链接到远程数据库post

 
C:\Users\Administrator>rman target sys/rusking@orcl;

恢复管理器: Release 11.2.0.1.0 - Production on 星期二 10月 7 12:01:56 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

链接到目标数据库: ORCL (DBID=1385990360)

RMAN>
 

四、记录RMAN日志spa

C:\Users\Administrator>rman target/ log d:\rman_logs.txt
RMAN>

五、退出RMAN操作系统

经过执行host命令暂时退出rman的命令提示符而进入到操做系统的命令环境日志

 
C:\Users\Administrator>rman target/

恢复管理器: Release 11.2.0.1.0 - Production on 星期二 10月 7 12:10:45 2014

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

链接到目标数据库: ORCL (DBID=1385990360)

RMAN> host;

Microsoft Windows [版本 6.1.7600]
版权全部 (c) 2009 Microsoft Corporation。保留全部权利。

C:\Users\Administrator>sqlplus / as sysdba;

SQL*Plus: Release 11.2.0.1.0 Production on 星期二 10月 7 12:10:58 2014

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


链接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> exit
从 Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options 断开

C:\Users\Administrator>exit
主机命令完成

RMAN>
 

2、RMAN简单命令code

一、在RMAN下启动和关闭数据库(跟SQL环境同样)orm

 
RMAN> shutdown immediate;

使用目标数据库控制文件替代恢复目录
数据库已关闭
数据库已卸装
Oracle 实例已关闭

RMAN> startup

已链接到目标数据库 (未启动)
Oracle 实例已启动
数据库已装载
数据库已打开

系统全局区域总计     855982080 字节

Fixed Size                     2180544 字节
Variable Size                654314048 字节
Database Buffers             192937984 字节
Redo Buffers                   6549504 字节

RMAN>
 

也能够执行startup mount,而后再利用alter database open命令打开数据库以及shutdown normal,shutdown abort等。对象

二、RMAN下执行SQL语句

rman中的sql环境不能执行SELECT语句。

 
RMAN> SQL 'ALTER SYSTEM ARCHIVE LOG ALL';

RMAN> SQL 'select 1+2 from dual';

sql 语句: select 1+2 from dual

RMAN> SQL 'select * from scott.emp';

sql 语句: select * from scott.emp
 

三、查看及修改RMAN配置

 
RMAN> show all;

db_unique_name 为 ORCL 的数据库的 RMAN 配置参数为:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   'D:\oracle_bak_test\%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'D:\APP\ADMINISTRATOR\PRODUCT\11.2.0\DBHOME_1\DATABASE\SNCFORCL.ORA'; # default

RMAN> CONFIGURE BACKUP OPTIMIZATION OFF;

旧的 RMAN 配置参数:
CONFIGURE BACKUP OPTIMIZATION ON;
新的 RMAN 配置参数:
CONFIGURE BACKUP OPTIMIZATION OFF;
已成功存储新的 RMAN 配置参数

RMAN> show channel;

db_unique_name 为 ORCL 的数据库的 RMAN 配置参数为:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   'D:\oracle_bak_test\%U';

RMAN> show device type;

db_unique_name 为 ORCL 的数据库的 RMAN 配置参数为:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default

RMAN> show default device type;

db_unique_name 为 ORCL 的数据库的 RMAN 配置参数为:
CONFIGURE DEFAULT DEVICE TYPE TO DISK;

RMAN>
 

四、列出备份信息

列出数据库中全部文件的备份信息:
RMAN>LIST BACKUP OF DATABASE;
列出指定表空间的备份信息:
RMAN>LIST COPY OF TABLESPACE 'SYSTEM';
列出指定数据文件的备份信息:
RMAN>LIST BACKUP OF DATAFILE 'D:\RUSKY\RUSKY_DATA01,DBF';

五、删除备份

用于删除RMAN备份记录及相应的物理文件。当使用RMAN执行备份操做时,会在RMAN资料库中生成RMAN备份记录,而且RMAN备份记录被存放在目标数据库的控制文件中,若是配置了恢复目录,那么该备份记录也会被存放到恢复目录中。

5.一、删除陈旧备份

当使用RMAN执行备份操做时,RMAN会根据备份冗余策略肯定陈旧备份。     

RMAN> delete obsolete;

5.二、删除EXPIRED备份

执行crosscheck命令核对备份集,那么会将该备份集标记为EXPIRED状态。为了删除相应的备份记录,能够执行delete expired backup命令。     

RMAN> delete expired backup;

5.三、删除EXPIRED副本

RMAN> delete expired copy;

5.四、删除特定备份集

RMAN> delete backupset 22;

5.五、删除特定备份片

RMAN> delete backuppiece 'd:\backup\rusky.bak';

5.六、删除全部备份集

RMAN> delete backup;

5.七、删除特定映像副本

RMAN> delete datafilecopy 'd:\backup\rusky.bak';

5.八、删除全部映像副本

RMAN> delete copy;

5.九、在备份后删除输入对象

RMAN> delete archivelog all delete input;

RMAN> delete backupset 22 format = ''d:\backup\%u.bak'' delete input;  

相关文章
相关标签/搜索