测试环境:
1 操作系统:Redhat Linux 6
[oracle@bld-tdb1 ~]$ cat /proc/version
Linux version 2.6.18-164.el5 (
[email protected]) (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';
#ascii
alter database backup controlfile to trace;
alter system archive log current;
<<EOF
附上piner的说明:
说明:
1、热备份必须在数据库归档方式下才可以运行
2、以上脚本可以在数据库运行状态下备份数据库所有的数据文件(除了临时数据文件),没有必要备份联机日志。
3、归档日志至少需要一次完整备份之后的所有日志。
4、如果以上命令没有成功依次执行,那么备份也是无效的,如连接数据库不成功,那么备份则无效。