分享
 
 
 

完整的oraclerman备份恢复的例子

王朝oracle·作者佚名  2008-05-19
窄屏简体版  字體: |||超大  

1、 建rman库作为repository

$more createrman_db1.sh

set echo on

spool makedb1.log

create database rman

datafile '/export/home/oracle/oradata/rman_data/system.dbf' size 50m autoextend

on next 640K

logfile '/export/home/oracle/oradata/rman_data/redo0101.log' SIZE 10M,

'/export/home/oracle/oradata/rman_data/redo0201.log' SIZE 10M

maxdatafiles 30

maxinstances 8

maxlogfiles 64

character set US7ASCII

national character set US7ASCII

;

disconnect

spool off

exit

@/export/home/oracle/8.1.6/rdbms/admin/catalog.sql;

REM ********** ALTER SYSTEM TABLESPACE *********

ALTER TABLESPACE SYSTEM

DEFAULT STORAGE ( INITIAL 64K NEXT 64K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCR

EASE 50);

ALTER TABLESPACE SYSTEM

MINIMUM EXTENT 64K;

REM ********** TABLESPACE FOR ROLLBACK **********

CREATE TABLESPACE RBS DATAFILE '/export/home/oracle/oradata/rman_data/rbs.dbf' s

ize 50m

AUTOEXTEND ON NEXT 512K

MINIMUM EXTENT 512K

DEFAULT STORAGE ( INITIAL 512K NEXT 512K MINEXTENTS 10 MAXEXTENTS UNLIMITED PC

TINCREASE 0 );

REM ********** TABLESPACE FOR TEMPORARY **********

CREATE TABLESPACE TEMP DATAFILE '/export/home/oracle/oradata/rman_data/temp.dbf'

size 50m

AUTOEXTEND ON NEXT 64K

MINIMUM EXTENT 64K

DEFAULT STORAGE ( INITIAL 64K NEXT 64K MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCR

EASE 0) TEMPORARY;

REM **** Creating four rollback segments ****************

CREATE PUBLIC ROLLBACK SEGMENT RBS_0 TABLESPACE RBS

STORAGE ( OPTIMAL 64000K );

ALTER ROLLBACK SEGMENT "RBS_0" ONLINE;

REM **** SYS and SYSTEM users ****************

alter user sys temporary tablespace TEMP;

alter user system temporary tablespace TEMP;

disconnect

spool off

exit

$more createrman_db3.sh

spool crdb3.log

@/export/home/oracle/8.1.6/rdbms/admin/catproc.sql

@/export/home/oracle/8.1.6/rdbms/admin/caths.sql

@/export/home/oracle/8.1.6/rdbms/admin/otrcsvr.sql

connect system/manager

@/export/home/oracle/8.1.6/sqlplus/admin/pupbld.sql

disconnect

spool off

exit

2、建repository存放的表空间和rman用户

$more createrman_db4.sh

connect internal

create tablespace rman_ts

datafile '/export/home/oracle/oradata/rman_data/rman_ts.dbf'

size 20M default storage (initial 100K next 100K pctincrease 0);

create user rman_hainan identified by rman_hainan

temporary tablespace TEMP

default tablespace rman_ts quota unlimited on

rman_ts;

grant recovery_catalog_owner to rman_hainan;

grant connect ,resource to rman_hainan;

3、建catalog,注册目标数据库

$more createrman_db5.sh

rman catalog rman_hainan/rman_hainan@rman msglog=rman.log

create catalog ;

exit;

rman target sys/oracle@db1

connect catalog rman_hainan/rman_hainan@rman

register database;

exit;

4、可以开始做备份了。

5、做全备

$more rmanshell

. /export/home/oracle/.profile

rman rcvcat rman_hainan/rman_hainan@rman target / cmdfile /export/home/oracle/ba

ckup_level0.rcv log /export/home/oracle/backup.log

$more backup_level0.rcv

resync catalog;

