某某业务数据库RMAN备份实例记录

某某业务数据库RMAN备份实例


1、设置业务数据库日志文件

1.1 修改日志文件
根据本次业务需求,增加一组日志文件,增加成员数为2
日志文件大小修改只能新建后,删除原有旧的文件。


查询在线日志
SQL>select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE  MEMBERS ARC STATUS       FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
1    1     151   52428800   512 1 NO  INACTIVE   168638269 12-JAN-16  168649896 12-JAN-16
2    1     152   52428800   512 1 NO  CURRENT   168649896 12-JAN-16 2.8147E+14
3    1     150   52428800   512 1 NO  INACTIVE   168626218 12-JAN-16  168638269 12-JAN-16


查询日志文件信息
SQL>select * from v$logfile;
    GROUP# STATUS  TYPE    MEMBER            IS_
---------- ------- ------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---
3   ONLINE  /opt/oracle/oradata/orcl/redo03.log            NO
2   ONLINE  /opt/oracle/oradata/orcl/redo02.log            NO
1   ONLINE  /opt/oracle/oradata/orcl/redo01.log            NO


增加文件组4,2个成员
SQL> alter database add logfile group 4 ('/opt/oracle/oradata/orcl/redo41.log','/opt/oradata/orcl/redo42.log') size 256m;


查询日志状态

{CSDN:CODE:

SQL>select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE  MEMBERS ARC STATUS       FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
1    1     151   52428800   512 1 NO  INACTIVE   168638269 12-JAN-16  168649896 12-JAN-16
2    1     152   52428800   512 1 NO  CURRENT   168649896 12-JAN-16 2.8147E+14
3    1     150   52428800   512 1 NO  INACTIVE   168626218 12-JAN-16  168638269 12-JAN-16

}

删除日志组 1 和 3
SQL> alter database drop logfile group 1;
Database altered.


SQL> alter database drop logfile group 3;
Database altered.


注意:Current、Active组不得删除,数据库只有两个组是不得删除,先逻辑删除、后物理删除


增加日志组 1 和 3
SQL> alter database add logfile group 1 ('/opt/oracle/oradata/orcl/redo11.log','/opt/oradata/orcl/redo12.log') size 256m;
Database altered.


SQL> alter database add logfile group 3 ('/opt/oracle/oradata/orcl/redo31.log','/opt/oradata/orcl/redo32.log') size 256m;
Database altered.


查询日志文件信息

{CSDN:CODE:

SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE  MEMBERS ARC STATUS       FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
1    1       0  268435456   512 2 YES UNUSED   0  0
2    1     152   52428800   512 1 NO  CURRENT   168649896 12-JAN-16 2.8147E+14
3    1       0  268435456   512 2 YES UNUSED   0  0
4    1       0  268435456   512 2 YES UNUSED   0  0
}

切换日志组


SQL> alter system switch logfile;
System altered.


SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE  MEMBERS ARC STATUS       FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
1    1     153  268435456   512 2 NO  CURRENT   168655441 12-JAN-16 2.8147E+14
2    1     152   52428800   512 1 NO  ACTIVE   168649896 12-JAN-16  168655441 12-JAN-16
3    1       0  268435456   512 2 YES UNUSED   0  0
4    1       0  268435456   512 2 YES UNUSED   0  0


第二组为ACTIVE组态,强制产生检查点命令
SQL> alter system checkpoint;
System altered.


SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE  MEMBERS ARC STATUS       FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
1    1     153  268435456   512 2 NO  CURRENT   168655441 12-JAN-16 2.8147E+14
2    1     152   52428800   512 1 NO  INACTIVE   168649896 12-JAN-16  168655441 12-JAN-16
3    1       0  268435456   512 2 YES UNUSED   0  0
4    1       0  268435456   512 2 YES UNUSED   0  0

删除日志组 2 
SQL> alter database drop logfile group 2;
Database altered.
增加日志组 2
SQL> alter database add logfile group 2 ('/opt/oracle/oradata/orcl/redo21.log','/opt/oradata/orcl/redo22.log') size 256m;
Database altered.

查询日志组组态
SQL> select * from V$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE  MEMBERS ARC STATUS       FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
1    1     153  268435456   512 2 NO  CURRENT   168655441 12-JAN-16 2.8147E+14
2    1       0  268435456   512 2 YES UNUSED   0  0
3    1       0  268435456   512 2 YES UNUSED   0  0
4    1       0  268435456   512 2 YES UNUSED   0  0

从磁盘删除以前日志物理文件
$cd /opt/oracle/oradata/orcl/
$rm redo0*.log


2、设置业务数据库归档模式


2.1查询数据库归档模式:
SQL>select log_mode from v$database;
SQL>archive log list (sys用户)


2.2查询参数文件使用方式(spfile)
SQL>show parameter spfile


2.3在spfile工作模式下,设置归档存储路径
SQL> alter system set log_archive_dest_1='location=/opt/oracle/oradata/archive1';
System altered.
SQL> alter system set log_archive_dest_2='location=/opt/oracle/oradata/archive2';
System altered.


设置归档文件存储格式
需要注意,在Oracle 11g中,配置归档日志文件格式时,必须带有%s,%t和%r匹配符
SQL> alter system set log_archive_format='%s_%t_%r.arc' scope=spfile;
System altered.


2.4修改数据库归档模式
SQL>shutdown immediate
SQL>startup mount
SQL>alter database ARCHIVELOG;
SQL>alter database open;


2.5查询归档模式
SQL>select log_mode from v$database;
SQL>archive log list


2.6查询归档存储路径
SQL> show parameter log_archive_dest




3、创建RMAN数据库
创建表空间
SQL>create tablespace rmanspace datafile '/opt/oracle/oradata/orcl/rman01.dbf' size 100m autoextend on next 100m maxsize 8g;
创建用户
SQL>create user rman identified by Zcps_123 default tablespace qhtitle temporary tablespace temp;

更改表空间
SQL>alter user rman default tablespace rmanspace;


授权
SQL>grant connect,resource ,recovery_catalog_owner to rman ;


将密码有效期由默认的180天修改成“无限制”
SQL>ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED; 


4、在业务数据库服务器上关联RMAN数据库

#创建恢复目录
$rman catalog rman/Zcps_123@rmanbackup 
RMAN>create catalog;

#连接目标数据库(以后每次都要做,用户必须为sys)
$rman TARGET sys/Qhrsc123 CATALOG rman/Zcps_123@rmanbackup 


#注册数据库  (目标控制文件写入rman目录)
RMAN>register database;
RMAN>report schema;


#设置数据保留策略
RMAN>CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 34 DAYS;
RMAN>CONFIGURE CONTROLFILE AUTOBACKUP ON;
RMAN>CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/opt/zcps_backup/hot_backup/autoctl_%F';


5、数据库备份脚本,见http://blog.csdn.net/upcorange/article/details/7335990



你可能感兴趣的:(某某业务数据库RMAN备份实例记录)