利用rman在同一台机器的oracle主库上在线搭建dataguard standby

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:946

利用rman在同一台机器的oracle主库上在线搭建dataguard standby

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文件
5.配置网络
6.配置主备库的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 ]/@test 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

10.启动到备库
SQL> alter database mount standby database;
Database altered.

11.利用rman恢复出备库
C:\Documents and Settings\Paul Yi>rman target ]/@test
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

12.将备库置于自动恢复状态
SQL> conn ]/@test 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
完成

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】