《备份和恢复概要》由会员分享,可在线阅读,更多相关《备份和恢复概要(7页珍藏版)》请在金锄头文库上搜索。
1、一、备份和恢复概要一、备份和恢复概要 1、高可用性(1)HA(High Availability,HA)(2)RAC(Real Application Clusters)(3)DG(Data Guard)(4)Oracle Replication(5)RAID 和镜像驱动器 2、备份和恢复。(1)收集备份与恢复策略需求(2)精心设计备份与恢复计划二、二、Oracle 备份备份 1、ORACLE 各种备份(1)类型物理备份逻辑备份(2)数据库状态联机备份(热)和脱机备份(冷)不一致性备份和一致性备份(3)备份规模完全备份:归档模式、非模式模式表空间备份数据文件备份控制文件备份归档日志文件备份三三
2、 、ORACLE 恢复恢复(1)错误的类型用户误操作导致错误系统进程导致的错误实例导致错误存储介质导致错误(2)恢复类型实例恢复:1 缓存恢复(前滚),2 事务恢复(后滚)介质恢复(数据文件或数据块)(3)恢复方式完全恢复不完全恢复(4)恢复操作restore -还原recover -恢复(5)resetlogs:alter database open resetlogs;incarnation:化身号四、常见备份与恢复技术四、常见备份与恢复技术(1)用户管理的备份和恢复(User-Managed Backupselect name from v$controlfile;-select mem
3、ber from v$logfile;-select name from v$tempfile;shutdown immediate;df -hlmkdir /backupchown -R oracle:oinstall /backupchmod -R 755 /backupsu - oraclecd /backupmkdir coldmkdir hotcd /backup/coldcp -rf /u01/app/oracle/oradata/ocp/* .startup(3)热备:SQL col file_name for a50;SQL select tablespace_name, fi
4、le_name from dba_data_files;SQL alter tablespace tp1 begin backup;SQL !cp /oradata/bxdb/user01.dbf /backup/SQL alter tablespace users end backup;SQL alter system switch logfile;-dd if=/u01/app/oracle/oradata/ocp/tp1.dbf skip=205 bs=8192 count=2|strings-alter system dump datafile block;*批量操作脚本:(v$bac
5、kup,dba_data_files,dba_tablespaces)selectalter tablespace |tablespace_name| begin backup; |chr(10)|host cp |file_name| /backup |chr(10)|alter tablespace |tablespace_name| end backup;from dba_data_files order by tablespace_name;beginfor i in 1 . 10000 loopinsert into t1 values(i,gyj|i);commit;end loo
6、p;end;/(4)控制文件备份:alter database backup controlfile to /backup/control.bin;alter database backup controlfile to trace as /backup/control.ctl;(5)初始化文件备份:create pfile=/backup/pfile.ora from spfile;(6)口令文件备份:orapwd file=$ORACLE_HOME/dbs/orapw password=oracle;六、六、RMAN 配置与备份配置与备份 1.RMAN 连接(1)连接本地数据库rman t
7、arget /(2)连接远程数据库rman sys/oraclebxdb(3)辅助连接rman target sys/oracleocp auxiliary sys/oracleocmduplicate target database for standby dorecover nofilenamecheck;(4)连接恢复目录(ppt-les_03_catalog)create tablespace rc_data datafile /u01/app/oracle/oradata/ocp/rc_data01.dbf size 100m;create user rc_admin identif
8、ied by rc_admin default tablespace rc_data quota unlimited on rc_data;grant connect,resource,recovery_catalog_owner to rc_admin;rman catalog rc_admin/rc_admincreate catalog tablespace rc_data;exitrman target / catalog rc_admin/rc_adminregister database; *虚拟专用目录:create user v_user1 identified by v_us
9、er1 default tablespace tp1 temporary tablespace temp quota unlimited on tp1;grant recovery_catalog_owner to v_user1;oracleocm $ rman catalog rc_admin/rc_admingrant catalog for database ocm to v_user1;oracleocm $ rman catalog v_user1/v_user1create virtual catalog;(5)退出 rmanexit2.RMAN 基本操作(1)启动关闭数据库rm
10、an target /shutdown immeidatestartup(2)执行 sql 语句sql alter system checkpoint;sql“create tablespace tp3 datafile /u01/app/oracle/oradata/ocp/tp3.dbf size 10M“;(3) RMAN 备份类型镜像复制(Image Copies)备份集(Backup sets) (4)RMAN 命令执行方式单个命令 backup database;批处理 run . ;运行脚本*命令行方式调用操作系统中保存的脚本rman target / script.rman (
11、或 cmdfile=script.rman)*在 rman 中执行操作系统保存的脚本文件scrip.rman*运行储储在 CATALOG 中的脚本(需要首先为 RMAN 创建恢复目录)create script full_dbbackup format=/back/rman/full_%Udatabase include current controlfileplus archivelog;sql alter system archive log current;runexecute script full_db;rman target sys/oracleoca catalog rc_adm
12、in/rc_adminoca script full_dblist script names;print script full_db;replace script full_dbbackup format=/backup/rman/full_%Udatabase;delete script full_db;resync catalog;unregister database;upgrade catalog;drop catalog;-查恢复目录 sqlplus rc_admin/rc_adminselect dbid,name,resetlogs_change# from rc_databa
13、se;select ts#,name,creation_change# from rc_tablespace;select file#,name,bytes from rc_datafile;select script_name from rc_stored_script;select line,text from rc_stored_script_line;3. RMAN 备份 (1)备份数据库backup database;backup database format /backup/rman_full_%U;list backup of database;(2)备份一个数据文件repor
14、t schemaselect file#,name from v$datafile; backup datafile 4 format /backup/md_%U;list backup of datafile 4;(3)备份表空间select tablespace_name,contents from dba_tablespaces;backup tablespace trans format /backup/trans_%U;list backup of tablespace trans;(4)备份控件文件(4 种方法)自动备份:configure controlfile autoback
15、up on;backup current controlfile;backup datafile 4 include current controlfile;sql “alter database backup controlfile to /backup/control/back_controlfile.bin“;list backup of controlfile;(5)备份参数文件(2 种方法)自动备份:configure controlfile autobackup on;backup spfile format /backup/spfile.ora;(6)备份归档文件backup a
16、rchivelog all format /backup/arch_%U;backup archivelog sequence between 85 and 89 delete all input;backup archivelog from time “sysdate - 14“ until time “sysdate - 7 “;backup database plus archivelog format /back/rman/full_%U delete all input;list backup of archivelog all;(7)备份备份集backup backupset 1