linux rman备份表空间,RMAN备份表空间

本文详细介绍了如何使用RMAN在Oracle数据库中备份与恢复用户表空间users,涉及全量备份、通道分配、恢复操作和表空间恢复脚本。通过实际步骤展示了在数据文件丢失后,如何利用RMAN进行高效且可靠的恢复,包括关闭数据库、模拟丢失文件、恢复及验证数据完整性。
摘要由CSDN通过智能技术生成

2、 备份数据库表空间users

C:/>rman target=backup_admin/backupuserpassword nocatalog

Recovery Manager: Release 8.1.6.0.0 - Production

RMAN-06008: connected to recovery catalog database

RMAN> connect target internal/virpure

RMAN-06005: connected to target database: TEST (DBID=1788174720)

RMAN> run{

2> allocate channel c1 type disk;

3> backup tag 'tsuser' format 'd:/backup/tsuser_%u_%s_%p'

4> tablespace users;

5> release channel c1;

6> }

RMAN-03022: compiling command: allocate

RMAN-03023: executing command: allocate

RMAN-08030: allocated channel: c1

RMAN-08500: channel c1: sid=16 devtype=DISK

RMAN-03022: compiling command: backup

RMAN-03025: performing implicit partial resync of recovery catalog

RMAN-03023: executing command: partial resync

RMAN-08003: starting partial resync of recovery catalog

RMAN-08005: partial resync complete

RMAN-03023: executing command: backup

RMAN-08008: channel c1: starting full datafile backupset

RMAN-08502: set_count=5 set_stamp=494177612 creation_time=16-MAY-03

RMAN-08010: channel c1: specifying datafile(s) in backupset

RMAN-08522: input datafile fno=00003 name=D:/Oracle/ORADATA/TEST/USER01.DBF

RMAN-08013: channel c1: piece 1 created

RMAN-08503: piece handle=D:/BACKUP/TSUSER_05EN93AC_5_1 comment=NONE

RMAN-08525: backup set complete, elapsed time: 00:00:01

RMAN-03023: executing command: partial resync

RMAN-08003: starting partial resync of recovery catalog

RMAN-08005: partial resync complete

RMAN-03022: compiling command: release

RMAN-03023: executing command: release

RMAN-08031: released channel: c1

RMAN>

3、 继续在测试表中插入记录

SQL> insert into test values(2);

1 row inserted

SQL> commit;

Commit complete

SQL> select * from test;

A

---------------------------------------

1

2

SQL> alter system switch logfile;

System altered.

SQL>r

1* alter system switch logfile;

System altered.

4、 关闭数据库,模拟丢失数据文件

SQL> shutdown immediate;

Database closed.

Database dismounted.

Oracle instance shut down

C:/>del D:/Oracle/ORADATA/TEST/USER01.DBF

5、 启动数据库,检查错误

SQL> startup

Oracle instance started.

Total System Global Area  102020364 bytes

Fixed Size                    70924 bytes

Variable Size              85487616 bytes

Database Buffers           16384000 bytes

Redo Buffers                  77824 bytes

Database mounted.

ORA-01157: cannot identify/lock data file 3 - see DBWR trace file

ORA-01110: data file 3: 'D:/Oracle/ORADATA/TEST/USER01.DBF'

6、 先打开数据库

SQL> alter database datafile 3 offline drop;

Database altered.

SQL> alter database open;

Database altered.

7、 恢复该表空间

恢复脚本可以是恢复单个数据文件

run{

allocate channel c1 type disk;

restore datafile 3;

recover datafile 3;

sql 'alter database datafile 3 online';

release channel c1;

}

也可以是,恢复表空间

run{

allocate channel c1 type disk;

restore tablespace users;

recover tablespace users;

sql 'alter database datafile 3 online';

release channel c1;

}

过程如下:

C:/>rman

Recovery Manager: Release 8.1.6.0.0 - Production

RMAN> connect rcvcat

RMAN-06008: connected to recovery catalog database

RMAN> connect target internal/virpure

RMAN-06005: connected to target database: TEST (DBID=1788174720)

RMAN> run{

2> allocate channel c1 type disk;

3> restore datafile 3;

4> recover datafile 3;

5> sql 'alter database datafile 3 online';

6> release channel c1;

7> }

//输出内容冗长,省略--编者

RMAN>

8、 检查数据是否完整

SQL> alter database open;

Database altered.

SQL> select * from test;

A

---------------------------------------

1

2

说明:

1、RMAN也可以实现单个表空间或数据文件的恢复,恢复过程可以在mount下或open方式下,如果在open方式下

恢复,可以减少down机时间;

2、如果损坏的是一个数据文件,建议offline并在open方式下恢复;

3、这里可以看到,RMAN进行数据文件与表空间恢复的时候,代码都比较简单,而且能保证备份与恢复的可靠性

,所以建议采用RMAN的备份与恢复.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值