日期:2014-05-16  浏览次数:20635 次

备份&恢复系列之二:在linux中对oracle用热备份!
测试环境:

1      操作系统:Redhat Linux 6

[oracle@bld-tdb1 ~]$ cat /proc/version
Linux version 2.6.18-164.el5 (mockbuild@x86-003.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Tue Aug 18 15:51:48 EDT 2009

2     数据库版本:Oracle11g


SQL> select * from v$version;

BANNER
--------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

3     数据库的名字:orcl

SQL> show parameter db_name;

.
SQL> show parameter db_name;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      PULSEINP


4    数据库的所有数据文件所在位置
select file#, status, enabled, name from v$datafile;

1 SYSTEM READ WRITE /u01/app/oracle/oradata/PULSEINP/system01.dbf
2 ONLINE READ WRITE /u01/app/oracle/oradata/PULSEINP/sysaux01.dbf
3 ONLINE READ WRITE /u01/app/oracle/oradata/PULSEINP/undotbs01.dbf
4 ONLINE READ WRITE /u01/app/oracle/oradata/PULSEINP/users01.dbf
5 ONLINE READ WRITE /u01/app/oracle/oradata/PULSEINP/user202.dbf


5   控制文件的所在位置
select * from v$controlfile;

/u01/app/oracle/oradata/PULSEINP/control01.ctl NO 16384 594
/u01/app/oracle/flash_recovery_area/PULSEINP/control02.ctl NO 16384 594



6    重做日志文件位置
select * from v$logfile;

ONLINE /u01/app/oracle/oradata/PULSEINP/redo011.log NO
ONLINE /u01/app/oracle/oradata/PULSEINP/redo012.log NO
ONLINE /u01/app/oracle/oradata/PULSEINP/redo021.log NO
ONLINE /u01/app/oracle/oradata/PULSEINP/redo022.log NO
ONLINE /u01/app/oracle/oradata/PULSEINP/redo031.log NO
ONLINE /u01/app/oracle/oradata/PULSEINP/redo032.log NO


7     写个hotbak.sql脚本

脚本内容如下:
#rem script.:hotbak.sql
#rem creater:mengzhaoliang
#rem data:2008/2/4
#rem desc:backup all database datafile in archive
#enter database
$ORACLE_HOME/bin/sqlplus "/as sysdba" <<EOF
alter system archive log current;
#start
alter tablespace system begin backup;
!cp /u01/app/oracle/oradata/PULSEINP/system01.dbf /home/oracle/oraclescript/;
alter tablespace system end backup;

alter tablespace system begin backup;
!cp /u01/app/oracle/oradata/PULSEINP/undotbs01.dbf /home/oracle/oraclescript/;
alter tablespace system end backup;

alter tablespace system begin backup;
!cp /u01/app/oracle/oradata/PULSEINP/users01.dbf /home/oracle/oraclescript/;
alter tablespace system end backup;

alter tablespace system begin backup;
!cp /u01/app/oracle/oradata/PULSEINP/sysaux01.dbf /home/oracle/oraclescript/;
alter tablespace system end backup;

alter tablespace system begin backup;
!cp /u01/app/oracle/oradata/PULSEINP/user202.dbf /home/oracle/oraclescript/;
alter tablespace system end backup;

#backup control file
#binary
alter database backup controlfile to '/home/oracle/oraclescript/controlbinarybackup