五、在primary server对数据库进行全库备份:

 

[ora9i@ORA10G standby]$ rman

 

Recovery Manager: Release 9.2.0.4.0 - Production

 

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

 

RMAN> connect target

 

connected to target database: DBA9I (DBID=3025467786)

 

RMAN> run                                                                                        

 {

2> 3>  allocate channel ch1 type disk maxpiecesize =2G;

4>  allocate channel ch2 type disk maxpiecesize =2G;

5>  backup database filesperset 8 format '/u02/9i/standby/%d_DF_%T_%s_%p.bak';

 sql "alter system archive log current";

6> 7>  backup current controlfile for standby format '/u02/9i/standby/%d_CTL_%T_%s_%p.bak';

8>  backup archivelog all format '/u02/9i/standby/%d_ARC_%T_%s_%p.bak' delete all input;

9>  release channel ch1;

10>  release channel ch2;

11> }

 

using target database controlfile instead of recovery catalog

allocated channel: ch1

channel ch1: sid=13 devtype=DISK

 

allocated channel: ch2

channel ch2: sid=12 devtype=DISK

 ......

released channel: ch1

 

released channel: ch2

 

 

 

六、Restoring the database to the standby location

 

PRIMARY SERVER 产生的BACKUP PIECE COPY TO STANDBY SERVER的同一目录

 

 

 

 

[ora9i@ORA10G standby]$  rman target / auxiliary sys/sys@STANDBY

 

Recovery Manager: Release 9.2.0.4.0 - Production

 

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

 

connected to target database: DBA9I (DBID=3025467786)

connected to auxiliary database: dba9i (not mounted)

 

RMAN>  run

2>  {

3>    allocate auxiliary channel dup1 type disk;

   allocate auxiliary channel dup2 type disk;

4> 5>    duplicate target database for standby

6>    dorecover NOFILENAMECHECK;

7>    }

 

using target database controlfile instead of recovery catalog

allocated channel: dup1

channel dup1: sid=11 devtype=DISK

 

allocated channel: dup2

channel dup2: sid=12 devtype=DISK

 

Starting Duplicate Db at 07-MAY-04

 

printing stored script: Memory Script

{

   restore clone standby controlfile to clone_cf;

   replicate clone controlfile from clone_cf;

   sql clone 'alter database mount standby database';

}

executing script: Memory Script

 

。。。。。。
released channel: dup1

released channel: dup2

 

 

--注意期间不能有新的ARCHIVELOG 产生。

[ora9i@ORA10G standby]$ sqlplus /nolog

 

SQL*Plus: Release 9.2.0.4.0 - Production on Fri May 7 14:23:03 2004

 

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

 

SQL> conn / as sysdba;

Connected.

 

SQL> alter system set log_archive_dest_state_2=enable;

 

System altered.

 

SQL> alter system switch logfile;

 

System altered.

 

 

 

--确认archicelog 是否传送成功

 

 

 

SQL> recover standby database;

ORA-00279: change 124210 generated at 05/07/2004 14:03:17 needed for thread 1

ORA-00289: suggestion : /u02/9i/arc/1_76.dbf

ORA-00280: change 124210 for thread 1 is in sequence #76

 

 

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

auto

ORA-00279: change 124622 generated at 05/07/2004 14:24:06 needed for thread 1

ORA-00289: suggestion : /u02/9i/arc/1_77.dbf

ORA-00280: change 124622 for thread 1 is in sequence #77

ORA-00278: log file '/u02/9i/arc/1_76.dbf' no longer needed for this recovery

 

 

ORA-00279: change 124625 generated at 05/07/2004 14:24:09 needed for thread 1

ORA-00289: suggestion : /u02/9i/arc/1_78.dbf

ORA-00280: change 124625 for thread 1 is in sequence #78

ORA-00278: log file '/u02/9i/arc/1_77.dbf' no longer needed for this recovery

 

 

ORA-00279: change 124739 generated at 05/07/2004 14:29:54 needed for thread 1

ORA-00289: suggestion : /u02/9i/arc/1_79.dbf

ORA-00280: change 124739 for thread 1 is in sequence #79

ORA-00278: log file '/u02/9i/arc/1_78.dbf' no longer needed for this recovery

 

 

ORA-00279: change 124742 generated at 05/07/2004 14:29:56 needed for thread 1

ORA-00289: suggestion : /u02/9i/arc/1_80.dbf

\

 

 

 

[ora9i@ORA10G standby]$ sqlplus /nolog

 

