利用rman在同一臺機器上主庫online搭建standby

paulyibinyi發表於2007-12-19

1.用oradmin新建一個例項名test
C:\Documents and Settings\Paul Yi>oradim -new -sid test

2.準備引數檔案 d:\inittest.ora檔案
*.background_dump_dest='D:\oracle\admin\test\bdump'
*.compatible='9.2.0.0.0'
*.control_files='D:\oracle\oradata\test\control01.ctl','D:\oracle\oradata\test\control02.ctl','D:\oracle\oradata\test\control03.ctl'
*.core_dump_dest='D:\oracle\admin\test\cdump'
*.db_name='paul'
*.lock_name_space='test'
*.db_file_name_convert='d:\oracle\oradata\paul','d:\oracle\oradata\test'
*.log_file_name_convert='d:\oracle\oradata\paul','d:\oracle\oradata\test'
*.fal_server=paul
*.fal_client=test
*.standby_archive_dest='location=e:\archtest'
*.standby_file_management=auto
*.log_archive_format='%t_%s.dbf'
*.log_archive_start=TRUE
*.user_dump_dest='D:\oracle\admin\test\udump'

3.生成密碼檔案
C:\Documents and Settings\Paul Yi>orapwd file=d:\oracle\ora92\database\pwdtest.o
ra password=abcdefg entries=10

4.配置listener.ora和tnsnames.ora檔案
.配置網路

配置主備庫的listener.ora,tnsnames.ora。修改完lisner.ora後注意重啟監聽。

Listener.ora

LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.163)(PORT = 1521))
)

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = d:\oracle\ora92)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = paul)
(ORACLE_HOME = d:\oracle\ora92)
(SID_NAME = paul)
)
(SID_DESC =
(GLOBAL_DBNAME = test)
(ORACLE_HOME = d:\oracle\ora92)
(SID_NAME = test)
)
)

tnsnames.ora

paul =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.163)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = paul)
)
)


test =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.163)(PORT = 1521))
)
(CONNECT_DATA =
(SID = test)
)
)

7.使用rman備份主庫


C:\Documents and Settings\Paul Yi>rman target /

Recovery Manager: Release 9.2.0.4.0 - Production

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

connected to target database: PAUL (DBID=1605165889)

RMAN> backup full database;

Starting backup at 19-DEC-07
using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=13 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=D:\ORACLE\ORADATA\PAUL\SYSTEM01.DBF
input datafile fno=00002 name=D:\ORACLE\ORADATA\PAUL\UNDOTBS01.DBF
input datafile fno=00003 name=D:\ORACLE\ORADATA\PAUL\INDX01.DBF
input datafile fno=00005 name=D:\ORACLE\ORADATA\PAUL\USERS01.DBF
input datafile fno=00004 name=D:\ORACLE\ORADATA\PAUL\TOOLS01.DBF
input datafile fno=00006 name=D:\TEST01_P.DBF
input datafile fno=00007 name=D:\TEST02_P.DBF
input datafile fno=00008 name=D:\TEST03_P.ORA
channel ORA_DISK_1: starting piece 1 at 19-DEC-07
channel ORA_DISK_1: finished piece 1 at 19-DEC-07
piece handle=D:\BACKUP\1SJ40FFL_1_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:46
Finished backup at 19-DEC-07

Starting Control File and SPFILE Autobackup at 19-DEC-07
piece handle=D:\BACKUP\C-1605165889-20071219-03 comment=NONE
Finished Control File and SPFILE Autobackup at 19-DEC-07

8.生成備庫控制檔案
SQL> alter database create standby controlfile as 'd:\control01.ctl' reuse;

Database altered.

複製兩份,放到 d:\oracle\oradata\test\下面,並改名為control02.ctl,control03.ctl


9.啟動備庫到nomount狀態
C:\Documents and Settings\Paul Yi>sqlplus /nolog

SQL*Plus: Release 9.2.0.4.0 - Production on Wed Dec 19 14:25:05 2007

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

SQL> conn as sysdba
Connected to an idle instance.
SQL> startup nomount pfile='d:\inittest.ora';
ORACLE instance started.

Total System Global Area  101785252 bytes
Fixed Size                   454308 bytes
Variable Size              75497472 bytes
Database Buffers           25165824 bytes
Redo Buffers                 667648 bytes
啟動到備庫
SQL> alter database mount standby database;

Database altered.

11.利用rman恢復出備庫
C:\Documents and Settings\Paul Yi>rman target

Recovery Manager: Release 9.2.0.4.0 - Production

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

connected to target database: PAUL (DBID=1605165889)

RMAN> restore database;

Starting restore at 19-DEC-07

using target database controlfile instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=10 devtype=DISK
skipping datafile 1; already restored to file D:\ORACLE\ORADATA\TEST\SYSTEM01.DB
F
skipping datafile 2; already restored to file D:\ORACLE\ORADATA\TEST\UNDOTBS01.D
BF
skipping datafile 3; already restored to file D:\ORACLE\ORADATA\TEST\INDX01.DBF
skipping datafile 4; already restored to file D:\ORACLE\ORADATA\TEST\TOOLS01.DBF

skipping datafile 5; already restored to file D:\ORACLE\ORADATA\TEST\USERS01.DBF

skipping datafile 8; already restored to file D:\TEST03_P.ORA
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00006 to D:\TEST01_P.DBF
restoring datafile 00007 to D:\TEST02_P.DBF
channel ORA_DISK_1: restored backup piece 1
piece handle=D:\BACKUP\1SJ40FFL_1_1 tag=TAG20071219T141933 params=NULL
channel ORA_DISK_1: restore complete
Finished restore at 19-DEC-07

13.將備庫置於自動恢復狀態
SQL> conn as sysdba
Connected.

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

Database altered.
SQL> select process,status from v$managed_standby;

PROCESS STATUS
------- ------------
ARCH CONNECTED
ARCH CONNECTED
MRP0 WAIT_FOR_LOG
RFS RECEIVING

 完成

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7199859/viewspace-883/,如需轉載,請註明出處,否則將追究法律責任。

相關文章