首页 > 数据库 > Oracle > Oracle学习系列—数据库备份—RMAN备份
RMAN(Recovery Manager,恢复管理器)是数据的备份工具,是一个与操作系统无关的数据库备份工具,可以跨越不同操作系统进行数据库备份。
以前从来不敢使用这玩意,也不太清楚到底有何用途,只知道很难使用;经过3天的实践总算硬着头皮把例子一个个做了一遍,对RMAN的基本命令和用途有了基本的了解。。。
唉,其实我还是没太搞明白,也许等冷静一段时间研究一下恢复的时候,才知道RMAN的真正用途。。。
|
--Create RMAN enviroment --Create RMAN default
tablespace --Create RMAN User --Grant RMAN privilege SQL*Plus: Release 9.2.0.1.0
- Production on Sun Apr 8 21:23:31 2007 Copyright (c) 1982, 2002,
Oracle Corporation. All rights
reserved. SQL> connect
sys/change_on_install as sysdba; Connected. SQL> create tablespace
cattbs 2
datafile 'c:/userdefine/oracle/oradata/wbq/cattbsdb01.dbf' size
10M 3
autoextend on next 10M maxsize 100M 4
extent management local uniform size 128k; Tablespace created. SQL> create user rman
identified by rman 2
default tablespace cattbs 3
temporary tablespace temp; User created. SQL> grant
connect,resource to rman; Grant succeeded. SQL> grant
recovery_catalog_owner to rman; Grant succeeded. SQL> |
|
--Rman login --create recovery catalog Recovery Manager: Release
9.2.0.1.0 - Production Copyright (c) 1995, 2002,
Oracle Corporation. All rights
reserved. RMAN> connect catalog
rman/rman connected to recovery
catalog database recovery catalog is not
installed RMAN> create catalog; recovery catalog created |
|
--Connect Destination
Database, local database can be connected directly --Register Database Recovery Manager: Release
9.2.0.1.0 - Production Copyright (c) 1995, 2002,
Oracle Corporation. All rights
reserved. RMAN> connect target
sys/change_on_install connected to target
database: WBQ (DBID=2252890748) RMAN> register database; database registered in
recovery catalog starting full resync of
recovery catalog full resync complete RMAN> resync catalog; starting full resync of
recovery catalog full resync complete |
|
--remote startup and
shutdown database RMAN> shutdown immediate database closed database dismounted Oracle instance shut down RMAN> startup connected to target
database(not started) Oracle instance started database mounted database opened Total System Global
Area XXX bytes Fixed Size XXX bytes Variable Size XXX bytes Database Buffers XXX bytes Redo Buffers XXX bytes |
|
--Auto Channel
configuration --Show default device type --Change parallelism number
to 3 --Show device type again --Set default device type --Set data volume per
backup RMAN> show device type; RMAN configuration
parameters are: CONFIGURE DEVICE TYPE DISK
PARALLELISM 1; # default RMAN> configure device
type disk parallelism 3; new RMAN configuration
parameters: CONFIGURE DEVICE TYPE DISK
PARALLELISM 3; new RMAN configuration
parameters are successfully stored released channel:
ORA_DISK_1 RMAN> show device type; RMAN configuration
parameters are: CONFIGURE DEVICE TYPE DISK
PARALLELISM 3; RMAN> configure default
device type to disk; new RMAN configuration
parameters: CONFIGURE DEFAULT DEVICE
TYPE TO DISK; new RMAN configuration
parameters are successfully stored RMAN> configure channel
device type disk maxpiecesize=1M; new RMAN configuration
parameters: CONFIGURE CHANNEL DEVICE
TYPE DISK MAXPIECESIZE 1 M; new RMAN configuration
parameters are successfully stored |
|
--backup Database by auto
channel RMAN> backup tablespace
wbq; Starting backup at
09-APR-07 allocated channel:
ORA_DISK_1 channel ORA_DISK_1: sid=18
devtype=DISK allocated channel:
ORA_DISK_2 channel ORA_DISK_2: sid=19
devtype=DISK allocated channel:
ORA_DISK_3 channel ORA_DISK_3: sid=20
devtype=DISK channel ORA_DISK_1:
starting full datafile backupset channel ORA_DISK_1:
specifying datafile(s) in backupset input datafile fno=00011
name=C:/USERDEFINE/ORACLE/ORADATA/WBQ/WBQ.ORA channel ORA_DISK_1:
starting piece 1 at 09-APR-07 channel ORA_DISK_1:
finished piece 1 at 09-APR-07 piece handle=C:/USERDEFINE/ORACLE/ORA92/DATABASE/3IEOTTB_1_1
comment=NONE channel ORA_DISK_1: backup
set complete, elapsed time: 00:00:03 Finished backup at
09-APR-07 --define Manual Channel by
RUN command. --define 3 channel, and
parallel backup 3 datafile. a channel operate a databfile RMAN> run 2> { 3> allocate channel c1
device type disk; 4> allocate channel c2
device type disk; 5> allocate channel c3
device type disk; 6> backup datafile
1,2,3; 7> } released channel:
ORA_DISK_1 released channel:
ORA_DISK_2 released channel:
ORA_DISK_3 allocated channel: c1 channel c1: sid=18
devtype=DISK allocated channel: c2 channel c2: sid=19
devtype=DISK allocated channel: c3 channel c3: sid=20
devtype=DISK Starting backup at
09-APR-07 channel c1: starting full
datafile backupset channel c1: specifying
datafile(s) in backupset input datafile fno=00002
name=C:/USERDEFINE/ORACLE/ORADATA/WBQ/UNDOTBS01.DBF channel c1: starting piece
1 at 09-APR-07 channel c2: starting full
datafile backupset channel c2: specifying
datafile(s) in backupset input datafile fno=00003
name=C:/USERDEFINE/ORACLE/ORADATA/WBQ/CWMLITE01.DBF channel c2: starting piece
1 at 09-APR-07 channel c3: starting full
datafile backupset channel c3: specifying
datafile(s) in backupset including current SPFILE in
backupset including current
controlfile in backupset input datafile fno=00001
name=C:/USERDEFINE/ORACLE/ORADATA/WBQ/SYSTEM01.DBF channel c3: starting piece
1 at 09-APR-07 channel c1: finished piece
1 at 09-APR-07 piece handle=C:/USERDEFINE/ORACLE/ORA92/DATABASE/4IEOU0O_1_1
comment=NONE channel c1: backup set
complete, elapsed time: 00:00:11 channel c2: finished piece
1 at 09-APR-07 piece handle=C:/USERDEFINE/ORACLE/ORA92/DATABASE/5IEOU0O_1_1
comment=NONE channel c2: backup set
complete, elapsed time: 00:00:11 channel c3: finished piece
1 at 09-APR-07 piece handle=C:/USERDEFINE/ORACLE/ORA92/DATABASE/6IEOU0O_1_1
comment=NONE channel c3: backup set
complete, elapsed time: 00:00:56 Finished backup at
09-APR-07 released channel: c2 released channel: c3 released channel: c1 |
|
--Define 3 channel, but
only a channel backup datafile ,so only utilize one channel RMAN> run 2> { 3> allocate channel c1
device type disk; 4> allocate channel c2
device type disk; 5> allocate channel c3
device type disk; 6> backup datafile 1; 7> backup datafile 2; 8> backup datafile 3; 9> } allocated channel: c1 channel c1: sid=18
devtype=DISK allocated channel: c2 channel c2: sid=19
devtype=DISK allocated channel: c3 channel c3: sid=20
devtype=DISK Starting backup at
09-APR-07 channel c1: starting full
datafile backupset channel c1: specifying
datafile(s) in backupset including current SPFILE in
backupset including current
controlfile in backupset input datafile fno=00001
name=C:/USERDEFINE/ORACLE/ORADATA/WBQ/SYSTEM01.DBF channel c1: starting piece
1 at 09-APR-07 channel c1: finished piece
1 at 09-APR-07 piece handle=C:/USERDEFINE/ORACLE/ORA92/DATABASE/7IEOU4E_1_1
comment=NONE channel c1: backup set
complete, elapsed time: 00:00:46 Finished backup at
09-APR-07 Starting backup at 09-APR-07 channel c1: starting full
datafile backupset channel c1: specifying
datafile(s) in backupset input datafile fno=00002
name=C:/USERDEFINE/ORACLE/ORADATA/WBQ/UNDOTBS01.DBF channel c1: starting piece
1 at 09-APR-07 channel c1: finished piece
1 at 09-APR-07 piece handle=C:/USERDEFINE/ORACLE/ORA92/DATABASE/8IEOU5T_1_1
comment=NONE channel c1: backup set
complete, elapsed time: 00:00:15 Finished backup at
09-APR-07 Starting backup at
09-APR-07 channel c1: starting full
datafile backupset channel c1: specifying
datafile(s) in backupset input datafile fno=00003
name=C:/USERDEFINE/ORACLE/ORADATA/WBQ/CWMLITE01.DBF channel c1: starting piece
1 at 09-APR-07 channel c1: finished piece
1 at 09-APR-07 piece handle=C:/USERDEFINE/ORACLE/ORA92/DATABASE/9IEOU6C_1_1
comment=NONE channel c1: backup set
complete, elapsed time: 00:00:03 Finished backup at
09-APR-07 released channel: c1 released channel: c2 released channel: c3 --show all channel
configuration parameter. RMAN> show all; RMAN configuration
parameters are: CONFIGURE RETENTION POLICY
TO REDUNDANCY 1; # default CONFIGURE BACKUP
OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE
TYPE TO DISK; CONFIGURE CONTROLFILE
AUTOBACKUP OFF; # default CONFIGURE CONTROLFILE
AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default CONFIGURE DEVICE TYPE DISK
PARALLELISM 3; 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 MAXPIECESIZE 1 M; CONFIGURE MAXSETSIZE TO
UNLIMITED; # default CONFIGURE SNAPSHOT
CONTROLFILE NAME TO 'C:/USERDEFINE/ORACLE/ORA92/DATABASE/SNCF WBQ.ORA'; # default |
|
--Copy by Manual Channel RMAN> run 2> { 3> allocate channel c1
device type disk; 4> allocate channel c2
device type disk; 5> allocate channel c3
device type disk; 6> copy 7> datafile 11 to 'c:/userdefine/oracle/oradata/wbq/backup/wbq1008.dbf', 8> current controlfile
to 'c:/userdefine/oracle/oradata/wbq/backup/controlbk.ctl'; 9> } using target database
controlfile instead of recovery catalog allocated channel: c1 channel c1: sid=19
devtype=DISK allocated channel: c2 channel c2: sid=18
devtype=DISK allocated channel: c3 channel c3: sid=12
devtype=DISK Starting copy at 09-APR-07 channel c2: copied current
controlfile output filename=C:/USERDEFINE/ORACLE/ORADATA/WBQ/BACKUP/CONTROLBK.CTL channel c1: copied datafile
11 output filename=C:/USERDEFINE/ORACLE/ORADATA/WBQ/BACKUP/WBQ1008.DBF
recid=3 stam p=619481357 Finished copy at 09-APR-07 released channel: c1 released channel: c2 released channel: c3 --copy by Auto Channel RMAN> copy 2> datafile 11 to 'c:/userdefine/oracle/oradata/wbq/backup/wbq1010.dbf', 3> current controlfile
to 'c:/userdefine/oracle/oradata/wbq/backup/control1010bk.ctl'; Starting copy at 09-APR-07 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 channel ORA_DISK_2: copied
current controlfile output filename=C:/USERDEFINE/ORACLE/ORADATA/WBQ/BACKUP/CONTROL1010BK.CTL channel ORA_DISK_1: copied
datafile 11 output filename=C:/USERDEFINE/ORACLE/ORADATA/WBQ/BACKUP/WBQ1010.DBF
recid=5 stam p=619481551 Finished copy at 09-APR-07 |
|
--backup method,need
dispatch auto or manual channel,define file format,define backup level,backup
object --backup full database RMAN> backup database ......... --backup tablesapce RMAN> backup tablespace
users; Starting backup at
09-APR-07 using target database
controlfile instead of recovery catalog allocated channel:
ORA_DISK_1 channel ORA_DISK_1: sid=19
devtype=DISK allocated channel:
ORA_DISK_2 channel ORA_DISK_2: sid=16
devtype=DISK allocated channel:
ORA_DISK_3 channel ORA_DISK_3: sid=20
devtype=DISK channel ORA_DISK_1:
starting full datafile backupset channel ORA_DISK_1:
specifying datafile(s) in backupset input datafile fno=00009
name=C:/USERDEFINE/ORACLE/ORADATA/WBQ/USERS01.DBF channel ORA_DISK_1:
starting piece 1 at 09-APR-07 channel ORA_DISK_1:
finished piece 1 at 09-APR-07 piece handle=C:/USERDEFINE/ORACLE/ORA92/DATABASE/DIEP4KJ_1_1
comment=NONE channel ORA_DISK_1: backup
set complete, elapsed time: 00:00:03 Finished backup at
09-APR-07 --backup controlfile RMAN> backup current
controlfile; Starting backup at
09-APR-07 using channel ORA_DISK_1 using channel ORA_DISK_2 using channel ORA_DISK_3 channel ORA_DISK_1:
starting full datafile backupset channel ORA_DISK_1:
specifying datafile(s) in backupset including current
controlfile in backupset channel ORA_DISK_1:
starting piece 1 at 09-APR-07 channel ORA_DISK_1:
finished piece 1 at 09-APR-07 piece handle=C:/USERDEFINE/ORACLE/ORA92/DATABASE/EIEP4ME_1_1
comment=NONE channel ORA_DISK_1:
starting piece 2 at 09-APR-07 channel ORA_DISK_1:
finished piece 2 at 09-APR-07 piece handle=C:/USERDEFINE/ORACLE/ORA92/DATABASE/EIEP4ME_2_1
comment=NONE channel ORA_DISK_1:
starting piece 3 at 09-APR-07 channel ORA_DISK_1:
finished piece 3 at 09-APR-07 piece handle=C:/USERDEFINE/ORACLE/ORA92/DATABASE/EIEP4ME_3_1
comment=NONE channel ORA_DISK_1: backup
set complete, elapsed time: 00:00:03 Finished backup at
09-APR-07 RMAN> |
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/8128313/viewspace-909665/ ,如需转载,请注明出处,否则将追究法律责任。