SQL*Plus: Release 9.2.0.4.0 - Production on Fri May 7 14:33:42 2004

 

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

 

SQL> conn system/manager

Connected.

SQL> create table test(name char(20));

 

Table created.

 

SQL> insert into test values('test');

 

1 row created.

 

SQL> commit;

 

Commit complete.

 

SQL> alter system switch logfile;

 

System altered.

 

 

SQL> conn / as sysdba;

Connected.

SQL> recover standby database;

ORA-00279: change 124762 generated at 05/07/2004 14:30:42 needed for thread 1

ORA-00289: suggestion : /u02/9i/arc/1_83.dbf

ORA-00280: change 124762 for thread 1 is in sequence #83

 

 

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

auto

ORA-00279: change 124855 generated at 05/07/2004 14:34:19 needed for thread 1

ORA-00289: suggestion : /u02/9i/arc/1_84.dbf

ORA-00280: change 124855 for thread 1 is in sequence #84

ORA-00278: log file '/u02/9i/arc/1_83.dbf' no longer needed for this recovery

 

 

ORA-00279: change 124933 generated at 05/07/2004 14:38:12 needed for thread 1

ORA-00289: suggestion : /u02/9i/arc/1_85.dbf

ORA-00280: change 124933 for thread 1 is in sequence #85

ORA-00278: log file '/u02/9i/arc/1_84.dbf' no longer needed for this recovery

 

 

ORA-00308: cannot open archived log '/u02/9i/arc/1_85.dbf'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

 

SQL> alter database open read only;

 

Database altered.

 

 

SQL> conn / as sysdba;

Connected.

SQL> alter database open read only;

 

Database altered.

 

SQL> select * from system.test;

 

NAME

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

test

 

 

 

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup nomount;

ORACLE instance started.

 

Total System Global Area   55645264 bytes

Fixed Size                   451664 bytes

Variable Size              46137344 bytes

Database Buffers            8388608 bytes

Redo Buffers                 667648 bytes

SQL> alter database mount standby;

alter database mount standby

                           *

ERROR at line 1:

ORA-00905: missing keyword

 

 

SQL> alter database mount standby database;

 

Database altered.

 

 

SQL> recover standby database;

ORA-00279: change 124933 generated at 05/07/2004 14:38:12 needed for thread 1

ORA-00289: suggestion : /u02/9i/arc/1_85.dbf

ORA-00280: change 124933 for thread 1 is in sequence #85

 

 

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

auto

ORA-00279: change 124971 generated at 05/07/2004 14:40:05 needed for thread 1

ORA-00289: suggestion : /u02/9i/arc/1_86.dbf

ORA-00280: change 124971 for thread 1 is in sequence #86

ORA-00278: log file '/u02/9i/arc/1_85.dbf' no longer needed for this recovery

 

 

ORA-00279: change 124973 generated at 05/07/2004 14:40:07 needed for thread 1

ORA-00289: suggestion : /u02/9i/arc/1_87.dbf

ORA-00280: change 124973 for thread 1 is in sequence #87

ORA-00278: log file '/u02/9i/arc/1_86.dbf' no longer needed for this recovery

 

 

ORA-00279: change 124976 generated at 05/07/2004 14:40:12 needed for thread 1

ORA-00289: suggestion : /u02/9i/arc/1_88.dbf

ORA-00280: change 124976 for thread 1 is in sequence #88

ORA-00278: log file '/u02/9i/arc/1_87.dbf' no longer needed for this recovery

 

 

ORA-00279: change 124978 generated at 05/07/2004 14:40:14 needed for thread 1

ORA-00289: suggestion : /u02/9i/arc/1_89.dbf

ORA-00280: change 124978 for thread 1 is in sequence #89

ORA-00278: log file '/u02/9i/arc/1_88.dbf' no longer needed for this recovery

 

 

ORA-00308: cannot open archived log '/u02/9i/arc/1_89.dbf'

ORA-27037: unable to obtain file status

Linux Error: 2: No such file or directory

Additional information: 3

 

 

 

 

 

 

 

SQL> alter database activate standby database;

 

Database altered.

 

SQL> shutdown immediate;

ORA-01507: database not mounted

 

 

ORACLE instance shut down.

SQL> startup

ORACLE instance started.

 

Total System Global Area   55645264 bytes

Fixed Size                   451664 bytes

Variable Size              46137344 bytes

Database Buffers            8388608 bytes

Redo Buffers                 667648 bytes

Database mounted.

Database opened.