Chinaunix首页 | 论坛 | 博客
  • 博客访问: 411691
  • 博文数量: 65
  • 博客积分: 2711
  • 博客等级: 少校
  • 技术积分: 745
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-02 10:02
文章分类

全部博文(65)

文章存档

2013年(4)

2012年(3)

2011年(24)

2010年(21)

2009年(11)

2008年(2)

分类: Oracle

2010-05-21 16:33:43

系统环境:
    主数据库:
        操作系统:REDHAT-AS4-U7
        数据库:ORACLE10.2.0.4
        ip地址:192.168.1.221
        目录结构:
            软件目录:/opt/oracle/product/10.2.0
            数据文件目录:/u00/oracle/standbydb
            ORACLE_SID:standbydb
        
    目标数据库:
        操作系统:REDHAT-AS4-U7
        数据库:ORACLE10.2.0.4
        ip地址:192.168.1.220
            软件目录:/opt/oracle/product/10.2.0
            数据文件目录:/u00/oracle/standbydb
            ORACLE_SID:standbydb
备份路径使用NFS共享,分别在两台服务器上创建相同的路径进行挂载:
mount -t nfs 192.168.1.241:/u03/share /u00/dbbackup
 
第一步:手动准备目标数据库存放路径、配置信息
1、手动创建数据库信息目录
[oracle@dmtzlk arch]$ cd /opt
[oracle@dmtzlk opt]$ ls
oracle  oraInventory  ORCLfmap  sun
[oracle@dmtzlk opt]$ cd oracle/
[oracle@dmtzlk oracle]$ ls
admin  oradata  oraInventory  product
[oracle@dmtzlk oracle]$ cd admin/
[oracle@dmtzlk admin]$ pwd
/opt/oracle/admin
[oracle@dmtzlk admin]$ mkdir racbydb
[oracle@dmtzlk admin]$ cd racbydb
[oracle@dmtzlk admin]$ mkdir adump
[oracle@dmtzlk admin]$ mkdir bdump
[oracle@dmtzlk admin]$ mkdir cdump
[oracle@dmtzlk admin]$ mkdir dpdump
[oracle@dmtzlk admin]$ mkdir udump
[oracle@dmtzlk admin]$ mkdir pfile
[oracle@dmtzlk racbydb]$ ls
adump  bdump  cdump  dpdump  pfile  udump
[oracle@dmtzlk racbydb]$ cd /home/oradatabase/datafile/
[oracle@dmtzlk admin]$ mkdir racbydb
[oracle@dmtzlk datafile]$ ls
racbydb
[oracle@dmtzlk datafile]$ cd
2、拷贝主数据库pfile文件到目标数据库,更改名称
登陆主数据库:
[oracle@db-standby ~]$ cd /opt/oracle/admin/standbydb/pfile/
[oracle@db-standby pfile]$ ls
init.ora.standbydb  sqlnet.log
[oracle@db-standby pfile]$ scp init.ora.standbydb
password:
init.ora.standbydb                            100% 2913     2.8KB/s   00:00   
[oracle@db-standby pfile]$
由于该试验两台服务器目录结构、oracle环境等均一样,因此不需要修改init参数文件。

3、创建数据库密码文件,注意密码文件名称格式及sys密码要与主数据库相同:
orapwd file=/opt/oracle/product/10.2.0/dbs/orapwracbydb password=aaa entries=30

