av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術文章
文章詳情頁

一個完整的Oracle rman備份恢復參考示例

瀏覽:6日期:2023-11-29 09:28:03
完整的Oracle rman備份恢復參考示例:

 

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/arch/arch_1_3.arc

ORA-00280: change 51054 for thread 1 is in sequence #3

Specify log: {=suggested | filename | AUTO | CANCEL}

Log applied.

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

ORA-00289: suggestion : /export/home/oracle/admin/test/arch/arch_1_4.arc

ORA-00280: change 51058 for thread 1 is in sequence #4

ORA-00278: log file '/export/home/oracle/admin/test/arch/arch_1_3.arc' no longer

needed for this recovery

Specify log: {=suggested | filename | AUTO | CANCEL}

Log applied.

ORA-00279: change 51074 generated at 06/11/2000 11:40:20 needed for thread 1

ORA-00289: suggestion : /export/home/oracle/admin/test/arch/arch_1_5.arc

ORA-00280: change 51074 for thread 1 is in sequence #5

ORA-00278: log file '/export/home/oracle/admin/test/arch/arch_1_4.arc' no longer

needed for this recovery

Specify log: {=suggested | filename | AUTO | CANCEL}

cancel

Media recovery cancelled.

SVRMGR> alter database open resetlogs;

Statement processed.

恢復完成。

SVRMGR> select table_name from user_tables;

TABLE_NAME

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

BONUS

DEPT

EMP

SALGRADE

TEST

TEST_ZMY

ZMY

ZMY_DEPT

ZMY_EMP

9 rows selected.

可以檢查看到,所有的都恢復了,包括全備份后的事務。(只要有歸檔日志,都可以恢復)。

3、恢復后rman數據庫的同步

$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> reset database;

RMAN-03022: compiling command: reset

RMAN-03023: executing command: reset

RMAN-08006: database registered in recovery catalog

RMAN-03023: executing command: full resync

RMAN-08029: snapshot controlfile name set to default value: ?/dbs/snapcf_@.f

RMAN-08002: starting full resync of recovery catalog

RMAN-08004: full resync complete

標簽: Oracle 數據庫
主站蜘蛛池模板: 日韩欧美一区二区三区 | 精品国产99| 一区二区三区高清 | 97在线观视频免费观看 | 国产精品国产三级国产aⅴ中文 | 中文字幕在线播放第一页 | 精品视频一区在线 | 黄页网址在线观看 | 国产欧美日韩综合精品一区二区 | 黑色丝袜三级在线播放 | 日本在线你懂的 | 日韩视频在线播放 | 波多野吉衣在线播放 | 成人福利在线视频 | 二区亚洲 | 91国产在线视频在线 | 久久人人网 | 在线欧美视频 | 成人免费观看男女羞羞视频 | 中文字幕欧美一区 | 亚洲欧美日韩成人在线 | 一级黄色片网址 | 超碰在线人 | 人人干在线视频 | 欧美精品一区二区蜜桃 | 激情婷婷 | 国产精品日韩在线观看一区二区 | 久久久久久久久久久久久久av | 91精品在线播放 | 欧美性猛交一区二区三区精品 | 成人激情免费视频 | 成人一区二区三区 | 日韩美女在线看免费观看 | 亚洲成人一二区 | 拍真实国产伦偷精品 | 日本a∨精品中文字幕在线 亚洲91视频 | 欧美一区二区二区 | 国内精品视频在线 | 国产日韩精品一区二区 | 色啪网| 日韩一区二区三区在线 |