【备份恢复】物理冷备份及恢复

发布时间:2020-08-11 05:58:02 作者:不一样的天空w
来源:ITPUB博客 阅读:142

冷备:,即关闭数据库备份,要求备份数据库三大文件(数据文件、控制文件、日志文件)及参数文件、口令文件同时冷备之前要一致性关库,以触发ckpt实现三大文件一致性,以使恢复数据库是不需要recover

1.查看备份文件绝对路径(重要)

SYS@ORA11GR2>select name from v$datafile;

 

NAME

--------------------------------------------------------/u01/app/oracle/oradata/ORA11GR2/system01.dbf

/u01/app/oracle/oradata/ORA11GR2/sysaux01.dbf

/u01/app/oracle/oradata/ORA11GR2/undotbs01.dbf

/u01/app/oracle/oradata/ORA11GR2/users01.dbf

/u01/app/oracle/oradata/ORA11GR2/example01.dbf

/u01/app/oracle/oradata/ORA11GR2/ts_ora11gr2_01.dbf

/u01/app/oracle/oradata/ORA11GR2/undotbs2_01.dbf

 

7 rows selected.

 

SYS@ORA11GR2>select name from v$controlfile;

 

NAME

--------------------------------------------------------

/u01/app/oracle/oradata/ORA11GR2/control01.ctl

/u01/app/oracle/oradata/ORA11GR2/control02.ctl

/u01/app/FRA/control03.ctl

 

SYS@ORA11GR2>

 

SYS@ORA11GR2>select member from v$logfile;

 

MEMBER

--------------------------------------------------------

/u01/app/oracle/oradata/ORA11GR2/redo03.log

/u01/app/oracle/oradata/ORA11GR2/redo02.log

/u01/app/oracle/oradata/ORA11GR2/redo01.log

/u01/app/oracle/oradata/ORA11GR2/redo01_a.log

/u01/app/oracle/oradata/ORA11GR2/redo02_a.log

/u01/app/oracle/oradata/ORA11GR2/redo03_a.log

/u01/app/FRA/redo01_b.log

/u01/app/FRA/redo02_b.log

/u01/app/FRA/redo03_b.log

 

9 rows selected.

 

SYS@ORA11GR2>

 

2.一致性关闭数据库:(触发CKPT,然后实施备份)

SYS@ORA11GR2>shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SYS@ORA11GR2>

 

3.回到操作系统层复制镜像(所有数据库文件)

——创建备份目录:

[oracle@wang ~]$ mkdir cold

[oracle@wang ~]$ ls

cold

[oracle@wang ~]$ cd cold/

[oracle@wang cold]$ ls

[oracle@wang cold]$

[oracle@wang cold]$ pwd

/home/oracle/cold

 

——备份控制文件、数据文件、redo日志到备份目录:

[oracle@wang ~]$ cd /u01/app/oracle/oradata/

ORA11GR2/ PROD/    

[oracle@wang ~]$ cd /u01/app/oracle/oradata/

[oracle@wang oradata]$

[oracle@wang oradata]$ cd ORA11GR2

[oracle@wang ORA11GR2]$ ls

control01.ctl  redo02.log    ts_ora11gr2_01.dbf

control02.ctl  redo03_a.log  undotbs01.dbf

example01.dbf  redo03.log    undotbs2_01.dbf

redo01_a.log   sysaux01.dbf  users01.dbf

redo01.log     system01.dbf

redo02_a.log   temp01.dbf

[oracle@wang ORA11GR2]$ pwd

/u01/app/oracle/oradata/ORA11GR2

[oracle@wang ORA11GR2]$ cp * /home/oracle/cold/

[oracle@wang ORA11GR2]$

成功,验证:

[oracle@wang cold]$ du -sh

2.3G    .

[oracle@wang cold]$ ll

total 2383092

-rw-r----- 1 oracle oinstall   9748480 Sep 27 15:12 control01.ctl

-rw-r----- 1 oracle oinstall   9748480 Sep 27 15:12 control02.ctl

-rw-r----- 1 oracle oinstall 363077632 Sep 27 15:12 example01.dbf

-rw-r----- 1 oracle oinstall  52429312 Sep 27 15:12 redo01_a.log

-rw-r----- 1 oracle oinstall  52429312 Sep 27 15:12 redo01.log

-rw-r----- 1 oracle oinstall  52429312 Sep 27 15:12 redo02_a.log

-rw-r----- 1 oracle oinstall  52429312 Sep 27 15:12 redo02.log

-rw-r----- 1 oracle oinstall  52429312 Sep 27 15:12 redo03_a.log

-rw-r----- 1 oracle oinstall  52429312 Sep 27 15:12 redo03.log

-rw-r----- 1 oracle oinstall 660611072 Sep 27 15:12 sysaux01.dbf

-rw-r----- 1 oracle oinstall 849354752 Sep 27 15:12 system01.dbf

-rw-r----- 1 oracle oinstall  51388416 Sep 27 15:12 temp01.dbf

-rw-r----- 1 oracle oinstall  20979712 Sep 27 15:12 ts_ora11gr2_01.dbf

