oracle 10g rman备份与恢复之一
一、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'; # defaul