RAC基本备份恢复(二)

RAC基本备份恢复(二)

一、RAC中RMAN备份脚本

 

1、  归档日志在本地的scripts

run{

ALLOCATECHANNEL d1 TYPE disk connect 'sys/oracle@racdb1';

ALLOCATECHANNEL d2 TYPE disk connect 'sys/oracle@racdb2';

backupas compressed backupset incremental level 0 database filesperset 4 format

'/rman/backup/data/level0_%d_%s_%p_%u_%T.bak'include current controlfile;

sql'alter system archive log current';

backuparchivelog all filesperset 10 format'/rman/backup/arch/arc_%d_%s_%p_%u_%T.bak';

releasechannel d1;

releasechannel d2;}

2、  归档日志在ASM的scripts

run{

backupas compressed backupset incremental level 0 database filesperset 4 format

'/rman/backup/data/level0_%d_%s_%p_%u_%T.bak'include current controlfile;

sql'alter system archive log current';

backuparchivelog all filesperset 10 format'/rman/backup/arch/arc_%d_%s_%p_%u_%T.bak';

releasechannel d1;}

 

二、恢复时,单实例进行恢复

1、归档日志在本地的:把备份集和归档日志copy到单实例机器进行统一恢复

2、归档日志在ASM的:直接恢复即可

 

 

RAC中RMAN备份脚本(指定双节点)

run{

ALLOCATE CHANNEL d1 TYPE disk connect 'sys/oracle@racdb1';

ALLOCATE CHANNEL d2 TYPE disk connect 'sys/oracle@racdb2';

backup as compressed backupset incremental level 0 database filesperset 4 format

'/rman/backup/data/level0_%d_%s_%p_%u_%T.bak' include current controlfile;

sql 'alter system archive log current';

backup archivelog all filesperset 10 format '/rman/backup/arch/arc_%d_%s_%p_%u_%T.bak';

release channel d1;

release channel d2;}

 

附表

11gr2RAC tnsnames.ora配置如下

节点1

[oracle@dou_rac1 admin]$ cat tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

RACDB =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dou_rac-scan)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = racdb)

    )

  )

节点2

[oracle@dou_rac2 admin]$ cat tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

RACDB =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = dou_rac-scan)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = racdb)

    )

  )

 

一、 添加tnsnames.ora(为了方便RMAN配置,需要在tnsnames.ora中添加racdb1,racdb2)

双节点均需添加

RACDB1 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.217)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = racdb)

    )

  )

RACDB2 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.220)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = racdb)

    )

  )

 

 

归档日志均放在节点本地目录

节点1

sys@RACDB> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /rman/arch

Oldest online log sequence     12

Next log sequence to archive   13

Current log sequence           13

节点2

sys@RACDB> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /rman/arch

Oldest online log sequence     11

Next log sequence to archive   12

Current log sequence           12

 

 

Rman备份详细过程

RMAN> run{

2> ALLOCATE CHANNEL d1 TYPE disk connect 'sys/oracle@racdb1';

3> ALLOCATE CHANNEL d2 TYPE disk connect 'sys/oracle@racdb2';

4> backup as compressed backupset incremental level 0 database filesperset 4 format

5> '/rman/backup/data/level0_%d_%s_%p_%u_%T.bak' include current controlfile;

6> sql 'alter system archive log current';

7> backup archivelog all filesperset 10 format '/rman/backup/arch/arc_%d_%s_%p_%u_%T.bak';

8> release channel d1;

9> release channel d2;}

 

allocated channel: d1

channel d1: SID=33 instance=racdb1 device type=DISK          --分配双通道(d1通道)

 

allocated channel: d2

channel d2: SID=32 instance=racdb2 device type=DISK          --分配双通道(d2通道)

 

Starting backup at 2013-07-23 09:12:23                       --备份开始时间

channel d1: starting compressed incremental level 0 datafile backup set  --0级压缩备份

channel d1: specifying datafile(s) in backup set

input datafile file number=00001 name=+DATA/racdb/datafile/system.256.821458313

input datafile file number=00005 name=+DATA/racdb/datafile/undotbs2.264.821458799

input datafile file number=00004 name=+DATA/racdb/datafile/users.259.821458317

channel d1: starting piece 1 at 2013-07-23 09:12:24

channel d2: starting compressed incremental level 0 datafile backup set

channel d2: specifying datafile(s) in backup set

input datafile file number=00002 name=+DATA/racdb/datafile/sysaux.257.821458317

input datafile file number=00003 name=+DATA/racdb/datafile/undotbs1.258.821458317

input datafile file number=00006 name=+DATA/racdb/datafile/doudou.268.821465747

channel d2: starting piece 1 at 2013-07-23 09:12:17

channel d2: finished piece 1 at 2013-07-23 09:12:54

piece handle=/rman/backup/data/level0_RACDB_26_1_0qofetrh_20130723.bak tag=TAG20130723T091223 comment=NONE                --生成备份集的名称和标记

channel d2: backup set complete, elapsed time: 00:00:37      --备份集完成时间

channel d2: starting compressed incremental level 0 datafile backup set

channel d2: specifying datafile(s) in backup set

including current control file in backup set                     --备份当前控制文件

channel d2: starting piece 1 at 2013-07-23 09:12:58

channel d2: finished piece 1 at 2013-07-23 09:12:59

piece handle=/rman/backup/data/level0_RACDB_27_1_0rofetsn_20130723.bak tag=TAG20130723T091223 comment=NONE           --当前控制文件备份集名称和标记

channel d2: backup set complete, elapsed time: 00:00:01      --控制文件备份完成时间

channel d2: starting compressed incremental level 0 datafile backup set

channel d2: specifying datafile(s) in backup set

including current SPFILE in backup set                           --备份当前参数文件