-rw-r----- 1 oracle oinstall  94380032 Sep 27 15:12 undotbs01.dbf

-rw-r----- 1 oracle oinstall 104865792 Sep 27 15:12 undotbs2_01.dbf

-rw-r----- 1 oracle oinstall   6561792 Sep 27 15:12 users01.dbf

[oracle@wang cold]$

 

——备份参数文件及口令文件:

[oracle@wang ORA11GR2]$ cd $ORACLE_HOME/dbs

[oracle@wang dbs]$ cp initORA11GR2.ora spfileORA11GR2.ora  /home/oracle/cold/

[oracle@wang dbs]$

[oracle@wang dbs]$ cp orapwORA11GR2 /home/oracle/cold/

验证:

[oracle@wang cold]$ ls initORA11GR2.ora

initORA11GR2.ora      

[oracle@wang cold]$ ls spfileORA11GR2.ora

spfileORA11GR2.ora

[oracle@wang cold]$ ls orapwORA11GR2

orapwORA11GR2

 

4.模拟删除$ORACLE_HOME/dbs的参数文件及密码文件,删除$ORACLE_HOME/oradata/ORA11GR2/下的所有数据库文件

[oracle@wang dbs]$ cd /u01/app/oracle/oradata/ORA11GR2/

[oracle@wang ORA11GR2]$ ls

control01.ctl  example01.dbf  redo01.log    redo02.log    redo03.log    system01.dbf  ts_ora11gr2_01.dbf  undotbs2_01.dbf

control02.ctl  redo01_a.log   redo02_a.log  redo03_a.log  sysaux01.dbf  temp01.dbf    undotbs01.dbf       users01.dbfv

[oracle@wang ORA11GR2]$ rm *

[oracle@wang ORA11GR2]$ ls

[oracle@wang ORA11GR2]$

 

5.启动实例(nomount):

SYS@ORA11GR2>startup nomount;

ORA-01078: failure in processing system parameters

LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initORA11GR2.ora'

SYS@ORA11GR2>

显示没有找到参数文件,恢复参数文件:

[oracle@wang cold]$ cp initORA11GR2.ora spfileORA11GR2.ora /u01/app/oracle/product/11.2.0/dbhome_1/dbs

[oracle@wang cold]$

再次启动实例:

SYS@ORA11GR2>startup nomount;

ORACLE instance started.

 

Total System Global Area  730714112 bytes

Fixed Size                  2256832 bytes

Variable Size             457179200 bytes

Database Buffers          268435456 bytes

Redo Buffers                2842624 bytes

SYS@ORA11GR2>

 

——实例启动

6.启动到mount

SYS@ORA11GR2>alter database mount;

alter database mount

*

ERROR at line 1:

ORA-00205: error in identifying control file, check alert log for more info

 

 

SYS@ORA11GR2>

 

恢复控制文件:

[oracle@wang cold]$ cp control01.ctl control02.ctl  /u01/app/oracle/oradata/ORA11GR2/

[oracle@wang cold]$

[oracle@wang ORA11GR2]$ pwd

/u01/app/oracle/oradata/ORA11GR2

[oracle@wang ORA11GR2]$

[oracle@wang ORA11GR2]$ ls

control01.ctl  control02.ctl

再次启动到mount

SYS@ORA11GR2>alter database mount;

 

Database altered.

 

SYS@ORA11GR2>

成功!

 

7.打开数据库:

SYS@ORA11GR2>alter database open;

alter database open

*

ERROR at line 1:

ORA-01157: cannot identify/lock data file 1 - see DBWR trace file

ORA-01110: data file 1: '/u01/app/oracle/oradata/ORA11GR2/system01.dbf'

 

——恢复数据文件日志文件

[oracle@wang cold]$ cp *dbf *log /u01/app/oracle/oradata/ORA11GR2/

[oracle@wang cold]$

[oracle@wang ORA11GR2]$ ls

control01.ctl  example01.dbf  redo01.log    redo02.log    redo03.log    system01.dbf  ts_ora11gr2_01.dbf  undotbs2_01.dbf

control02.ctl  redo01_a.log   redo02_a.log  redo03_a.log  sysaux01.dbf  temp01.dbf    undotbs01.dbf       users01.dbf

 

——再次打开数据库:

SYS@ORA11GR2>alter database open;

 

Database altered.

 

SYS@ORA11GR2>select status from v$instance;

 

STATUS

------------

OPEN

 

SYS@ORA11GR2>

数据库已打开,恢复成功!!!!!!!!!

(数据库已从冷备恢复回来,不需要recovery,因为冷备是在一致性关闭数据库的基础上实施的,数据库已处于一致状态)

 

 

推荐阅读:
  1. MongoDB备份恢复笔记
  2. WSFC备份恢复

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

备份 恢复 物理

上一篇:[AlwaysOn2017] AlwaysOn的DMV和DMF - Sys.fn_hadr_distributed_ag_replica

下一篇:Linux装Windows系统后还不会激活?3招教你搞定

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》