第二步、对主库做rman零级备份。(该步骤备份piece号同恢复时候不一样,是因为实验过程中反复做了几次,对过程没有影响。)
RMAN> show all;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u00/dbbackup/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT   '/u00/dbbackup/%U';
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/opt/oracle/product/10.2.0/dbs/snapcf_standbydb.f'; # default
RMAN>    run{
2>     allocate channel c1 type disk '/u00/dbbackup/standbydb%U';
3>     allocate channel c2 type disk '/u00/dbbackup/standbydb%U';
4>     allocate channel c3 type disk '/u00/dbbackup/standbydb%U';
5>     backup incremental level 0 format '/u00/dbbackup/standbydb%U' database skip readonly;
7>     release channel c1;
8>     release channel c2;
9>     release channel c3;
10>     }
released channel: ORA_DISK_1
allocated channel: c1
channel c1: sid=144 devtype=DISK
allocated channel: c2
channel c2: sid=143 devtype=DISK
allocated channel: c3
channel c3: sid=138 devtype=DISK
Starting backup at 2010-05-20 15:49:56
channel c1: starting incremental level 0 datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00004 name=/u00/oracle/standbydb/users01.dbf
channel c1: starting piece 1 at 2010-05-20 15:49:57
channel c2: starting incremental level 0 datafile backupset
channel c2: specifying datafile(s) in backupset
input datafile fno=00001 name=/u00/oracle/standbydb/system01.dbf
input datafile fno=00002 name=/u00/oracle/standbydb/undotbs01.dbf
input datafile fno=00003 name=/u00/oracle/standbydb/sysaux01.dbf
channel c2: starting piece 1 at 2010-05-20 15:49:57
channel c3: starting incremental level 0 datafile backupset
channel c3: specifying datafile(s) in backupset
input datafile fno=00012 name=/u00/oracle/standbydb/lizi.dbf
input datafile fno=00005 name=/u00/oracle/standbydb/example01.dbf
input datafile fno=00007 name=/u00/oracle/standbydb/rman.dbf
channel c3: starting piece 1 at 2010-05-20 15:49:57
channel c1: finished piece 1 at 2010-05-20 15:50:00
piece handle=/u00/dbbackup/standbydb09le5m95_1_1 tag=TAG20100520T154956 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:03
channel c3: finished piece 1 at 2010-05-20 15:50:00
piece handle=/u00/dbbackup/standbydb0ble5m95_1_1 tag=TAG20100520T154956 comment=NONE
channel c3: backup set complete, elapsed time: 00:00:03
channel c2: finished piece 1 at 2010-05-20 15:53:35
piece handle=/u00/dbbackup/standbydb0ale5m95_1_1 tag=TAG20100520T154956 comment=NONE
channel c2: backup set complete, elapsed time: 00:03:38
Finished backup at 2010-05-20 15:53:35
Starting Control File and SPFILE Autobackup at 2010-05-20 15:53:35
piece handle=/u00/dbbackup/c-131143223-20100520-01 comment=NONE
Finished Control File and SPFILE Autobackup at 2010-05-20 15:53:39
released channel: c1
released channel: c2
released channel: c3
RMAN> list backup;

List of Backup Sets
===================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
9       Incr 0  240.00K    DISK        00:00:01     2010-05-20 15:49:58
        BP Key: 13   Status: AVAILABLE  Compressed: NO  Tag: TAG20100520T154956
        Piece Name: /u00/dbbackup/standbydb0ble5m95_1_1
  List of Datafiles in backup set 9
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  5    0  Incr 66525171   2010-05-20 15:49:57 /u00/oracle/standbydb/example01.dbf
  7    0  Incr 66525171   2010-05-20 15:49:57 /u00/oracle/standbydb/rman.dbf
  12   0  Incr 66525171   2010-05-20 15:49:57 /u00/oracle/standbydb/lizi.dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
10      Incr 0  1.20M      DISK        00:00:01     2010-05-20 15:49:58
        BP Key: 14   Status: AVAILABLE  Compressed: NO  Tag: TAG20100520T154956
        Piece Name: /u00/dbbackup/standbydb09le5m95_1_1
  List of Datafiles in backup set 10
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  4    0  Incr 66525169   2010-05-20 15:49:57 /u00/oracle/standbydb/users01.dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
11      Incr 0  714.02M    DISK        00:03:34     2010-05-20 15:53:31
        BP Key: 15   Status: AVAILABLE  Compressed: NO  Tag: TAG20100520T154956
        Piece Name: /u00/dbbackup/standbydb0ale5m95_1_1
  List of Datafiles in backup set 11
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1    0  Incr 66525170   2010-05-20 15:49:57 /u00/oracle/standbydb/system01.dbf
  2    0  Incr 66525170   2010-05-20 15:49:57 /u00/oracle/standbydb/undotbs01.dbf
  3    0  Incr 66525170   2010-05-20 15:49:57 /u00/oracle/standbydb/sysaux01.dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
