您的位置:首页 > 其它

rman输出信息解释及表空间备份与在线恢复

2017-04-02 22:43 465 查看
rman输出信息解释及表空间备份与在线恢复

一 ,[oracle@oracle1 ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sun Apr 2 16:07:33 2017

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: SHPOG1 (DBID=799280029)

rman 输出的信息

RMAN> show all;

using target database control file instead of recovery catalog

RMAN configuration parameters for database with db_unique_name SHPOG1 are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 7; #备份后保留几份,默认1份,可以修改

CONFIGURE BACKUP OPTIMIZATION OFF; # default #设置备份优化

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default #设置备份到磁盘,默认是备份到磁盘

CONFIGURE CONTROLFILE AUTOBACKUP ON; #设置备份控制文件,默认是关闭

CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/oracle.bacup/control/cf_%F’; #设置备份控制文件路径和格式

CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default #备份类型,默认是备份集

CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default #备份集的个数,里面包括数据,控制,参数

CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default #备份归档的路径

CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘/oracle.bacup/%d_%s_%T.bak’; #控制文件备份路径

CONFIGURE MAXSETSIZE TO UNLIMITED; # default #备份集大小

CONFIGURE ENCRYPTION FOR DATABASE OFF; # default #加密

CONFIGURE ENCRYPTION ALGORITHM ‘AES128’; # default #加密类型

CONFIGURE COMPRESSION ALGORITHM ‘BASIC’ AS OF RELEASE ‘DEFAULT’ OPTIMIZE FOR LOAD TRUE ; # default #备份压缩

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default #归档删除策略

CONFIGURE SNAPSHOT CONTROLFILE NAME TO ‘/oracle/app/product/11.2/db/dbs/snapcf_shpog1.f’; # default #备份控制文件快照

RMAN> list backup;

using target database control file instead of recovery catalog

List of Backup Sets #列表

编号 全备类型 备份大小 备份到磁盘 备份用的时间 备份时间

BS Key Type LV Size Device Type Elapsed Time Completion Time

——- —- – ———- ———– ———— —————

1 Full 1.07G DISK 00:03:47 18-MAR-17 >>>>>>>>> #全备–大小1.07G—备份到磁盘–用时间–备份时间

BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20170318T040731 >>>>>>>>>#备份篇–备份状态–备份压缩–标签

Piece Name: /oracle/app/product/11.2/db/dbs/01rvdlk4_1_1 >>>>>>>>>>>>>>>>#篇名字–备份路径

List of Datafiles in backup set 1

File LV Type Ckp SCN Ckp Time Name

1 Full 1027269 18-MAR-17 /oracle/app/oradata/shpog1/system01.dbf

2 Full 1027269 18-MAR-17 /oracle/app/oradata/shpog1/sysaux01.dbf

3 Full 1027269 18-MAR-17 /oracle/app/oradata/shpog1/undotbs01.dbf

4 Full 1027269 18-MAR-17 /oracle/app/oradata/shpog1/users01.dbf

5 Full 1027269 18-MAR-17 /oracle/app/oradata/shpog1/example01.dbf

6 Full 1027269 18-MAR-17 /oracle/oracle_tablespace/zhou01.dbf

BS Key Type LV Size Device Type Elapsed Time Completion Time

2 Full 9.36M DISK 00:00:01 18-MAR-17

BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20170318T041310

Piece Name: /oracle/app/product/11.2/db/dbs/03rvdm22_1_1

SPFILE Included: Modification time: 18-MAR-17

SPFILE db_unique_name: SHPOG1

Control File Included: Ckp SCN: 1027584 Ckp time: 18-MAR-17

二,创建用户和表空间

[oracle@oracle1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun Apr 2 16:21:28 2017

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

Connected to:

Oracle Database 11g Release 11.2.0.1.0 - 64bit Production

(1)创建表空间

SQL> create tablespace hai datafile ‘/oracle/app/oradata/shpog1/hai01.dbf’ size 100m autoextend on;

Tablespace created.

(2)创建用户及给默认表空间

SQL> create user hai identified by hai default tablespace hai;

User created.

(3)给用户权限

SQL> grant connect,resource to hai;

Grant succeeded.

SQL> grant dba to hai;

Grant succeeded.

SQL> exit

Disconnected from Oracle Database 11g Release 11.2.0.1.0 - 64bit Production

三,rman备份

[oracle@oracle1 ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sun Apr 2 19:06:49 2017

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: SHPOG1 (DBID=799280029)

(1)全备

RMAN> backup database format ‘/oracle.bacup/%u.bak’;

Starting backup at 02-APR-17

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=1713 device type=DISK

channel ORA_DISK_1: starting full datafile backup set #通道全备数据文件

channel ORA_DISK_1: specifying datafile(s) in backup set #备份数据文件是下面input

input datafile file number=00006 name=/oracle/oracle_tablespace/zhou01.dbf

input datafile file number=00007 name=/oracle/app/oradata/shpog1/rman_tbs.dbf

input datafile file number=00001 name=/oracle/app/oradata/shpog1/system01.dbf

input datafile file number=00002 name=/oracle/app/oradata/shpog1/sysaux01.dbf

input datafile file number=00003 name=/oracle/app/oradata/shpog1/undotbs01.dbf

input datafile file number=00004 name=/oracle/app/oradata/shpog1/users01.dbf

input datafile file number=00005 name=/oracle/app/oradata/shpog1/example01.dbf

input datafile file number=00008 name=/oracle/app/oradata/shpog1/hai01.dbf

channel ORA_DISK_1: starting piece 1 at 02-APR-17 #通道启用时间

channel ORA_DISK_1: finished piece 1 at 02-APR-17 #通道结束时间

piece handle=/oracle.bacup/0ds0ms3i.bak tag=TAG20170402T190938 comment=NONE #备份篇 #tag=TAG20170402T190938是标签

channel ORA_DISK_1: backup set complete, elapsed time: 00:11:26 #备份篇时间

Finished backup at 02-APR-17

Starting Control File and SPFILE Autobackup at 02-APR-17 #参数文件备份

piece handle=/oracle.bacup/control/cf_c-799280029-20170402-01 comment=NONE

Finished Control File and SPFILE Autobackup at 02-APR-17

(3)备份表空间

RMAN> backup tablespace hai format ‘/oracle.bacup/tablespace/%u.bak’;

Starting backup at 02-APR-17

using channel ORA_DISK_1

channel ORA_DISK_1: starting full datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

input datafile file number=00008 name=/oracle/app/oradata/shpog1/hai01.dbf

channel ORA_DISK_1: starting piece 1 at 02-APR-17

channel ORA_DISK_1: finished piece 1 at 02-APR-17

piece handle=/oracle.bacup/tablespace/0gs0mvs0.bak tag=TAG20170402T201351 comment=NONE

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

Finished backup at 02-APR-17

Starting Control File and SPFILE Autobackup at 02-APR-17

piece handle=/oracle.bacup/control/cf_c-799280029-20170402-02 comment=NONE

Finished Control File and SPFILE Autobackup at 02-APR-17

RMAN> exit

(4)删除数据文件

[root@oracle1 shpog1]# ll

total 9919560

-rw-r—– 1 oracle oinstall 9748480 Apr 2 20:14 control01.ctl

-rw-r—– 1 oracle oinstall 9748480 Apr 2 20:14 control02.ctl

-rw-r—– 1 oracle oinstall 104865792 Apr 2 19:09 example01.dbf

-rw-r—– 1 oracle oinstall 104865792 Apr 2 20:13 hai01.dbf

-rw-r—– 1 oracle oinstall 52429312 Apr 2 15:35 redo01.log

-rw-r—– 1 oracle oinstall 52429312 Apr 2 20:14 redo02.log

-rw-r—– 1 oracle oinstall 52429312 Apr 2 15:35 redo03.log

-rw-r—– 1 oracle oinstall 52429312 Apr 2 15:35 redo04.log

-rw-r—– 1 oracle oinstall 52429312 Apr 2 15:35 redo05.log

-rw-r—– 1 oracle oinstall 5368717312 Apr 2 19:09 rman_tbs.dbf

-rw-r—– 1 oracle oinstall 1073750016 Apr 2 20:05 sysaux01.dbf

-rw-r—– 1 oracle oinstall 1073750016 Apr 2 19:56 system01.dbf

-rw-r—– 1 oracle oinstall 40902656 Apr 2 15:35 temp01.dbf

-rw-r—– 1 oracle oinstall 1073750016 Apr 2 19:45 undotbs01.dbf

-rw-r—– 1 oracle oinstall 1073750016 Apr 2 19:09 users01.dbf

[root@oracle1 shpog1]# rm -rf hai01.dbf

[root@oracle1 shpog1]#

[root@oracle1 shpog1]#

[root@oracle1 shpog1]# ll

total 9817148

-rw-r—– 1 oracle oinstall 9748480 Apr 2 20:14 control01.ctl

-rw-r—– 1 oracle oinstall 9748480 Apr 2 20:14 control02.ctl

-rw-r—– 1 oracle oinstall 104865792 Apr 2 19:09 example01.dbf

-rw-r—– 1 oracle oinstall 52429312 Apr 2 15:35 redo01.log

-rw-r—– 1 oracle oinstall 52429312 Apr 2 20:14 redo02.log

-rw-r—– 1 oracle oinstall 52429312 Apr 2 15:35 redo03.log

-rw-r—– 1 oracle oinstall 52429312 Apr 2 15:35 redo04.log

-rw-r—– 1 oracle oinstall 52429312 Apr 2 15:35 redo05.log

-rw-r—– 1 oracle oinstall 5368717312 Apr 2 19:09 rman_tbs.dbf

-rw-r—– 1 oracle oinstall 1073750016 Apr 2 20:05 sysaux01.dbf

-rw-r—– 1 oracle oinstall 1073750016 Apr 2 19:56 system01.dbf

-rw-r—– 1 oracle oinstall 40902656 Apr 2 15:35 temp01.dbf

-rw-r—– 1 orac
f714
le oinstall 1073750016 Apr 2 19:45 undotbs01.dbf

-rw-r—– 1 oracle oinstall 1073750016 Apr 2 19:09 users01.dbf

(5)关闭数据库

[oracle@oracle1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun Apr 2 20:15:13 2017

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

Connected to:

Oracle Database 11g Release 11.2.0.1.0 - 64bit Production

SQL> shudown immdeiated

SP2-0734: unknown command beginning “shudown im…” - rest of line ignored.

SQL> shutdown immediated;

SP2-0717: illegal SHUTDOWN option

SQL> shutdown immediate;

ORA-01116: error in opening database file 8

ORA-01110: data file 8: ‘/oracle/app/oradata/shpog1/hai01.dbf’

ORA-27041: unable to open file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

SQL>

SQL> shutdown immediate;

ORA-01116: error in opening database file 8

ORA-01110: data file 8: ‘/oracle/app/oradata/shpog1/hai01.dbf’

ORA-27041: unable to open file

Linux-x86_64 Error: 2: No such file or directory

Additional information: 3

SQL>

关闭数据库强制关

SQL> shutdown abort;

ORACLE instance shut down.

SQL>

(6)起数据库少了 8号数据库文件,数据库起不起来 》》’/oracle/app/oradata/shpog1/hai01.dbf’

SQL> startup;

ORACLE instance started.

Total System Global Area 1586708480 bytes

Fixed Size 2213736 bytes

Variable Size 1191184536 bytes

Database Buffers 385875968 bytes

Redo Buffers 7434240 bytes

Database mounted.

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

ORA-01110: data file 8: ‘/oracle/app/oradata/shpog1/hai01.dbf’

(7)数据库状态

SQL> select instance_name,status from v$instance;

INSTANCE_NAME STATUS

shpog1 MOUNTED

SQL> alter tablespace datafile ‘/oracle/app/oradata/shpog1/hai01.dbf’ offline;

alter tablespace datafile ‘/oracle/app/oradata/shpog1/hai01.dbf’ offline

*

ERROR at line 1:

ORA-02142: missing or invalid ALTER TABLESPACE option

四,在线恢复丢失的数据库文件

数据库文件恢复将数据文件offline,

SQL> alter database datafile ‘/oracle/app/oradata/shpog1/hai01.dbf’ offline;

Database altered.

先将数据库open

SQL> alter database open;

Database altered.

SQL> exit

(1)rman 进行恢复

Disconnected from Oracle Database 11g Release 11.2.0.1.0 - 64bit Production

[oracle@oracle1 ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sun Apr 2 20:54:45 2017

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: SHPOG1 (DBID=799280029)

RMAN> restore datafile 8;

Starting restore at 02-APR-17

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=1710 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore

channel ORA_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_DISK_1: restoring datafile 00008 to /oracle/app/oradata/shpog1/hai01.dbf

channel ORA_DISK_1: reading from backup piece /oracle.bacup/tablespace/0gs0mvs0.bak

channel ORA_DISK_1: piece handle=/oracle.bacup/tablespace/0gs0mvs0.bak tag=TAG20170402T201351

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:00:03

Finished restore at 02-APR-17

RMAN> recover datafile 8;

Starting recover at 02-APR-17

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=1705 device type=DISK

starting media recovery

media recovery complete, elapsed time: 00:00:00

Finished recover at 02-APR-17

RMAN> exit

Recovery Manager complete.

(2)在将丢失的数据文件 online

[oracle@oracle1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun Apr 2 20:58:35 2017

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

Connected to:

Oracle Database 11g Release 11.2.0.1.0 - 64bit Production

SQL> alter database datafile ‘/oracle/app/oradata/shpog1/hai01.dbf’ online;

Database altered.

SQL>

SQL>

SQL>

SQL> exit

Disconnected from Oracle Database 11g Release 11.2.0.1.0 - 64bit Production

[oracle@oracle1 ~]ll/oracle/app/oradata/shpog1/hai01.dbf−rw−r—–1oracleoinstall104865792Apr220:59/oracle/app/oradata/shpog1/hai01.dbf[oracle@oracle1 ] 已经恢复回来

-bash: 已经恢复回来: command not found

[oracle@oracle1 ~][oracle@oracle1 ] sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sun Apr 2 21:03:27 2017

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

Connected to:

Oracle Database 11g Release 11.2.0.1.0 - 64bit Production

SQL> select * from hai.feng;

ID NAME


2 haifeng
3 haifeng2
4 haifeng3
5 haifeng4
6 haifeng5
7 haifeng5
8 haifeng6
9 haifeng8
10 haifeng8


9 rows selected.

SQL> select * from hai.feng2;

SP2-0734: unknown command beginning “色ect…” - rest of line ignored.

SQL> select * from hai.feng2;

ID NAME


2 haifeng
3 haifeng2
4 haifeng3
5 haifeng4
6 haifeng5
7 haifeng5
8 haifeng6
9 haifeng8
10 haifeng8


9 rows selected.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  备份 rman