Oracle rman定时备份数据库

来源:互联网 发布:易语言在线播放器源码 编辑:程序博客网 时间:2024/05/29 18:34
对一个测试人员使用的测试数据库做简单的RMAN定时备份,过程如下,比较粗糙,见谅:--1.查看数据库基本信息,是否归档,归档存放地址,快速恢复区大小等[oracle@sean ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Thu Jun 1 18:00:05 2017Copyright (c) 1982, 2013, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> archive log list   Database log mode              No Archive Mode  --未归档Automatic archival             DisabledArchive destination            USE_DB_RECOVERY_FILE_DEST  --归档地址为快速恢复区Oldest online log sequence     198Current log sequence           200SQL> show parameter recoveryNAME                                 TYPE        VALUE------------------------------------ ----------- ------------------------------db_recovery_file_dest                string      /u01/app/oracle/fast_recovery_area  --快速恢复区地址db_recovery_file_dest_size           big integer 4182M   --快速恢复区大小recovery_parallelism                 integer     0--2.开启归档模式SQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> startup mountORACLE instance started.Total System Global Area  496922624 bytesFixed Size                  2254504 bytesVariable Size             159385944 bytesDatabase Buffers          331350016 bytesRedo Buffers                3932160 bytesDatabase mounted.SQL> alter database archivelog;Database altered.SQL> alter database open;Database opened.--3.修改归档地址和快速恢复区大小(可选),本例子不修改地址,修改大小alter system set db_recovery_file_dest_size = 10g;--4.修改rman默认参数[oracle@sean ~]$ rman target /Recovery Manager: Release 11.2.0.4.0 - Production on Thu Jun 1 18:05:13 2017Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.connected to target database: SEAN (DBID=1642013397, not open)RMAN> show all;using target database control file instead of recovery catalogRMAN configuration parameters for database with db_unique_name SEAN are:CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # defaultCONFIGURE BACKUP OPTIMIZATION OFF; # defaultCONFIGURE DEFAULT DEVICE TYPE TO DISK;CONFIGURE CONTROLFILE AUTOBACKUP OFF;CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # defaultCONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # defaultCONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # defaultCONFIGURE MAXSETSIZE TO UNLIMITED; # defaultCONFIGURE ENCRYPTION FOR DATABASE OFF; # defaultCONFIGURE ENCRYPTION ALGORITHM 'AES128'; # defaultCONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # defaultCONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO 'SBT_TAPE';CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_sean.f'; # defaultRMAN> CONFIGURE BACKUP OPTIMIZATION ON;   --开启优化备份RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;  --开启控制文件自动备份RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2; --设置备份冗余数为2--5.编写rman备份脚本[oracle@localhost ~]$ cat backup_full_db.sh #!/bin/bash#set environment variablesORACLE_SID=orclORACLE_BASE=/u01/app/oracleORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1PATH=$PATH:$ORACLE_HOME/binexport ORACLE_SID ORACLE_BASE ORACLE_HOME PATHrman target / <<EOFrun{allocate channel c1 type disk;backup full tag 'dbfull_orcl' database;sql 'alter system archive log current';backup archivelog all delete input;release channel c1;crosscheck backup;crosscheck archivelog all;delete expired backup;delete expired archivelog all;delete noprompt obsolete;}EOF--5.1修改备份脚本文件执行权限chmod 755 backup_full_db.sh--6.设置crontab定时调度[oracle@localhost ~]$ cat /etc/crontabSHELL=/bin/bashPATH=/sbin:/bin:/usr/sbin:/usr/binMAILTO=rootHOME=/# For details see man 4 crontabs# Example of job definition:# .---------------- minute (0 - 59)# |  .------------- hour (0 - 23)# |  |  .---------- day of month (1 - 31)# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# |  |  |  |  |# *  *  *  *  * user-name command to be executed0 23 * * * oracle /home/oracle/backup_full_db.sh


原创粉丝点击