12      Full    7.11M      DISK        00:00:02     2010-05-20 15:53:37
        BP Key: 16   Status: AVAILABLE  Compressed: NO  Tag: TAG20100520T155335
        Piece Name: /u00/dbbackup/c-131143223-20100520-01
  Control File Included: Ckp SCN: 66525279     Ckp time: 2010-05-20 15:53:35
  SPFILE Included: Modification time: 2010-05-14 16:47:44
RMAN> exit

Recovery Manager complete.
 
第三步、对目标数据库进行恢复
[oracle@db-primary pfile]$ pwd
/opt/oracle/admin/standbydb/pfile
[oracle@db-primary pfile]$ ls
init.ora.standbydb
[oracle@db-primary pfile]$ sqlplus '/as sysdba'
SQL*Plus: Release 10.2.0.4.0 - Production on Thu May 20 15:57:21 2010
Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.
Connected to an idle instance.
SQL> create spfile from pfile='/opt/oracle/admin/standbydb/pfile/init.ora.standbydb';
File created.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@db-primary 220]$
[oracle@db-standby 220]$ rman target
Recovery Manager: Release 10.2.0.4.0 - Production on Fri May 21 13:02:15 2010
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
connected to target database (not started)
 
RMAN> set dbid=131143223;
 
-----------------------------------
必须设置dbid,否则会出现意想不到的错误,我在实验过程中报错:RMAN-06054: media recovery requesting unknown log: thread 1 seq 9 lowscn
-----------------------------------
 
 
executing command: SET DBID
RMAN> startup nomount;
Oracle instance started
Total System Global Area    1073741824 bytes
Fixed Size                     2089400 bytes
Variable Size                264244808 bytes
Database Buffers             801112064 bytes
Redo Buffers                   6295552 bytes
RMAN> list backup;
using target database control file instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of list command at 05/21/2010 13:07:16
ORA-01507: database not mounted
RMAN>     run
2>     {
3>       set controlfile autobackup format for device type disk to '/u00/dbbackup/%F';
4>       restore controlfile from autobackup;
5>      }
executing command: SET CONTROLFILE AUTOBACKUP FORMAT
Starting restore at 2010-05-21 13:08:04
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
recovery area destination: /u00/flash
database name (or database unique name) used for search: SBYDB
channel ORA_DISK_1: no autobackups found in the recovery area
channel ORA_DISK_1: looking for autobackup on day: 20100521
channel ORA_DISK_1: autobackup found: /u00/dbbackup/c-131143223-20100521-03
channel ORA_DISK_1: control file restore from autobackup complete
output filename=/u00/oracle/standbydb/control01.ctl
output filename=/u00/oracle/standbydb/control02.ctl
output filename=/u00/oracle/standbydb/control03.ctl
Finished restore at 2010-05-21 13:08:08
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> list backup;

List of Backup Sets
===================
BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
28      Incr 0  1.20M      DISK        00:00:01     2010-05-21 12:55:02
        BP Key: 32   Status: AVAILABLE  Compressed: NO  Tag: TAG20100521T125501
        Piece Name: /u00/dbbackup/standbydb0tle80d5_1_1
  List of Datafiles in backup set 28
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  4    0  Incr 66598375   2010-05-21 12:55:01 /u00/oracle/standbydb/users01.dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
29      Incr 0  240.00K    DISK        00:00:01     2010-05-21 12:55:02
        BP Key: 33   Status: AVAILABLE  Compressed: NO  Tag: TAG20100521T125501
        Piece Name: /u00/dbbackup/standbydb0vle80d5_1_1
  List of Datafiles in backup set 29
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  5    0  Incr 66598377   2010-05-21 12:55:01 /u00/oracle/standbydb/example01.dbf
  7    0  Incr 66598377   2010-05-21 12:55:01 /u00/oracle/standbydb/rman.dbf
  12   0  Incr 66598377   2010-05-21 12:55:01 /u00/oracle/standbydb/lizi.dbf
