设为首页 收藏本站
查看: 428|回复: 0

[经验分享] oracle rac rman backup,recover(archive log-share storage)

[复制链接]

尚未签到

发表于 2016-8-7 07:07:14 | 显示全部楼层 |阅读模式
  archive log 目录为共享存储:/ocfs/archivelog
  
  第一步:数据库全备
  
  RMAN> run{
2> allocate channel ch0 type disk maxpiecesize 300m rate 1m;
3> allocate channel ch1 type disk maxpiecesize 300m rate 1m;
4> allocate channel ch2 type disk maxpiecesize 300m rate 1m;
5> allocate channel ch3 type disk maxpiecesize 300m rate 1m;
6> backup format ='/home/oracle/db_%T_%t_%U.bak' full database;
7> backup format ='/home/oracle/arch_%T_%t_%U.bak' archivelog all;
8> sql 'alter system switch logfile';
9> backup format ='/home/oracle/control_%T_%t_%U.bak' current controlfile;
10> release channel ch0;
11> release channel ch1;
12> release channel ch2;
13> release channel ch3;
14> }
  using target database control file instead of recovery catalog
allocated channel: ch0
channel ch0: sid=130 instance=demo1 devtype=DISK
  allocated channel: ch1
channel ch1: sid=128 instance=demo1 devtype=DISK
  allocated channel: ch2
channel ch2: sid=129 instance=demo1 devtype=DISK
  allocated channel: ch3
channel ch3: sid=127 instance=demo1 devtype=DISK
  Starting backup at 31-JUL-10
