分类: Oracle
2010-12-22 13:28:47
1、打开和关闭数据库:
基础知识回顾:
Oracle的启动过程分为三个阶段:
① 启动数据库实例:读取定义启动参数的文件、分配SGA区、启动后台进程
② 加载数据库文件:读取参数文件指定的控制文件、将数据库文件与已启动实例关联
③ 打开数据库:打开联机数据文件、日志文件
数据库启动可分为:
① startup:正常方式启动实例、加载数据库文件、打开数据库
② startup force:强制打开数据库
③ startup mount:只启动实例,不打开数据库(用于切换模式、恢复数据等)
④ alter database open:startup mount后打开数据库
数据库关闭可分为:
① shutdown normal:正常关闭,必须等所有用户退出后才关闭
② shutdown immediate:立即关闭,所有正在处理的事务回退
③ shutdown abort:异常关闭,马上关闭数据库,但不对事务进行处理
由于备份一般需要在关闭数据库的情况下操作,所以RMAN具有直接打开和关闭数据库的功能。
所有操作指令与sqlplus下的命令完全相同。
2、常用命令
① 要使用操作系统命令:
RMAN> host;
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp. C:\Documents and Settings\wangxiaoqi>
与SqlPlus中不同的是,RMAN中host后面必须加“;”
② 使用SQL命令:
RMAN> SQL 'ALTER SYSTEM ARCHIVE LOG ALL';
但是使用SQL命令的限制比较多,主要是针对数据库级的操作,很多的SQL语句都是无法使用的
因此最好的方法是:
RMAN> host;
Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp. C:\Documents and Settings\wangxiaoqi>sqlplus wangxiaoqi/wangxiaoqi
SQL*Plus: Release 9.2.0.1.0 - Production on Thu Sep 18 14:30:03 2008
Copyright (c) 1982, 2002, Oracle Corporation.
Connected to: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production With the Partitioning, OLAP and Oracle Data Mining options JServer Release 9.2.0.1.0 - Production SQL>
3、 首先列出所有指标:
RMAN> show all;
using target database controlfile instead of recovery catalog
RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE MAXSETSIZE TO UNLIMITED; # default CONFIGURE SNAPSHOT CONTROLFILE NAME TO 'D:\ORACLE\ORA92\DATABASE\SNCFDODO.ORA';# default 4、 配置自动通道数:
RMAN> show device type;
RMAN configuration parameters are:
CONFIGURE DEVICE TYPE DISK PARALLELISM 1; # default RMAN> configure device type disk parallelism 2; new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2; new RMAN configuration parameters are successfully stored starting full resync of recovery catalog full resync complete RMAN>
RMAN configuration parameters are:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2; 若要清除对通道数的设置:
RMAN> configure device type disk clear;
old RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK PARALLELISM 2; RMAN configuration parameters are successfully reset to default value starting full resync of recovery catalog full resync complete 5、制定自动通道默认设备:
RMAN> show default device type;
RMAN configuration parameters are:
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default RMAN> configure default device type to sbt; --磁带备份
new RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE'; new RMAN configuration parameters are successfully stored starting full resync of recovery catalog full resync complete RMAN> configure default device type clear;
old RMAN configuration parameters:
CONFIGURE DEFAULT DEVICE TYPE TO 'SBT_TAPE'; RMAN configuration parameters are successfully reset to default value starting full resync of recovery catalog full resync complete 6、配置磁盘:
RMAN> show channel;
RMAN configuration parameters are:
RMAN configuration has no stored or default parameters RMAN> configure channel device type disk format 'D:\oracle\oradata\dodo\rmanback\ora_%t_%s_%p';
new RMAN configuration parameters:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT new RMAN configuration parameters are successfully stored starting full resync of recovery catalog full resync complete RMAN>
new RMAN configuration parameters:
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT new RMAN configuration parameters are successfully stored starting full resync of recovery catalog full resync complete RMAN> show channel;
RMAN configuration parameters are:
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT 注:%t代替时间戳;%s代替备份组号;%p代替备份片号
取消:
RMAN> configure channel 2 device type disk clear;
old RMAN configuration parameters:
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT old RMAN configuration parameters are successfully deleted starting full resync of recovery catalog full resync complete 7、控制文件配置:
启动控制文件的自动备份:
RMAN> configure controlfile autobackup on;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON; new RMAN configuration parameters are successfully stored starting full resync of recovery catalog full resync complete RMAN> show controlfile autobackup;
RMAN configuration parameters are:
CONFIGURE CONTROLFILE AUTOBACKUP ON; 设置控制文件、服务器参数文件备份文件格式路径:
RMAN> configure controlfile autobackup format for device type disk to 'D:\oracle
\oradata\dodo\rmanback\ctl_%F'; new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO 'D:\oracle\orada ta\dodo\rmanback\ctl_%F'; new RMAN configuration parameters are successfully stored starting full resync of recovery catalog full resync complete 8、保存策略:
保存策略分两种
时间策略:决定至少有一个备份能恢复到指定的日期
RMAN> configure retention policy to recovery window of 3 days;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS; new RMAN configuration parameters are successfully stored starting full resync of recovery catalog full resync complete 注:保证至少有一个备份能恢复到3天前的时间点上,之前备份标注为obsolete
冗余策略:决定至少有几个冗余的备份:
RMAN> configure retention policy to redundancy 3;
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 3 DAYS; new RMAN configuration parameters: CONFIGURE RETENTION POLICY TO REDUNDANCY 3; new RMAN configuration parameters are successfully stored starting full resync of recovery catalog full resync complete 注:至少需要有3个冗余备份,若多于3个,则以前备份标记为obsolete
RMAN> show retention policy
RMAN configuration parameters are: CONFIGURE RETENTION POLICY TO REDUNDANCY 3; |