您的位置:首页 > 数据库 > Oracle

oracle rac rman backup,recover(archive log-share storage)

2010-08-15 19:53 399 查看
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>

第二步:破坏数据文件

[root@h2 ~]# dd if=/dev/raw/raw12 of=/root/usersbak
1024000+0 records in
1024000+0 records out
[root@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
[root@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
[root@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
[root@h2 ~]#

第三步:测试数据库状态

[root@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->
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: