ITPub博客

首页 > 数据库 > Oracle > Windows环境下的Oracle Data Guard安装和配置

Windows环境下的Oracle Data Guard安装和配置

原创 Oracle 作者:PercyWang 时间:2007-11-03 16:22:22 0 删除 编辑

操作环境:Windows 2003 企业版 + Serveice pack 2数据库:Oracle 9.2.0.1主库SID:dbguard IP: 192.168.159.133从库SID:dbguard IP: 192.168.159.131

其实网络上有很多关于data guard的安装配置资料,不过真正做起来还是会遇到很多问题的;在小杨的帮忙下,总算搞定了。

[@more@]

oracle安装采用OMF结构

1. 主从库均Install Oracle 9i,且只选择安装软件,不创建数据库

2. 在主库上使用DBCA,创建dbguard实例

3. 创建测试环境,创建test表空间和test用户以及test表和简单的几条记录

SQL> create table test

2 (ID integer,

3 Name varchar2(20)

4 );

表已创建。

SQL> insert into test values(1,'a');

已创建 1 行。

SQL> insert into test values(2,'b');

已创建 1 行。

SQL> commit;

提交完成。

SQL> select * from test;

ID NAME

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

1 a

2 b

4. 修改数据库为归档方式

SQL*Plus: Release 9.2.0.1.0 - Production on 星期二 10 9 20:02:24 2007

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

SQL> connect sys/wbq as sysdba;

SQL> startup mount;

SQL> alter database archivelog;

SQL> alter system set log_archive_dest_1='E:ORACLEora92databasearchive' scope=both;

SQL> alter system set log_archive_dest_2='service=standby' scope=both;

SQL> alter system set log_archive_start=true scope=spfile;

SQL> alter database open;

SQL> archive log list;

数据库日志模式 存档模式

自动存档 启用

存档终点 e:oracleoradataarchive

最早的概要日志序列 1

下一个存档日志序列 2

当前日志序列 2

SQL> show parameter archive

NAME TYPE VALUE

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

archive_lag_target integer 0

log_archive_dest string

log_archive_dest_1 string location=e:oracleoradataarchive

log_archive_dest_2 string service=standby

log_archive_duplex_dest string

log_archive_format string ARC%S.%T

log_archive_max_processes integer 2

log_archive_min_succeed_dest integer 1

log_archive_start boolean TRUE

log_archive_trace integer 0

remote_archive_enable string true

standby_archive_dest string %ORACLE_HOME%RDBMS

SQL> shutdown immediate;

5. 创建standby 控制文件和便于修改的pfile

SQL> alter database force logging;

数据库已更改。

SQL> select name,force_logging from v$database;

NAME FOR

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

DBGUARD YES

SQL> create pfile=' E:oracleadmindbguardpfilepfile.ora' from spfile;

文件已创建。

SQL> alter database create standby controlfile as 'e:oraclecontrol01.ctl';

6. 确定需要复制相应的数据文件、日志文件等,并关闭数据库

SQL> select file_name from dba_data_files;

FILE_NAME

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

E:ORACLEORADATADBGUARDSYSTEM01.DBF

E:ORACLEORADATADBGUARDUNDOTBS01.DBF

E:ORACLEORADATADBGUARDCWMLITE01.DBF

E:ORACLEORADATADBGUARDDRSYS01.DBF

E:ORACLEORADATADBGUARDEXAMPLE01.DBF

E:ORACLEORADATADBGUARDINDX01.DBF

E:ORACLEORADATADBGUARDODM01.DBF

E:ORACLEORADATADBGUARDTOOLS01.DBF

E:ORACLEORADATADBGUARDUSERS01.DBF

E:ORACLEORADATADBGUARDXDB01.DBF

E:ORACLEORADATADBGUARDTEST.ORA

已选择11行。

SQL> select member from v$logfile;

MEMBER

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

E:ORACLEORADATADBGUARDREDO03.LOG

E:ORACLEORADATADBGUARDREDO02.LOG

E:ORACLEORADATADBGUARDREDO01.LOG

SQL>shutdown immediate

7. 创建standby服务器相应的Oracle目录,并把主库文件复制到standby机器的指定目录下

Mkdir E:oracleadmindbguardbdump

Mkdir E:oracleadmindbguardcdump

Mkdir E:oracleadmindbguardcreate

Mkdir E:oracleadmindbguardpfile

Mkdir E:oracleadmindbguardudump

Mkdir D:oracleoradatadbguard

Mkdir D:oracleoradatadbguardarchive

8. 创建dbguardwindow服务

Oradim –NEW –SID dbguard –STARDMODE manual

复制通过主库创建的standby控制文件,并分别复制为control02.ctl,control03.ctl,并拷贝到相应的目录下

复制通过主库创建的参数文件并加以修改,添加以下信息

*.standby_archive_dest='E:oracleoradataarchive'

*.fal_server='primary'

*.fal_client='satndby'

*.standby_file_management=auto

*.lock_name_space='dbguard'

9. 创建密码文件

C:>orapwd file=E:oracleora92DATABASEPWDdbguard.ORA password=test

10. 配置主从服务器的listener.ora

--standby从库为以下信息;主库修改为192.168.159.133

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.159.131)(PORT = 1521))

)

)

)

11. 分别配置主从服务器的tnsname.ora保持一致

STANDBY =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.159.131)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = dbguard)

)

)

PRIMARY =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.159.133)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = dbguard)

)

)

12. 重新启动lsn侦听,并进行侦听查看主从机是否能够监听

Lsnrctl stop

Lsnrctl start

Tnsping standby

Tnsping primary

13. .启动物理Standby数据库

SQL> conn sys/test@dbguard as sysdba

已连接到空闲例程。

SQL> startup nomount;

ORACLE 例程已经启动。

Total System Global Area 101784276 bytes

Fixed Size 453332 bytes

Variable Size 75497472 bytes

Database Buffers 25165824 bytes

Redo Buffers 667648 bytes

SQL> create spfile from pfile;

文件已创建。

SQL> ALTER DATABASE MOUNT STANDBY DATABASE;

数据库已更改。

14. Standby数据库上,初始化Log Apply 服务

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

数据库已更改

15. 安装完的的验证

primary

SQL> select sequence#,first_time,next_time from v$archived_log;

SEQUENCE# FIRST_TIME NEXT_TIME

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

3 xxxx-xx-xx xxxx-xx-xx

standby

SQL> select sequence#,first_time,next_time from v$archived_log;

未选定行

primary

SQL> alter system archive log current;

系统已更改。

SQL> select sequence#,first_time,next_time from v$archived_log;

SEQUENCE# FIRST_TIME NEXT_TIME

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

xxxx-xx-xx xxxx-xx-xx

standby

SQL> select sequence#,first_time,next_time from v$archived_log;

SEQUENCE# FIRST_TIME NEXT_TIME

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

xxxx-xx-xx xxxx-xx-xx xx

SQL> select sequence#,applied from v$archived_log;

SEQUENCE# APP

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

5 YES

--YesOK

standby

SQL> select process,status from v$managed_standby;

PROCESS STATUS

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

ARCH CONNECTED

ARCH CONNECTED

MRP0 WAIT_FOR_LOG

RFS RECEIVING

RFS RECEIVING

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

请登录后发表评论 登录
全部评论
  • 博文量
    127
  • 访问量
    1755783