主动维护
数据字典中的信息和表中的信息,是不一样的,所以要统计信息和收集信息。
statistics_level:
basic手动收集统计信息
type自动收集统计信息(默认)
all自动收集统计信息
AWR(automatic workload repository)
SGA->MMON->AWR(SYS SCHEMA),默认收集时间是60分钟一次记录数据库度量快照,保留期为7天。
MMON在SGA中收集统计信息放入AWR里。
ADDM(automatic database diagnostic monitor)
在记录每个AWR快照之后运行,监视实例:检测瓶颈,在AWR存储结果
DBMS_ADVISOR程序包
DBA_OUTSTANDING_ALERTS DBA_ALERT_HISTORY
自动维护任务
ASMM(automatic shared momery management)
v$sysstat v$sesstat v$service_stats v$system_event v$session_event v$service_event
v$session、v$sql (sql_id)
备份与恢复
语句错误、用户进程错误、网络故障、用户错误、实例错误、介质故障
redo logfile 5-8个group
%t_%s_%r.dbf
archive log list;
select log_mode from v$database;
select archiver from v$instance;
fast_start_mttr_target
rman target / nocatalog
RMAN> backup database;
Starting backup at 16-JAN-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=144 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00006 name=/home/oracle/oradata/orcl/test.dbf
input datafile fno=00001 name=/home/oracle/oradata/orcl/system01.dbf
input datafile fno=00002 name=/home/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00003 name=/home/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/home/oracle/oradata/orcl/example01.dbf
input datafile fno=00004 name=/home/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 16-JAN-11
channel ORA_DISK_1: finished piece 1 at 16-JAN-11
piece handle=/home/oracle/flash_recovery_area/ORCL/backupset/2011_01_16/o1_mf_nnndf_TAG20110116T142418_6m53rllk_.bkp tag=TAG20110116T142418 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 16-JAN-11
channel ORA_DISK_1: finished piece 1 at 16-JAN-11
piece handle=/home/oracle/flash_recovery_area/ORCL/backupset/2011_01_16/o1_mf_ncsnf_TAG20110116T142418_6m53tfl8_.bkp tag=TAG20110116T142418 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:05
Finished backup at 16-JAN-11
控制文件全丢,只有备份,如何恢复?(做实验)
丢失一个控制文件 时,需要拷贝最新的控制文件。
redo logfile
redo logfile 组中丢失一个member的恢复方法。
方法一、select group#,status from v$log;
alter system switch logfile; --一直切换到status等于inactive再拷贝另一个成员到相应的位置
方法二(推荐使用这种)、直接删除这个 成员,再重新创建一个member
丢失非系统datafile恢复
sqlplus: alter database datafile 4 offline;
rman:
restore datafile 4;
recover datafile 4;
sqlplus: alter datafile 4 online;
丢失系统datafile recovery
sqlplus: shutdown abort;
rman:
startup mount;
restore datafile 1;
recover database;
sqlplus: alter database open;
闪回技术(做实验)
闪回数据库: 闪回日志
闪回表: 闪回删除表(recyclebin)、闪回查询(还原数据)
transaction: 闪回事务(还原数据)
闪回数据库后,需要使用aler database open read only |[resetlogs];限制:还原了controlfile、删除了表空间、收缩了数据文件,不能闪回。
闪回表:条件:undo data exists ,enable row movement,flashback table privileges.
限制:有DML互斥锁,不闪回统计信息,保留当前索引和相关对象,会写入预警日志文件 ,会生成redo和undo data.
闪回删除:flashback table t to before drop;限制:
闪回查询:闪回查询、闪回版本查询、闪回事务
select * from …… as of timestamp to_timestamp(……) where …… --某个时间点
select version_id,* from …… versions between timestamp t1 and t2 where …… --一个时间段
flashback_transaction_query
闪回事务:对DDL没什么用
select * from emp as of timestamp sysdate-1/1440 ; --闪回查询
select versions_starttime,versions_endtime,empno from emp versions between timestamp sysdate-1/1440 and sysdate-30/1440 ; --闪回版本查询
flashback table emp to timestamp|SCN sysdate-15/1440; --闪回表,闪回15分之前。注意,以前的数据都没有了并且之前要enable row movement[@more@]
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/16298743/viewspace-1044737/
,如需转载,请注明出处,否则将追究法律责任。