BS Key  Type LV Size       Device Type Elapsed Time Completion Time   
------- ---- -- ---------- ----------- ------------ -------------------
30      Incr 0  732.00M    DISK        00:01:39     2010-05-21 12:56:40
        BP Key: 34   Status: AVAILABLE  Compressed: NO  Tag: TAG20100521T125501
        Piece Name: /u00/dbbackup/standbydb0ule80d5_1_1
  List of Datafiles in backup set 30
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1    0  Incr 66598376   2010-05-21 12:55:01 /u00/oracle/standbydb/system01.dbf
  2    0  Incr 66598376   2010-05-21 12:55:01 /u00/oracle/standbydb/undotbs01.dbf
  3    0  Incr 66598376   2010-05-21 12:55:01 /u00/oracle/standbydb/sysaux01.dbf
RMAN> restore database;
Starting restore at 2010-05-21 13:09:22
Starting implicit crosscheck backup at 2010-05-21 13:09:22
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 2010-05-21 13:09:23
Starting implicit crosscheck copy at 2010-05-21 13:09:23
using channel ORA_DISK_1
Finished implicit crosscheck copy at 2010-05-21 13:09:23
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /u00/oracle/standbydb/users01.dbf
channel ORA_DISK_1: reading from backup piece /u00/dbbackup/standbydb0tle80d5_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u00/dbbackup/standbydb0tle80d5_1_1 tag=TAG20100521T125501
channel ORA_DISK_1: restore complete, elapsed time: 00:01:35
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00005 to /u00/oracle/standbydb/example01.dbf
restoring datafile 00007 to /u00/oracle/standbydb/rman.dbf
restoring datafile 00012 to /u00/oracle/standbydb/lizi.dbf
channel ORA_DISK_1: reading from backup piece /u00/dbbackup/standbydb0vle80d5_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u00/dbbackup/standbydb0vle80d5_1_1 tag=TAG20100521T125501
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u00/oracle/standbydb/system01.dbf
restoring datafile 00002 to /u00/oracle/standbydb/undotbs01.dbf
restoring datafile 00003 to /u00/oracle/standbydb/sysaux01.dbf
channel ORA_DISK_1: reading from backup piece /u00/dbbackup/standbydb0ule80d5_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u00/dbbackup/standbydb0ule80d5_1_1 tag=TAG20100521T125501
channel ORA_DISK_1: restore complete, elapsed time: 00:01:25
Finished restore at 2010-05-21 13:12:49
RMAN> recover database;
Starting recover at 2010-05-21 13:13:20
using channel ORA_DISK_1
starting media recovery
archive log thread 1 sequence 12 is already on disk as file /u00/oracle/standbydb/redo03.log
archive log filename=/u00/oracle/standbydb/redo03.log thread=1 sequence=12
media recovery complete, elapsed time: 00:00:04
Finished recover at 2010-05-21 13:13:24
RMAN> recover database;
Starting recover at 2010-05-21 13:13:50
using channel ORA_DISK_1
starting media recovery
archive log thread 1 sequence 12 is already on disk as file /u00/oracle/standbydb/redo03.log
archive log filename=/u00/oracle/standbydb/redo03.log thread=1 sequence=12
media recovery complete, elapsed time: 00:00:01
Finished recover at 2010-05-21 13:13:51
RMAN> alter database open resetlogs;
database opened
RMAN>
RMAN>
RMAN>
RMAN> exit

Recovery Manager complete.
 
第四步、创建临时表空间
阅读(1505) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~