RMAN的命令类型
1. sqlplus命令
[oracle@oracle admin]$ export ORACLE_SID=orcl
[oracle@oracle admin]$ rman target / RMAN> shutdown abort
RMAN> startup
2. 操作系统命令:
RMAN> run { host "ls -l /u01/app/oracle";}
3. 还可以执行SQL语句,但是select除外
RMAN> sql 'create table scott.e as select * from scott.emp';
RMAN> sql 'drop table scott.e purge';
配置保留策略:
配置冗余的份数:
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 1; RMAN> list backup of database;
RMAN> report obsolete; RMAN> backup tablespace users format='/u01/app/oracle/backup/rmanbk/%d_%s.dbf'; RMAN> list backup of database;
RMAN> report obsolete; RMAN> backup tablespace users format='/u01/app/oracle/backup/rmanbk/%d_%s.dbf'; RMAN> list backup of database;
RMAN> report obsolete; RMAN> delete noprompt obsolete;
RMAN> report obsolete;
改变冗余的值:
RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
RMAN> show all; RMAN> backup tablespace users format='/u01/app/oracle/backup/rmanbk/%d_%s.dbf';
RMAN> report obsolete ;--因为冗余为2,所以没有过期的备份
恢复窗口:
RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 2 DAYS;
这种保留策略要求数据库了有一份备份,这份备份必须能够恢复到窗口内的任何一刻,而且这份备份必须是离窗口最近的恢复到默认的配置.
关闭保留策略:
RMAN> CONFIGURE RETENTION POLICY clear;
RMAN> CONFIGURE RETENTION POLICY TO NONE;
配置备份默认位置
RMNA> configure channel device type disk format '/u01/app/oracle/backup/rmanbk/%d_%s.dbf';
配置归档
1. 查看当前数据库的运行模式:
SQL> archive log list;
2. 修改数据库为归档模式:
SQL> shutdown immediate
SQL> start mount
SQL> alter database archivelog
SQL> alter system set log_archive_dest_1='location=/u01/app/oracle/archivelog'
SQL> alter database open
SQL> alter sysetm switch logfile [oracle@oracle ~]$ cd /u01/app/oracle/archivelog
[oracle@oracle ~]$ ls
创建多个归档位置:
1. 创建本地和远程的归档位置:
创建本地的:alter sysem set log_archive_dest_1='location='
创建远程的:alter system set log_archive_dest_2='service='
2. 仅创建本地的归档位置:
SQL> alter system set log_archive_dest='location='
SQL> alter system set log_archive_duplex_dest='location='
oracle推荐使用log_archive_dest_n参数来设置本地和远程的位置
可以指定参数来确保归档成功的最少位置:
SQL> alter system set LOG_ARCHIVE_MIN_SUCCEED_DEST = 2;
配置快速恢复区
1. 定义快速闪回区
1). 首先定义快速闪回区的大小:alter system set DB_RECOVERY_FILE_DEST_SIZE=
2). 定义快速闪回区的位置:alter system set DB_RECOVERY_FILE_DEST
2. 快速闪回区的空间管理
1). 在备份的时候删除:
RMAN> backup archivelog all delete input;-----只会删除log_archive_dest_1参数指定位置的归档
RMAN> backup archivelog all delete all input; ------删除所有位置的归档
2). 如果手动的在操作系统下删除归档,删除之后使用以下命令与rman进行同步:
RMAN> crosscheck archivelog all;
3. 使用oem对快速闪回区进行监视:
home -> Related Links -> All Metrics -> Fast Recovery -> RECOVERY AREA
--------------------------------------------------------------------------------------
介质错误:
磁盘坏
磁盘控制器损坏
数据文件损坏
用户错误:
基于时间点的不完全恢复
应用程序错误:
闪回
备份集备份:
10G -- 使用了8G,仅备份使用了的8G
备份快,恢复慢
镜像备份则备份全部的10G
备份慢,恢复快 -- 备份切换
rman help=y
本地连接:rman target /
远程连接: rman target sys/oracle@orcl
run{
delete noprompt backup;
backup database;
}
tail -f alert_orcl.log
rman
show all -- 查看配置
使用快速恢复区
永久项:
Multiplexed copies of the current control file
Multiplexed copies of online redo logs
临时项:
Archived redo logs
Data file copies
Control file copies
Control file autobackups
Backup pieces
Flashback logs