如何为Oracle数据库进行备份

来源:互联网 发布:人工智能 电影 简介 编辑:程序博客网 时间:2024/05/25 05:34

冷备份发生在数据库已经正常关闭的情况下,当正常关闭时会提供给我们一个完整的数据库。
数据库使用的每个文件都被备份下来,这些文件包括:
☆所有数据文件
☆所有控制文件
☆所有联机REDO LOG 文件
☆INIT.ORA文件(可选)
值得注意的是冷备份必须是数据库关闭的情况下完成,当数据库开着的时候,执行数据库文件系统备份无效。
作冷备份一般步骤是:
1:正常关闭要备份的实例(instance);
2: 备份整个数据库到一个目录
3:启动数据库
1: SQLDBA>connect internal
SQLDBA>shutdown normal
2: SQLDBA>! cp

SQLDBA>!tar cvf /dev/rmt/0 /wwwdg/oracle
3: SQLDBA>startup

(三)热备份(ACHIRELOG)
数据库需要二十四小时运行,而且随时有新的数据加入.数据丢失将影响整个公司.采用archivelog mode物理备份.
?设置数据库为automatic archivelog mode,
#su - oracle
%svrmgrl
svrmgrl>connect internal
svrmgrl>startup mount
svrmgrl>alter database archivelog
svrmgrl>shutdown
svrmgrl>exit
%vi initoracle7.ora
加入log_archive_start = true # if you want automatic archiving
log_archive_dest = $ORACLE_HOME/dbs/arch
log_archive_format = log%s.arc
%dbstart
%ps -ef|grep arch
oracle 1743 1 0 15:20:20 ? 0:00 ora_arch_oracle7
注:oracle database is in automatic archivelog mode

?full offline entire database backup, 当数据库初始完成后 这份备份是将来备份的基础。它提供了所有与数据库有关
的拷贝.
%dbshut
%cp /oracle/oradata/oracle7/system.dbf
/oracle/oradata/oracle7/rbs.dbf
/oracle/oradata/oracle7/temp.dbf
/oracle/oradata/oracle7/tools.dbf
/oracle/oradata/oracle7/users.dbf
/oraclecle/app/oracle/product/7.3.2/dbs/application.dbf
/oracle/app/oracle/product/7.3.2/dbs/apptmpsp.dbf
/oracle/app/oracle/product/7.3.2/dbs/apprlbksp.dbf
/oracle/oradata/oracle7/redooracle.log
/oracle/oradata/oracle7/control1.ctl
/oracle/oradata/oracle7/control2.ctl
/oracle/oradata/oracle7/control3.ctl

%dbstart
注:以上*.dbf文件为数据文件,*.log文件为日志文件,*.ctl文件为控制文件
%exit
%tar uvf /dev/rmt/0
注:如果为oracle 7.2 ,则copy 相应的 data files,relog files,control files.

6.3、每天做一次 partial online with archiving backups .
#su - oracle
%svrmgrl
%svrmgrl>connect internal
%svrmgrl>alter tablespace billsp begin backup
%svrmgrl>alter tablespace billtmpsp begin backup
%svrmgrl>alter tablespace billrlbksp begin backup
%svrmgrl>alter tablespace system begin backup
%svrmgrl>alter tablespace rbs begin backup
%svrmgrl>alter tablespace temp begin backup
%svrmgrl>alter tablespace tools begin backup
%svrmgrl>alter tablespace users begin backup
%svrmgrl>host cp all datafile to the backup storage. #文件名如第一步中以.dbf结尾的.
%svrmgrl>alter tablespace billsp end backup
%svrmgrl>alter tablespace billtmpsp end backup
%svrmgrl>alter tablespace billrlbksp end backup
%svrmgrl>alter tablespace system end backup
%svrmgrl>alter tablespace rbs end backup
%svrmgrl>alter tablespace temp end backup
%svrmgrl>alter tablespace tools end backup
%svrmgrl>alter tablespace users end backup

做一个sql文件,如上所写.

The billing system can recover to the point of failure when the failure occur.

原创粉丝点击