Oracle rman定时备份数据库

对一个测试人员使用的测试数据库做简单的RMAN定时备份,过程如下,比较粗糙,见谅:

--1.查看数据库基本信息,是否归档,归档存放地址,快速恢复区大小等

[oracle@sean ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Jun 1 18:00:05 2017

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> archive log list   
Database log mode              No Archive Mode  --未归档
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST  --归档地址为快速恢复区
Oldest online log sequence     198
Current log sequence           200
SQL> show parameter recovery

NAME                                 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 immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  496922624 bytes
Fixed Size                  2254504 bytes
Variable Size             159385944 bytes
Database Buffers          331350016 bytes
Redo Buffers                3932160 bytes
Database 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 2017

Copyright (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 catalog
RMAN configuration parameters for database with db_unique_name SEAN are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK;
CONFIGURE CONTROLFILE AUTOBACKUP OFF;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # 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 ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE 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'; # default

RMAN> 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 variables

ORACLE_SID=orcl
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID ORACLE_BASE ORACLE_HOME PATH

rman target / <<EOF

run{
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/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# 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 executed
0 23 * * * oracle /home/oracle/backup_full_db.sh


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值