设为首页 收藏本站
查看: 710|回复: 0

[经验分享] Oracle 学习笔记: Backup & Recovery 常用命令

[复制链接]

尚未签到

发表于 2016-7-22 07:58:39 | 显示全部楼层 |阅读模式
  1
. set database to archivelog mode

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area  251658240 bytes
Fixed Size                  1248356 bytes
Variable Size              83887004 bytes
Database Buffers          159383552 bytes
Redo Buffers                7139328 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     1319
Next log sequence to archive   1321
Current log sequence           1321

  
  2
. define flash recovery area

SQL> alter system set db_recovery_file_dest='D:\oracle\flash_recovery_area' scope=both;
System altered.
SQL> alter system set db_recovery_file_dest_size=15G scope=both;
System altered.
  
  Oracle will use Oracle Managed File (OMF) for the flash recovery area. The free space in recovery area can be checked using OEM: All Metrics -> Recovery Area, or query vflash_recovery_area_usage view. To get more free space, you can use the following command to backup and then delete all the archived log files.



RMAN> backup archivelog all delete all input; 
  
  3
. define multiple archived log destinations

SQL> alter system set log_archive_dest_1='location=use_db_recovery_file_dest' scope=both;
System altered.
SQL> alter system set log_archive_dest_2='location=D:\oracle\archivelog_area1' scope=both;
System altered.
  
  4
. CONTROL_FILE_RECORD_KEEP_TIME
  
  This parameter specify the minimum days the RMAN information is stored in the control file before overwritten. The default value is 7 days. When using catalog, a smaller value should be chosen.
  
  5
. starting RMAN

rman target /
rman target / nocatalog
rman target sys/change_on_install@orcl
rman target sys/change_on_install@orcl catalog rman/rman@catdb
rman target sys/change_on_install log=xxx.log append
rman target sys/change_on_install cmdfile=xxx.rcv
  
  6
. RMAN persistent settings
  
  6.1 display settings

RMAN> show all;
RMAN> show controlfile autobackup;
RMAN> show retention policy;
  
  6.2 configure settings

RMAN> configure retention policy to recovery window of 7 days;
RMAN> configure backup optimization on;
RMAN> configure default device type to disk;
RMAN> configure controlfile autobackup on;
RMAN> configure controlfile autobackup format for device type disk to '%F';
RMAN> configure device type disk backup type to compressed backupset parallelism 1;
RMAN> configure datafile backup copies for device type disk to 1;
RMAN> configure archivelog backup copies for device type disk to 1;
RMAN> configure channel device type disk maxpiecesize 1 G;
RMAN> configure maxsetsize to unlimited;
RMAN> configure encryption for database off;
RMAN> configure encryption algorithm 'AES128';
RMAN> configure archivelog deletion policy to none;
RMAN> configure snapshot controlfile name to 'D:\oracle\flash_recovery_area\sncfepcit.ora';
  
  If the control file autobackup is enabled, then RMAN automatically backs up the control file and spfile in one of two circumstances:

- A successful backup is recorded in the RMAN repository

- A structural change to the database affects the contents of the control file
  Control file autobackups are stored in the flash recovery area, unless otherwise specified.
  
  6.3 reset settings to default value

RMAN> configure controlfile autobackup clear;
RMAN> configure retention policy clear;
  
  7. RMAN commands
  
  7.1 backup commands

RMAN> backup database;
RMAN> backup copy of database;
RMAN> backup as compressed backupset database;
RMAN> backup as backupset format ''/BACKUP/df_%d_%s_%p.bus' tablespace users;
RMAN> backup database plus archivelog delete all input;
RMAN> backup archivelog from sequence=234 delete input;
RMAN> backup tag='month_full_backup' datafile 1, 2, 3, 4;
RMAN> backup incremental level 0 database;
RMAN> backup incremental level 1 database;
RMAN> backup incremental level 1 cumulative database;
RMAN> run {
2> allocate channel c1 device type sbt;
3> allocate channel c2 device type sbt;
4> allocate channel c3 device type sbt;
5> backup incremental level = 0
6> format '/disk1/backup/df_%d_%s_%p.bak'
7> (datafile 1,4,5 channel c1)
8> (datafile 2,3,9 channel c2)
9> (datafile 6,7,8 channel c3);
10> alter system archive log current;
11> }

  
  7.2 block change tracking

SQL> alter database enable block change tracking using file ''/mydir/rman_change_track.f' reuse;
SQL> alter database disable block change tracking;
  
  7.3 incrementally updating backups

RMAN> backup as copy incremental level 0 datafile 1 tag 'basecopy';
RMAN> backup incremental level 1 for recover of copy with tag 'basecopy' datafile 1;
RMAN> recover copy of datafile 1 with tag 'basecopy';
  
  7.4 list commands

RMAN> list backup of database summary;
RMAN> list backup of tablespace system summary;
RMAN> list backup of datafile {n|'file_name'} summary;
RMAN> list backup of database by {file|backup};
RMAN> list copy of database;

  
  7.5 report commands

RMAN> report schema;
RMAN> report need backup incremental 0 database;
RMAN> report need backup days 3;
RMAN> report need backup redundancy 2;
RMAN> report need backup recovery window of 3 days;
RMAN> report obsolete redundancy 2;
RMAN> report obsolete recovery window of 3 days;
  
  7.6 delete commands

RMAN> delete noprompt expired copy;
RMAN> delete noprompt expired backup;
RMAN> delete noprompt obsolete;
RMAN> delete obsolete redundancy 2;
RMAN> delete obsolete recovery window of 3 days;
RMAN> delete backupset 4;
  
  8. RMAN v$ views

V$ARCHIVED_LOG
V$BACKUP_CORRUPTION
V$BACKUP_DEVICE
V$BACKUP_FILES
V$BACKUP_PIECE
V$BACKUP_REDOLOG
V$BACKUP_SET
V$BACKUP_SPFILE
V$COPY_CORRUPTION
V$RMAN_CONFIGURATION

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-247544-1-1.html 上篇帖子: oracle JDBC PreparedStatement 内存释放BUG? 下篇帖子: Windows上安装Oracle 10G RAC
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表