channel ch0: starting full datafile backupset
channel ch0: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/oradata/demo/system_dbf1
channel ch0: starting piece 1 at 31-JUL-10
channel ch1: starting full datafile backupset
channel ch1: specifying datafile(s) in backupset
input datafile fno=00003 name=/u01/oradata/demo/sysaux_dbf1
input datafile fno=00004 name=/u01/oradata/demo/users_dbf1
channel ch1: starting piece 1 at 31-JUL-10
channel ch2: starting full datafile backupset
channel ch2: specifying datafile(s) in backupset
input datafile fno=00002 name=/u01/oradata/demo/undotbs_dbf1
input datafile fno=00005 name=/u01/oradata/demo/undotbs_dbf2
channel ch2: starting piece 1 at 31-JUL-10
channel ch3: starting full datafile backupset
channel ch3: specifying datafile(s) in backupset
including current control file in backupset
channel ch3: starting piece 1 at 31-JUL-10
channel ch3: finished piece 1 at 31-JUL-10
piece handle=/home/oracle/db_20100731_725805543_04lk5qf7_1_1.bak tag=TAG20100731T123901 comment=NONE
channel ch3: backup set complete, elapsed time: 00:00:16
channel ch3: throttle time: 0:00:12
channel ch3: starting full datafile backupset
channel ch3: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ch3: starting piece 1 at 31-JUL-10
channel ch3: finished piece 1 at 31-JUL-10
piece handle=/home/oracle/db_20100731_725805560_05lk5qfo_1_1.bak tag=TAG20100731T123901 comment=NONE
channel ch3: backup set complete, elapsed time: 00:00:02
channel ch2: finished piece 1 at 31-JUL-10
piece handle=/home/oracle/db_20100731_725805542_03lk5qf6_1_1.bak tag=TAG20100731T123901 comment=NONE
channel ch2: backup set complete, elapsed time: 00:01:05
channel ch2: throttle time: 0:00:50
^[[A
channel ch1: finished piece 1 at 31-JUL-10
piece handle=/home/oracle/db_20100731_725805542_02lk5qf6_1_1.bak tag=TAG20100731T123901 comment=NONE
channel ch1: backup set complete, elapsed time: 00:05:00
channel ch1: throttle time: 0:04:51
channel ch0: finished piece 1 at 31-JUL-10
piece handle=/home/oracle/db_20100731_725805542_01lk5qf6_1_1.bak tag=TAG20100731T123901 comment=NONE
channel ch0: starting piece 2 at 31-JUL-10
channel ch0: finished piece 2 at 31-JUL-10
piece handle=/home/oracle/db_20100731_725805542_01lk5qf6_2_1.bak tag=TAG20100731T123901 comment=NONE
channel ch0: backup set complete, elapsed time: 00:08:00
channel ch0: throttle time: 0:07:47
Finished backup at 31-JUL-10
  Starting backup at 31-JUL-10
current log archived
channel ch0: starting archive log backupset
channel ch0: specifying archive log(s) in backup set
input archive log thread=2 sequence=46 recid=4 stamp=725751630
input archive log thread=2 sequence=47 recid=6 stamp=725752124
input archive log thread=2 sequence=48 recid=7 stamp=725796565
input archive log thread=2 sequence=49 recid=8 stamp=725796646
channel ch0: starting piece 1 at 31-JUL-10
channel ch1: starting archive log backupset
channel ch1: specifying archive log(s) in backup set
input archive log thread=1 sequence=94 recid=10 stamp=725798518
input archive log thread=1 sequence=95 recid=12 stamp=725803120
input archive log thread=1 sequence=96 recid=16 stamp=725806025
input archive log thread=2 sequence=45 recid=1 stamp=725750992
channel ch1: starting piece 1 at 31-JUL-10
channel ch2: starting archive log backupset
channel ch2: specifying archive log(s) in backup set
input archive log thread=2 sequence=50 recid=11 stamp=725798580
input archive log thread=2 sequence=51 recid=13 stamp=725803440
input archive log thread=2 sequence=52 recid=14 stamp=725805178
input archive log thread=2 sequence=53 recid=15 stamp=725806025
channel ch2: starting piece 1 at 31-JUL-10
channel ch3: starting archive log backupset
channel ch3: specifying archive log(s) in backup set
input archive log thread=1 sequence=90 recid=2 stamp=725750992
input archive log thread=1 sequence=91 recid=3 stamp=725751547
input archive log thread=1 sequence=92 recid=5 stamp=725752054
input archive log thread=1 sequence=93 recid=9 stamp=725796653
channel ch3: starting piece 1 at 31-JUL-10
channel ch3: finished piece 1 at 31-JUL-10
piece handle=/home/oracle/arch_20100731_725806029_09lk5qud_1_1.bak tag=TAG20100731T124708 comment=NONE
channel ch3: backup set complete, elapsed time: 00:00:04
channel ch3: throttle time: 0:00:02
channel ch2: finished piece 1 at 31-JUL-10
piece handle=/home/oracle/arch_20100731_725806029_08lk5qud_1_1.bak tag=TAG20100731T124708 comment=NONE
channel ch2: backup set complete, elapsed time: 00:00:07
channel ch2: throttle time: 0:00:04
channel ch1: finished piece 1 at 31-JUL-10
piece handle=/home/oracle/arch_20100731_725806029_07lk5qud_1_1.bak tag=TAG20100731T124708 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:10
channel ch1: throttle time: 0:00:08
channel ch0: finished piece 1 at 31-JUL-10
piece handle=/home/oracle/arch_20100731_725806029_06lk5qud_1_1.bak tag=TAG20100731T124708 comment=NONE
channel ch0: backup set complete, elapsed time: 00:00:13
channel ch0: throttle time: 0:00:11
Finished backup at 31-JUL-10
  sql statement: alter system switch logfile
  Starting backup at 31-JUL-10
channel ch0: starting full datafile backupset
channel ch0: specifying datafile(s) in backupset
including current control file in backupset
channel ch0: starting piece 1 at 31-JUL-10
channel ch0: finished piece 1 at 31-JUL-10
piece handle=/home/oracle/control_20100731_725806045_0alk5qut_1_1.bak tag=TAG20100731T124725 comment=NONE
channel ch0: backup set complete, elapsed time: 00:00:16
channel ch0: throttle time: 0:00:13
Finished backup at 31-JUL-10
  released channel: ch0
  released channel: ch1
  released channel: ch2
  released channel: ch3
  RMAN>
  
  
  第二步:破坏数据文件
  
  [iyunv@h2 ~]# dd if=/dev/raw/raw12 of=/root/usersbak
1024000+0 records in
1024000+0 records out
[iyunv@h2 ~]# dd if=/dev/zero of=/dev/raw/raw12
dd: writing to `/dev/raw/raw12': No space left on device
1024001+0 records in
1024000+0 records out
[iyunv@h2 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 49G 8.9G 38G 20% /
/dev/sda1 99M 12M 83M 13% /boot
none 345M 0 345M 0% /dev/shm
/dev/sdg1 3.0G 294M 2.8G 10% /ocfs
[iyunv@h2 ~]# ll
total 516920
-rw-r--r-- 1 root root 1229 May 22 16:23 anaconda-ks.cfg
-rwxr-xr-x 1 root root 23 May 22 21:02 date.sh
drwxr-xr-x 2 root root 4096 May 22 16:28 Desktop
-rw-r--r-- 1 root root 59020 May 22 16:23 install.log
-rw-r--r-- 1 root root 81301 May 22 16:23 install.log.syslog
-rw-r--r-- 1 root root 3014745 Jul 29 07:40 ocfs2-2.6.9-42.ELsmp-1.2.3-1.i686.rpm
-rw-r--r-- 1 root root 177275 Jul 29 07:41 ocfs2console-1.2.2-1.i386.rpm
-rw-r--r-- 1 root root 1036426 Jul 29 07:41 ocfs2-tools-1.2.2-1.i386.rpm
-rw-r--r-- 1 root root 90012 Jul 8 05:35 ocrdmp.dmp
-rw-r--r-- 1 root root 524288000 Jul 31 13:45 usersbak
[iyunv@h2 ~]#
  
  
  第三步:测试数据库状态
  
  [iyunv@h1 bin]# su - oracle
h1-> crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....MFBK.cs application ONLINE OFFLINE
ora....mo1.srv application ONLINE OFFLINE
ora....mo2.srv application ONLINE OFFLINE
ora.demo.db application ONLINE OFFLINE
ora....o1.inst application ONLINE OFFLINE
ora....o2.inst application ONLINE OFFLINE
ora....H1.lsnr application ONLINE ONLINE h1
ora.h1.gsd application ONLINE ONLINE h1
ora.h1.ons application ONLINE ONLINE h1
ora.h1.vip application ONLINE ONLINE h1
ora....H2.lsnr application ONLINE OFFLINE
ora.h2.gsd application ONLINE OFFLINE
ora.h2.ons application ONLINE OFFLINE
ora.h2.vip application ONLINE ONLINE h1
h1-> sqlplus / as sysdba
  SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jul 31 13:59:18 2010
  Copyright (c) 1982, 2005, Oracle. All rights reserved.
  Connected to an idle instance.
  demo1>startup nomount;
ORACLE instance started.
  Total System Global Area 184549376 bytes
Fixed Size 1218388 bytes
Variable Size 117442732 bytes
Database Buffers 58720256 bytes
Redo Buffers 7168000 bytes
demo1>alter database mount;
  Database altered.
  demo1>alter database open;
alter database open
*
ERROR at line 1:
ORA-01122: database file 4 failed verification check
ORA-01110: data file 4: '/u01/oradata/demo/users_dbf1'
ORA-01251: Unknown File Header Version read for file number 4
  
demo1>exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
h1-> sqlplus / as sysdba
  SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jul 31 14:00:10 2010
  Copyright (c) 1982, 2005, Oracle. All rights reserved.
  
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
  demo1>select instance_name,status from gv$instance;
  INSTANCE_NAME STATUS
---------------- ------------
demo1 MOUNTED
  demo1>
  
  
  
  
  第四步:recover:
  
  h1->
h1->
h1-> rman target /
  Recovery Manager: Release 10.2.0.1.0 - Production on Sat Jul 31 14:00:33 2010
  Copyright (c) 1982, 2005, Oracle. All rights reserved.
  connected to target database: DEMO (DBID=3463775362, not open)
  RMAN> run{
2> allocate channel ch0 type disk;
3> allocate channel ch1 type disk;
4> allocate channel ch2 type disk;
5> allocate channel ch3 type disk;
6> restore database;
7> recover database;
8> release channel ch0;
9> release channel ch1;
10> release channel ch2;
11> release channel ch3;
12> }
  using target database control file instead of recovery catalog
allocated channel: ch0
channel ch0: sid=145 instance=demo1 devtype=DISK
  allocated channel: ch1
channel ch1: sid=144 instance=demo1 devtype=DISK
  allocated channel: ch2
channel ch2: sid=143 instance=demo1 devtype=DISK
  allocated channel: ch3
channel ch3: sid=142 instance=demo1 devtype=DISK
  Starting restore at 31-JUL-10
  channel ch0: starting datafile backupset restore
channel ch0: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /u01/oradata/demo/undotbs_dbf1
restoring datafile 00005 to /u01/oradata/demo/undotbs_dbf2
channel ch0: reading from backup piece /home/oracle/db_20100731_725805542_03lk5qf6_1_1.bak
channel ch1: starting datafile backupset restore
channel ch1: specifying datafile(s) to restore from backup set
restoring datafile 00003 to /u01/oradata/demo/sysaux_dbf1
restoring datafile 00004 to /u01/oradata/demo/users_dbf1
channel ch1: reading from backup piece /home/oracle/db_20100731_725805542_02lk5qf6_1_1.bak
channel ch2: starting datafile backupset restore
channel ch2: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/oradata/demo/system_dbf1
channel ch2: reading from backup piece /home/oracle/db_20100731_725805542_01lk5qf6_1_1.bak
channel ch0: restored backup piece 1
piece handle=/home/oracle/db_20100731_725805542_03lk5qf6_1_1.bak tag=TAG20100731T123901
channel ch0: restore complete, elapsed time: 00:00:03
channel ch1: restored backup piece 1
piece handle=/home/oracle/db_20100731_725805542_02lk5qf6_1_1.bak tag=TAG20100731T123901
channel ch1: restore complete, elapsed time: 00:00:19
channel ch2: restored backup piece 1
piece handle=/home/oracle/db_20100731_725805542_01lk5qf6_1_1.bak tag=TAG20100731T123901
channel ch2: reading from backup piece /home/oracle/db_20100731_725805542_01lk5qf6_2_1.bak
channel ch2: restored backup piece 2
piece handle=/home/oracle/db_20100731_725805542_01lk5qf6_2_1.bak tag=TAG20100731T123901
channel ch2: restore complete, elapsed time: 00:00:25
Finished restore at 31-JUL-10
  Starting recover at 31-JUL-10
  starting media recovery
  archive log thread 1 sequence 96 is already on disk as file /ocfs/archivelog/1_96_719705029.dbf
archive log thread 1 sequence 97 is already on disk as file /ocfs/archivelog/1_97_719705029.dbf
archive log thread 2 sequence 53 is already on disk as file /ocfs/archivelog/2_53_719705029.dbf
archive log filename=/ocfs/archivelog/1_96_719705029.dbf thread=1 sequence=96
archive log filename=/ocfs/archivelog/2_53_719705029.dbf thread=2 sequence=53
media recovery complete, elapsed time: 00:00:05
Finished recover at 31-JUL-10
  released channel: ch0
  released channel: ch1
  released channel: ch2
  released channel: ch3
  RMAN> alter database open;
  database opened
  RMAN> exit
  
Recovery Manager complete.
h1-> sqlplus / as sysdba
  SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jul 31 14:02:48 2010
  Copyright (c) 1982, 2005, Oracle. All rights reserved.
  
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
  demo1>select instance_name,status from gv$instance;
  INSTANCE_NAME STATUS
---------------- ------------
demo1 OPEN
  demo1>exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
h1-> srvctl enable instance -d demo -i demo1
PRKP-1017 : Instance demo1 already enabled.
h1-> srvctl enable instance -d demo -i demo2
PRKP-1017 : Instance demo2 already enabled.
h1-> crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....MFBK.cs application ONLINE OFFLINE
ora....mo1.srv application ONLINE OFFLINE
ora....mo2.srv application ONLINE OFFLINE
ora.demo.db application ONLINE ONLINE h1
ora....o1.inst application ONLINE ONLINE h1
ora....o2.inst application ONLINE OFFLINE
ora....H1.lsnr application ONLINE ONLINE h1
ora.h1.gsd application ONLINE ONLINE h1
ora.h1.ons application ONLINE ONLINE h1
ora.h1.vip application ONLINE ONLINE h1
ora....H2.lsnr application ONLINE OFFLINE
ora.h2.gsd application ONLINE OFFLINE
ora.h2.ons application ONLINE OFFLINE
ora.h2.vip application ONLINE ONLINE h1
h1-> crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....MFBK.cs application ONLINE ONLINE h2
ora....mo1.srv application ONLINE ONLINE h1
ora....mo2.srv application ONLINE ONLINE h2
ora.demo.db application ONLINE ONLINE h1
ora....o1.inst application ONLINE ONLINE h1
ora....o2.inst application ONLINE ONLINE h2
ora....H1.lsnr application ONLINE ONLINE h1
ora.h1.gsd application ONLINE ONLINE h1
ora.h1.ons application ONLINE ONLINE h1
ora.h1.vip application ONLINE ONLINE h1
ora....H2.lsnr application ONLINE ONLINE h2
ora.h2.gsd application ONLINE ONLINE h2
ora.h2.ons application ONLINE ONLINE h2
ora.h2.vip application ONLINE ONLINE h2
h1-> crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora....MFBK.cs application ONLINE ONLINE h2
ora....mo1.srv application ONLINE ONLINE h1
ora....mo2.srv application ONLINE ONLINE h2
ora.demo.db application ONLINE ONLINE h1
ora....o1.inst application ONLINE ONLINE h1
ora....o2.inst application ONLINE ONLINE h2
ora....H1.lsnr application ONLINE ONLINE h1
ora.h1.gsd application ONLINE ONLINE h1
ora.h1.ons application ONLINE ONLINE h1
ora.h1.vip application ONLINE ONLINE h1
ora....H2.lsnr application ONLINE ONLINE h2
ora.h2.gsd application ONLINE ONLINE h2
ora.h2.ons application ONLINE ONLINE h2
ora.h2.vip application ONLINE ONLINE h2
h1-> sqlplus test/test
  SQL*Plus: Release 10.2.0.1.0 - Production on Sat Jul 31 14:07:14 2010
  Copyright (c) 1982, 2005, Oracle. All rights reserved.
  
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
  demo1>select object_name from user_objects;
  OBJECT_NAME
--------------------------------------------------------------------------------
T_COUNT
T_RMAN
  demo1>select * from t_count;
  A B
---------- --------------------
49824
1 a
2 b
  demo1>exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options
h1->

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-254139-1-1.html 上篇帖子: Oracle 高水位(HWM: High Water Mark) 说明 下篇帖子: 用Pl*SQL将Excel中数据导入到oracle中,将oracle的数据通过Pl*SQL导向Excel
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表