channel d2: starting piece 1 at 2013-07-23 09:13:00

channel d2: finished piece 1 at 2013-07-23 09:13:01

piece handle=/rman/backup/data/level0_RACDB_28_1_0sofetss_20130723.bak tag=TAG20130723T091223 comment=NONE

channel d2: backup set complete, elapsed time: 00:00:01

channel d1: finished piece 1 at 2013-07-23 09:13:22

piece handle=/rman/backup/data/level0_RACDB_25_1_0pofetro_20130723.bak tag=TAG20130723T091223 comment=NONE

channel d1: backup set complete, elapsed time: 00:00:58

Finished backup at 2013-07-23 09:13:22

 

sql statement: alter system archive log current

 

Starting backup at 2013-07-23 09:13:27

current log archived

channel d1: starting archived log backup set                     --通道d1开始备份归档日志

channel d1: specifying archived log(s) in backup set

input archived log thread=1 sequence=8 RECID=9 STAMP=821515041   --节点1

input archived log thread=1 sequence=9 RECID=10 STAMP=821515044

input archived log thread=1 sequence=10 RECID=14 STAMP=821521768

channel d1: starting piece 1 at 2013-07-23 09:13:33

channel d2: starting archived log backup set                     --通道d2开始备份归档日志

channel d2: specifying archived log(s) in backup set

input archived log thread=2 sequence=8 RECID=12 STAMP=821521724  --节点2

input archived log thread=2 sequence=9 RECID=13 STAMP=821521761

input archived log thread=2 sequence=10 RECID=16 STAMP=821521859

channel d2: starting piece 1 at 2013-07-23 09:13:27

channel d1: finished piece 1 at 2013-07-23 09:13:35

piece handle=/rman/backup/arch/arc_RACDB_29_1_0tofettt_20130723.bak tag=TAG20130723T091333 comment=NONE                --归档日志备份集和标识

channel d1: backup set complete, elapsed time: 00:00:02

channel d1: starting archived log backup set

channel d1: specifying archived log(s) in backup set

input archived log thread=1 sequence=11 RECID=15 STAMP=821521865

input archived log thread=1 sequence=12 RECID=18 STAMP=821521871

channel d1: starting piece 1 at 2013-07-23 09:13:35

channel d2: finished piece 1 at 2013-07-23 09:13:29

piece handle=/rman/backup/arch/arc_RACDB_30_1_0uofettm_20130723.bak tag=TAG20130723T091333 comment=NONE

channel d2: backup set complete, elapsed time: 00:00:02

channel d2: starting archived log backup set

channel d2: specifying archived log(s) in backup set

input archived log thread=2 sequence=11 RECID=17 STAMP=821521862

input archived log thread=2 sequence=12 RECID=20 STAMP=821524398

channel d2: starting piece 1 at 2013-07-23 09:13:29

channel d1: finished piece 1 at 2013-07-23 09:13:35

piece handle=/rman/backup/arch/arc_RACDB_31_1_0vofettv_20130723.bak tag=TAG20130723T091333 comment=NONE

channel d1: backup set complete, elapsed time: 00:00:00

channel d1: starting archived log backup set

channel d1: specifying archived log(s) in backup set

input archived log thread=1 sequence=13 RECID=19 STAMP=821524403

input archived log thread=1 sequence=14 RECID=22 STAMP=821524410

channel d1: starting piece 1 at 2013-07-23 09:13:36

channel d2: finished piece 1 at 2013-07-23 09:13:29

piece handle=/rman/backup/arch/arc_RACDB_32_1_10ofettp_20130723.bak tag=TAG20130723T091333 comment=NONE

channel d2: backup set complete, elapsed time: 00:00:00

channel d2: starting archived log backup set

channel d2: specifying archived log(s) in backup set

input archived log thread=2 sequence=13 RECID=21 STAMP=821524401

channel d2: starting piece 1 at 2013-07-23 09:13:29

channel d1: finished piece 1 at 2013-07-23 09:13:36

piece handle=/rman/backup/arch/arc_RACDB_33_1_11ofetu0_20130723.bak tag=TAG20130723T091333 comment=NONE

channel d1: backup set complete, elapsed time: 00:00:00

channel d2: finished piece 1 at 2013-07-23 09:13:30

piece handle=/rman/backup/arch/arc_RACDB_34_1_12ofettp_20130723.bak tag=TAG20130723T091333 comment=NONE

channel d2: backup set complete, elapsed time: 00:00:01

Finished backup at 2013-07-23 09:13:37

released channel: d1

released channel: d2

 

 

 

 

RMAN通道与备份集生成的位置

总结:

RMAN使用2个通道(d1,d2)进行备份:

使用d1时(channel d1:)备份集就会生成在节点1上。

使用d2时(channel d2:)备份集就会生成在节点2上。

实验说明:

piece handle=/rman/backup/arch/arc_RACDB_33_1_11ofetu0_20130723.bak tag=TAG20130723T091333 comment=NONE

channel d1: backup set complete, elapsed time: 00:00:00

piece handle=/rman/backup/arch/arc_RACDB_34_1_12ofettp_20130723.bak tag=TAG20130723T091333 comment=NONE

channel d2: backup set complete, elapsed time: 00:00:01

节点1

channel d1

[oracle@dou_rac1 arch]$ ls -l arc_RACDB_33_1_11ofetu0_20130723.bak

-rw-r----- 1 oracle oinstall 1847808 07-23 09:13 arc_RACDB_33_1_11ofetu0_20130723.bak

节点2

channel d2

[oracle@dou_rac2 arch]$ ls -l arc_RACDB_34_1_12ofettp_20130723.bak

-rw-r----- 1 oracle asmadmin 2560 07-23 09:13 arc_RACDB_34_1_12ofettp_20130723.bak

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值