linux系统下用rman实现oracle数据库全备份和增量备份

1.用命令 echo $ORACLE_SID 查看当前默认的ORACLE_SID,如果不是要备份的SID,修改 export ORACLE_SID=PORTAL ,(PORTAL为要备份的数据库实例)。

2.以sysdba身份连接到数据库 sqlplus / as sysdba .

3.查看当前sid,确保备份实例正确: select instance from v$thread;

4.查看数据库的日志模式: select log_mode fromv$database;

   SQL>select log_mode from v$database;

   LOG_MODE
   ------------------------------------
   ARCHIVELOG

5.查看存档的目的地 archive log list
SQL> archive log list;

Database log mode Archive Mode
Automatic archival Enabled
Archive destination/export/db/oracle/oradata/ARCH
Oldest online log sequence 1265
Next log sequence to archive 1267
Current log sequence 1267
SQL>

如果要改变存档目的地 用 ALTER SYSTEM SET log_archive_dest_1='LOCATION=/export/db/oracle/oradata/ARCH';

6.停止数据库 shut immediate;

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>

7.在挂载状态下启动数据库 startup mount;

SQL> startup mount;
ORACLE instance started.

Total System Global Area 1031798784 bytes
Fixed Size 2089080 bytes
Variable Size 629149576 bytes
Database Buffers 394264576 bytes
Redo Buffers 6295552 bytes
Database mounted.
SQL>

8.启用归档日志 alter database archivelog;

SQL> alter databasearchivelog;

Database altered. 

9.启动数据库(此时数据库可用) alter databaseopen;

SQL> alter database open;

Database altered.

SQL> 

10.连接到rman:   host rman target /

SQL> host rman target/

Recovery Manager: Release 10.2.0.4.0 - Production on Fri Sep 28 15:46:40 2012

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

connected to target database: PORTAL (DBID=4144397491)

RMAN>

11.配置rman:

    RMAN>CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
    RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;
    RMAN> CONFIGURE BACKUP OPTIMIZATION ON;
    RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICETYPE DISK TO '/export/db/oracle/oradata/RMAN/cro_%F';

12.运行以下脚本全数据库备份级别0:

    RUN{
    ALLOCATE CHANNEL C1 TYPE DISK;
    ALLOCATE CHANNEL C2 TYPE DISK;
    ALLOCATE CHANNEL C3 TYPE DISK;
    BACKUP FILESPERSET 1 INCREMENTAL LEVEL 0 TAG 'LEV0' FORMAT'/export/db/oracle/oradata/RMAN/lev0%u_%s_%p'
    DATABASE SKIP INACCESSIBLE PLUS ARCHIVELOG FORMAT'/export/db/oracle/oradata/RMAN/arch%u_%s_%p' DELETE INPUT;
    RELEASE CHANNEL C1;
    RELEASE CHANNEL C2;
    RELEASE CHANNEL C3;
    DELETE NOPROMPT OBSOLETE;
    }

13.运行以下脚本增量累积数据库备份级别0:
    RUN{
    ALLOCATE CHANNEL C1 TYPE DISK;
    ALLOCATE CHANNEL C2 TYPE DISK;
    ALLOCATE CHANNEL C3 TYPE DISK;
    BACKUP FILESPERSET 1 INCREMENTAL LEVEL 1 CUMULATIVE TAG'LEV1' CUMULATIVE FORMAT '/export/db/oracle/oradata/RMAN/lev1%u_%s_%p'
    DATABASE SKIP INACCESSIBLE PLUS ARCHIVELOG FORMAT'/export/db/oracle/oradata/RMAN/arch%u_%s_%p' DELETE INPUT;
    RELEASE CHANNEL C1;
    RELEASE CHANNEL C2;
    RELEASE CHANNEL C3;
    DELETE NOPROMPT OBSOLETE;
    }

备份完毕。

你可能感兴趣的:(技术文章)