ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 成功创建standby database using RMAN

成功创建standby database using RMAN

原创 Linux操作系统 作者:doris_hf 时间:2008-04-03 15:16:29 0 删除 编辑

这两日,一直在围绕着standby转,前几次总是遇到ORA-01180错误在restore的时候,后重新准备了一台机器,按照Note:469493.1上的步骤,终于实验成功,下面是具体的步骤:

 

一、准备primary database

a)         Modify parameter file of primary database, following are some important parameters:

db_name=confgdb

db_unique_name=confgdbpri

db_recovery_file_dest = /u01/app/oracle/admin/confgdb/recover

db_recovery_file_dest_size = 2G

LOG_ARCHIVE_CONFIG='DG_CONFIG=(confgdbpri,confgdbstb)'

remote_login_passwordfile = EXCLUSIVE

log_archive_dest_1 = 'LOCATION=/u01/app/oracle/admin/confgdb/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=confgdbpri'

LOG_ARCHIVE_DEST_STATE_1=enable

log_archive_format = 'log%t_%s_%r.arc'

log_archive_dest_2 = 'SERVICE=confgdbstb arch ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=confgdbstb'

LOG_ARCHIVE_DEST_STATE_2=ENABLE

control_files = ('/u01/app/oracle/admin/confgdb/control01.dbf')

FAL_SERVER=confgdbpri

FAL_CLIENT=confgdbstb

STANDBY_FILE_MANAGEMENT=AUTO

 

b)         Create password file

$orapwd file=orapwconfgdb password=change_on_install entries=10

 

c)         SQL> alter database force logging;

 

二、备份primary database

a)         RMAN> run

{

allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

backup database plus archivelog;

}

 

Default directory which backupset will exist is ‘db_recovery_file_dest/db_unique_name/dat

e/, in my environment, it is /u01/app/oracle/admin/confgdb/recover/CONFGDBPRI/

backupset/2008_04_03.

 

Please note this directory, you should create same directory in your standby server.

 

When you backup, please record dbid and controlfile backupset tag.

In my environment, they are 1175659046 and o1_mf_ncnnf_TAG20080403T023027_3z8jb3xp_.bkp respectively.

 

b)         Backup controlfile

RMAN> run

{

allocate channel c1 type disk;

backup current controlfile for standby;

}

 

三、准备standby server

a)         Create same directories with primary server

In my environment, I create following directory:

/u01/app/oracle/admin/confgdb/recover

/u01/app/oracle/admin/confgdb/bdump

/u01/app/oracle/admin/confgdb/cdump

/u01/app/oracle/admin/confgdb/udump

/u01/app/oracle/admin/confgdb/adump

/u01/app/oracle/admin/confgdb/utl

 

b)         Copy initial parameter file from primary server, and modify or keep some parameters:

db_name=confgdb

db_unique_name=confgdbstb

LOG_ARCHIVE_CONFIG='DG_CONFIG=(confgdbpri,confgdbstb)'

db_recovery_file_dest = /u01/app/oracle/admin/confgdb/recover

db_recovery_file_dest_size = 2G

log_archive_dest_1 = 'LOCATION=/u01/app/oracle/admin/confgdb/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=confgdbstb'

LOG_ARCHIVE_DEST_STATE_1=enable

log_archive_format = 'log%t_%s_%r.arc'

log_archive_dest_2 = 'SERVICE=confgdbstb arch ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=confgdbpri'

LOG_ARCHIVE_DEST_STATE_2=ENABLE

FAL_SERVER=confgdbstb

FAL_CLIENT=confgdbpri

 

c)         Copy password file from primary server

 

四、创建standby database

a)         Startup standby database

$export ORACLE_SID=confgdb

$RMAN target /

 

RMAN> startup nomount;

RMAN> set dbid=1175659046; -- it is very importand

 

b)         Restore controlfile

RMAN> restore standby controlfile from '/u01/app/oracle/admin/confgdb/recover/

o1_mf_ncnnf_TAG20080403T023027_3z8jb3xp_.bkp';

 

c)         Mount standby database

RMAN> sql 'alter database mount standby database';

 

d)         Restore database

RMAN> restore database;

 

Here, I meet ORA-01180 error:

RMAN-03002: failure of restore command at 04/03/2008 03:16:00

ORA-01180: can not create datafile 1

ORA-01110: data file 1: '/u01/app/oracle/admin/confgdb/system01.dbf'

 

So I add folder CONFGDBPRI/backupset/2008_04_03 under /u01/app/oracle/admin/co-

                   nfgdb/recover, and then list backupset:

                   RMAN> list backup;

                   All backupsets’ status are ‘EXPIRED’, then I crosscheck backupset:

                   RMAN> crosscheck backupset;

                   RMAN read valid backupset again, and it can find the valid backupset

                  

                   Continue restore and successful.

                   RMAN> restore database;

                  

e)         Recover sequence

RMAN> list backup of archivelog all;

Please notice last sequence number of list. In my environment, it is 25.

 

RMAN> recover database until sequence 26;

Please ignore oracle error.

 

RMAN> exit

 

f)          Put standby database in recover managed mode

SQL> alter database recover managed standby database disconnect from session;

 

五、测试standby database

a)         Primary database

SQL>alter system switch logfile;

SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SEQUENCE# FIRST_TIM NEXT_TIME

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

2 25-MAR-08 25-MAR-08

3 25-MAR-08 25-MAR-08

4 25-MAR-08 25-MAR-08

5 25-MAR-08 25-MAR-08

6 25-MAR-08 25-MAR-08

7 25-MAR-08 25-MAR-08

8 25-MAR-08 25-MAR-08

9 25-MAR-08 25-MAR-08

10 25-MAR-08 25-MAR-08

11 25-MAR-08 25-MAR-08

12 25-MAR-08 25-MAR-08

 

SEQUENCE# FIRST_TIM NEXT_TIME

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

13 25-MAR-08 25-MAR-08

14 25-MAR-08 25-MAR-08

15 25-MAR-08 25-MAR-08

16 25-MAR-08 25-MAR-08

17 25-MAR-08 26-MAR-08

18 26-MAR-08 26-MAR-08

19 26-MAR-08 28-MAR-08

20 28-MAR-08 29-MAR-08

21 29-MAR-08 31-MAR-08

22 31-MAR-08 02-APR-08

23 02-APR-08 02-APR-08

 

SEQUENCE# FIRST_TIM NEXT_TIME

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

24 02-APR-08 03-APR-08

25 03-APR-08 03-APR-08

26 03-APR-08 03-APR-08

27 03-APR-08 03-APR-08

28 03-APR-08 03-APR-08

29 03-APR-08 03-APR-08

 

Remember that the last sequence of archive log is 25 while backup. Now is 29. Let’s go to standby database to see whether it has received archive log.

 

b)         Standby database

SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

SEQUENCE# FIRST_TIM NEXT_TIME

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

25 03-APR-08 03-APR-08

26 03-APR-08 03-APR-08

27 03-APR-08 03-APR-08

28 03-APR-08 03-APR-08

29 03-APR-08 03-APR-08

 

Let’s to see whether standby database has apply archive log:

SQL> SELECT  sequence#, applied FROM v$archived_log ORDER BY sequence#;

 

SEQUENCE# APP

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

25 YES

26 YES

27 YES

28 YES

29 YES

30 YES

 

到目前为止,我们可以说已经成功创建standby database,具体是否能进行角色的成功切换,过两天再试。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/561895/viewspace-227884/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
下一篇: 保存LINK
请登录后发表评论 登录
全部评论

注册时间:2008-02-02

  • 博文量
    6
  • 访问量
    9594