run {

allocate channel t1 type disk;

backup

incremental level 0

skip inaccessible

tag hot_db_bk_level0

filesperset 3

format '/export/home/oracle/bk_%s_%p_%t.bk'

(database);

sql 'alter system archive log current';

backup

filesperset 10

format '/export/home/oracle/a1_%s_%p_%t.ac'

(archivelog all delete input);

backup

format '/export/home/oracle/df_t%t_s%s_p%p.ct'

current controlfile ;

}

6、做增备

$more rmanshell1

rman rcvcat rman_hainan/rman_hainan@rman target / cmdfile backup_level1.rcv log

backup.log

$more backup_level1.rcv

resync catalog;

run {

allocate channel t1 type disk;

backup

incremental level 1

skip inaccessible

tag hot_db_bk_level1

filesperset 3

format 'bk_%s_%p_%t.bk1'

(database);

sql 'alter system archive log current';

backup

filesperset 10

format 'a1_%s_%p_%t.ac1'

(archivelog all delete input);

backup current controlfile;

}

1、 删除旧的全备

$rman rcvcat rman_hainan/rman_hainan@rman target /

Recovery Manager: Release 8.1.6.0.0 - Production

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

RMAN-06008: connected to recovery catalog database

RMAN list backupset;

RMAN-03022: compiling command: list

List of Backup Sets

Key Recid Stamp LV Set Stamp Set Count Completion Time

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

38 145 399987408 0 399987406 153 11-JUN-00

根据key来删除旧的备份。

RMAN allocate channel for maintenance type disk;

RMAN change backupset 169 delete; ----------THIS IS THE COMMAND TO REMOVE THE ENTRY & OS FILE

做完后可以看到list backupset和操作系统的文件都没有了。

2、 恢复

(1) 将数据库启动到nomount状态:

$svrmgrl

Oracle Server Manager Release 3.1.6.0.0 - Production

Copyright (c) 1997, 1999, Oracle Corporation. All Rights Reserved.

Oracle8i Enterprise Edition Release 8.1.6.0.0 - 64bit Production

With the Partitioning option

JServer Release 8.1.6.0.0 - Production

SVRMGR connect internal

Connected.

SVRMGR startup nomount;

ORACLE instance started.

Total System Global Area 339275684 bytes

Fixed Size 94116 bytes

Variable Size 318685184 bytes

Database Buffers 16384000 bytes

Redo Buffers 4112384 bytes

SVRMGR exit

Server Manager complete.

(2) 恢复控制文件:

$rman rcvcat rman_hainan/rman_hainan@rman target /

Recovery Manager: Release 8.1.6.0.0 - Production

RMAN-06006: connected to target database: test (not mounted)

RMAN-06008: connected to recovery catalog database

RMAN run {

2 allocate channel d1 type disk;

3 restore controlfile;

4 release channel d1;

5 }

(3) 恢复数据文件

RMAN run {

2 allocate channel d1 type disk;

3 sql "alter database mount";

4 restore datafile 1;

5 restore datafile 2;

6 restore datafile 3;

7 restore datafile 4;

8 release channel d1;

9 }

(4) 恢复日志文件

RMAN run {

2 set archivelog destination to '/export/home/oracle/admin/test/arch';

3 allocate channel d1 type disk;

4 restore archivelog all;

5 release channel d1;

6 }

会把所有的日志文件恢复。

(5) 根据日志做recover

$svrmgrl

Oracle Server Manager Release 3.1.6.0.0 - Production

Copyright (c) 1997, 1999, Oracle Corporation. All Rights Reserved.

Oracle8i Enterprise Edition Release 8.1.6.0.0 - 64bit Production

With the Partitioning option

JServer Release 8.1.6.0.0 - Production

SVRMGR connect internal

Connected.

SVRMGR recover database using backup controlfile until cancel;

ORA-00279: change 51054 generated at 06/11/2000 11:38:37 needed for thread 1

ORA-00289: suggestion : /export/home/oracle/admin/test

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有