数据库连接oracle 10g rman 备份与恢复 之一
在改章节中,我们主要介绍数据库连接的内容,自我感觉有个不错的议建和大家分享下
播布客海明师老第一媾和第二讲记笔
rman 10g备份与恢复
海明诚实第一讲
一、recovery management(恢复管理器)
rman可以连接据数库的类型
1、target database
sysdba限权才能target database,如果没有连接失败。
2、recovery catalog database
可选的,可以用catalog或者nocatalog,应用rman备份时候发生的信息,存到catalog,当然如果没有catalog就放到controlfile面里
3、auxiliary database(帮助据数库)
连接出产据数库时候可以连接帮助据数库,可以将出产据数库copy到帮助据数库
rman可以连接以上三个据数库,这三种据数库可以在一台oracle server面上;也可以在不同的oracle server面上,oracle议建将catalog
目录据数库和出产据数库不要放到一个oracle server面上。还有帮助据数也放到独自的oracle server上。这样可以通过rman把出产据数库copy
到帮助据数库面上,这样更安全。
--------------------------------------------------------------------------------------------------
二、rman备份方法 (归档式模)
非catalog方法
全备份
0级增量
1级增量
。
。
找一下rman文件
[root@redhat wolf]# find / -name rman
/oracle/ora10g/product/10.2.0/db_1/bin/rman
/oracle/ora10g/product/10.2.0/db_1/oc4j/j2ee/oc4j_applications/applications/em/em/WEB-INF/perl/db/rman
/oracle/ora10g/product/10.2.0/db_1/oc4j/j2ee/oc4j_applications/applications/em/em/database/rman
/oracle/ora10g/product/10.2.0/db_1/sysman/admin/scripts/db/rman
[root@redhat wolf]# su - oracle
[oracle@redhat ~]$ echo @PATH
@PATH
[oracle@redhat ~]$ echo $PATH (这面里出来的bin定一先是oracle的bin,不然rman会为认linux子的rman)
/oracle/ora10g/product/10.2.0/db_1/bin:/usr/sbin:/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin
[root@redhat wolf]# vi ./.bash_profile
export PATH
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/oracle/ora10g
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=wolf
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH (行执序顺,不然有可能行执linux上的rman)
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/usr/x11R6/lib64
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export LD_ASSUME_KERNEL=2.6.18
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.UTF8"
umask 022
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
fi
fi
"./.bash_profile" 31L, 787C
-----------------------------------------------------------------------------------
三、备份(多练)
[oracle@redhat ~]$ rman nocatalog
Recovery Manager: Release 10.2.0.1.0 - Production on 星期六 4月 20 02:42:15 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
RMAN> conn target /
RMAN> connect target /
connected to target database: WOLF (DBID=3778783462)
using target database control file instead of recovery catalog
RMAN>list backupset;
RMAN>backup database;(全备份)
RMAN> backup database; (仔细观测发生了两个备份集,一个是据数库文件,一个是控制文件和参数文件,分别在不同的目录)
Starting backup at 20-4月 -13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oracle/ora10g/oradata/wolf/system01.dbf
input datafile fno=00003 name=/oracle/ora10g/oradata/wolf/sysaux01.dbf
input datafile fno=00002 name=/oracle/ora10g/oradata/wolf/undotbs01.dbf
input datafile fno=00005 name=/oracle/ora10g/oradata/wolf/rmanwolf.dbf
input datafile fno=00004 name=/oracle/ora10g/oradata/wolf/users01.dbf
channel ORA_DISK_1: starting piece 1 at 20-4月 -13
channel ORA_DISK_1: finished piece 1 at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_nnndf_TAG20130420T025250_8q4gt34k_.bkp tag=TAG20130420T025250 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:04:56
Finished backup at 20-4月 -13
Starting Control File and SPFILE Autobackup at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813207467_8q4h3cvp_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 20-4月 -13
[oracle@redhat WOLF]$ ls
archivelog autobackup backupset onlinelog
[oracle@redhat WOLF]$ cd autobackup
[oracle@redhat autobackup]$ ls
2013_04_17 2013_04_19 2013_04_20
[oracle@redhat autobackup]$ cd 2013_04_20/
[oracle@redhat 2013_04_20]$ ls
o1_mf_s_813207467_8q4h3cvp_.bkp
[oracle@redhat 2013_04_20]$ cd ..
[oracle@redhat autobackup]$ ls
2013_04_17 2013_04_19 2013_04_20
[oracle@redhat autobackup]$ cd ..
[oracle@redhat WOLF]$ ls
archivelog autobackup backupset onlinelog
[oracle@redhat WOLF]$ cd backupset/
[oracle@redhat backupset]$ ls
2013_04_17 2013_04_19 2013_04_20
[oracle@redhat backupset]$ cd 2013_04_20/
[oracle@redhat 2013_04_20]$ ls
o1_mf_nnndf_TAG20130420T025250_8q4gt34k_.bkp
[oracle@redhat 2013_04_20]$
这里备份的文件可以copy到硬盘然后删除,当需要恢复的时候在copy到这个目录,然今后进行恢复
====================================================================================================
oracle 10grman备份与恢复
海明师老第二讲
备份内容格式是由rman内部默认格式决定的。nocatalog方法备份信息写入control
可以到control目录进入controlfile查看
[oracle@redhat wolf]$ pwd
/oracle/ora10g/oradata/wolf
[oracle@redhat wolf]$ strings control01.ctl
。。。。
delete
2013-04-19T10:39:43
delete
2013-04-19T10:39:43
list
2013-04-19T10:39:43
delete
2013-04-20T02:42:15
RMAN
2013-04-20T02:42:15
list
2013-04-20T02:42:15
delete
2013-04-20T02:42:15
list
2013-04-19T10:39:43
list
。。。。
当然所显示的信息就是一些备份的时间内容等。
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; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
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 MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/oracle/ora10g/product/10.2.0/db_1/dbs/snapcf_wolf.f'; # default
RMAN> list backupset;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
18 Full 529.59M DISK 00:04:53 20-4月 -13
BP Key: 18 Status: AVAILABLE Compressed: NO Tag: TAG20130420T025250
Piece Name: /oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_nnndf_TAG20130420T025250_8q4gt34k_.bkp
List of Datafiles in backup set 18
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ---------- ----
1 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/system01.dbf
2 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/undotbs01.dbf
3 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/sysaux01.dbf
4 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/users01.dbf
5 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/rmanwolf.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
19 Full 6.80M DISK 00:00:01 20-4月 -13
BP Key: 19 Status: AVAILABLE Compressed: NO Tag: TAG20130420T025747
Piece Name: /oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813207467_8q4h3cvp_.bkp
Control File Included: Ckp SCN: 476395 Ckp time: 20-4月 -13
SPFILE Included: Modification time: 20-4月 -13
backup set(备份集)
backup piece (备份片)
0级备份和全备份几乎一样,唯一的区别是全备份不能作为一级备份的基础。
参考:
增量备份0级与全备份都是全备份,但是增量备份0级应用rman备份的话就只备份了used block,而全备份备份了used and unused block
总结一下,二者有两个地方不同
1、全备份不能被用作1级增量备份的基础
2、应用rman备份的时候,全备份备份了used and unused block,0级应用rman备份的话就只备份了used block
http://blog.csdn.net/wh62592855/article/details/5082505(网上资料说明0级备份和全备的区别)
0级增量:
backup incremental level=0 database;
RMAN> backup incremental level=0 database;
Starting backup at 20-4月 -13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oracle/ora10g/oradata/wolf/system01.dbf
input datafile fno=00003 name=/oracle/ora10g/oradata/wolf/sysaux01.dbf
input datafile fno=00002 name=/oracle/ora10g/oradata/wolf/undotbs01.dbf
input datafile fno=00005 name=/oracle/ora10g/oradata/wolf/rmanwolf.dbf
input datafile fno=00004 name=/oracle/ora10g/oradata/wolf/users01.dbf
channel ORA_DISK_1: starting piece 1 at 20-4月 -13
channel ORA_DISK_1: finished piece 1 at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_nnnd0_TAG20130420T032742_8q4jvgyw_.bkp tag=TAG20130420T032742 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:05:36
Finished backup at 20-4月 -13
Starting Control File and SPFILE Autobackup at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813209598_8q4k5yqq_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 20-4月 -13
RMAN> list backup;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
18 Full 529.59M DISK 00:04:53 20-4月 -13
BP Key: 18 Status: AVAILABLE Compressed: NO Tag: TAG20130420T025250
Piece Name: /oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_nnndf_TAG20130420T025250_8q4gt34k_.bkp
List of Datafiles in backup set 18
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ---------- ----
1 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/system01.dbf
2 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/undotbs01.dbf
3 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/sysaux01.dbf
4 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/users01.dbf
5 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/rmanwolf.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
19 Full 6.80M DISK 00:00:01 20-4月 -13
BP Key: 19 Status: AVAILABLE Compressed: NO Tag: TAG20130420T025747
Piece Name: /oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813207467_8q4h3cvp_.bkp
Control File Included: Ckp SCN: 476395 Ckp time: 20-4月 -13
SPFILE Included: Modification time: 20-4月 -13
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
20 Incr 0 529.64M DISK 00:05:25 20-4月 -13
BP Key: 20 Status: AVAILABLE Compressed: NO Tag: TAG20130420T032742
Piece Name: /oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_nnnd0_TAG20130420T032742_8q4jvgyw_.bkp
List of Datafiles in backup set 20
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ---------- ----
1 0 Incr 477469 20-4月 -13 /oracle/ora10g/oradata/wolf/system01.dbf
2 0 Incr 477469 20-4月 -13 /oracle/ora10g/oradata/wolf/undotbs01.dbf
3 0 Incr 477469 20-4月 -13 /oracle/ora10g/oradata/wolf/sysaux01.dbf
4 0 Incr 477469 20-4月 -13 /oracle/ora10g/oradata/wolf/users01.dbf
5 0 Incr 477469 20-4月 -13 /oracle/ora10g/oradata/wolf/rmanwolf.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21 Full 6.80M DISK 00:00:00 20-4月 -13
BP Key: 21 Status: AVAILABLE Compressed: NO Tag: TAG20130420T033318
Piece Name: /oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813209598_8q4k5yqq_.bkp
Control File Included: Ckp SCN: 477636 Ckp time: 20-4月 -13
SPFILE Included: Modification time: 20-4月 -13
RMAN>
一级增量备份(controlfile和spfile都是全备份,没有增量仔细观测)
backup incremental level 1 database 速度也是很慢,因为面里要和0级对比一些信息
RMAN> backup incremental level 1 database
2> ;
Starting backup at 20-4月 -13
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/oracle/ora10g/oradata/wolf/system01.dbf
input datafile fno=00003 name=/oracle/ora10g/oradata/wolf/sysaux01.dbf
input datafile fno=00002 name=/oracle/ora10g/oradata/wolf/undotbs01.dbf
input datafile fno=00005 name=/oracle/ora10g/oradata/wolf/rmanwolf.dbf
input datafile fno=00004 name=/oracle/ora10g/oradata/wolf/users01.dbf
channel ORA_DISK_1: starting piece 1 at 20-4月 -13
channel ORA_DISK_1: finished piece 1 at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_nnnd1_TAG20130420T034525_8q4kwod7_.bkp tag=TAG20130420T034525 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:04:56
Finished backup at 20-4月 -13
Starting Control File and SPFILE Autobackup at 20-4月 -13
piece handle=/oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813210622_8q4l5yy1_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 20-4月 -13
RMAN> list backupset;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
18 Full 529.59M DISK 00:04:53 20-4月 -13
BP Key: 18 Status: AVAILABLE Compressed: NO Tag: TAG20130420T025250
Piece Name: /oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_nnndf_TAG20130420T025250_8q4gt34k_.bkp
List of Datafiles in backup set 18
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ---------- ----
1 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/system01.dbf
2 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/undotbs01.dbf
3 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/sysaux01.dbf
4 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/users01.dbf
5 Full 476267 20-4月 -13 /oracle/ora10g/oradata/wolf/rmanwolf.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
19 Full 6.80M DISK 00:00:01 20-4月 -13
BP Key: 19 Status: AVAILABLE Compressed: NO Tag: TAG20130420T025747
Piece Name: /oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813207467_8q4h3cvp_.bkp
Control File Included: Ckp SCN: 476395 Ckp time: 20-4月 -13
SPFILE Included: Modification time: 20-4月 -13
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
20 Incr 0 529.64M DISK 00:05:25 20-4月 -13
BP Key: 20 Status: AVAILABLE Compressed: NO Tag: TAG20130420T032742
Piece Name: /oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_nnnd0_TAG20130420T032742_8q4jvgyw_.bkp
List of Datafiles in backup set 20
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ---------- ----
1 0 Incr 477469 20-4月 -13 /oracle/ora10g/oradata/wolf/system01.dbf
2 0 Incr 477469 20-4月 -13 /oracle/ora10g/oradata/wolf/undotbs01.dbf
3 0 Incr 477469 20-4月 -13 /oracle/ora10g/oradata/wolf/sysaux01.dbf
4 0 Incr 477469 20-4月 -13 /oracle/ora10g/oradata/wolf/users01.dbf
5 0 Incr 477469 20-4月 -13 /oracle/ora10g/oradata/wolf/rmanwolf.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
21 Full 6.80M DISK 00:00:00 20-4月 -13
BP Key: 21 Status: AVAILABLE Compressed: NO Tag: TAG20130420T033318
Piece Name: /oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813209598_8q4k5yqq_.bkp
Control File Included: Ckp SCN: 477636 Ckp time: 20-4月 -13
SPFILE Included: Modification time: 20-4月 -13
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
22 Incr 1 640.00K DISK 00:04:44 20-4月 -13
BP Key: 22 Status: AVAILABLE Compressed: NO Tag: TAG20130420T034525
Piece Name: /oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_20/o1_mf_nnnd1_TAG20130420T034525_8q4kwod7_.bkp
List of Datafiles in backup set 22
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- ---------- ----
1 1 Incr 478003 20-4月 -13 /oracle/ora10g/oradata/wolf/system01.dbf
2 1 Incr 478003 20-4月 -13 /oracle/ora10g/oradata/wolf/undotbs01.dbf
3 1 Incr 478003 20-4月 -13 /oracle/ora10g/oradata/wolf/sysaux01.dbf
4 1 Incr 478003 20-4月 -13 /oracle/ora10g/oradata/wolf/users01.dbf
5 1 Incr 478003 20-4月 -13 /oracle/ora10g/oradata/wolf/rmanwolf.dbf
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
23 Full 6.80M DISK 00:00:01 20-4月 -13
BP Key: 23 Status: AVAILABLE Compressed: NO Tag: TAG20130420T035022
Piece Name: /oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_20/o1_mf_s_813210622_8q4l5yy1_.bkp
Control File Included: Ckp SCN: 478120 Ckp time: 20-4月 -13
SPFILE Included: Modification time: 20-4月 -13
RMAN>
文章结束给大家分享下程序员的一些笑话语录:
雅虎最擅长的不是开通新业务,是关闭旧业务。