ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 配置Oracle physical DataGuard

配置Oracle physical DataGuard

原创 Linux操作系统 作者:byfree 时间:2009-04-13 15:57:21 0 删除 编辑
Primary SID:orcl   ORACLE_HOME= D:\oracle\product\10.2.0\oradata\orcl
Standby SID:standby  ORACLE_HOME= D:\oracle\product\10.2.0\oradata\standby
1. 准备primary database
2. 备份primary database
3. 拷贝相关primary database文件到standby system
4. 设置physical standby的参数文件
5. 启动standby
6. 配置listener和tnsnames
7. 配置primary system的参数文件
8. 传输归档日志文件
1. 准备primary database
1) 设置database为force logging
   SQL>alter database force logging;
2) 创建口令文件
C:\>orapwd file=d:\PWDorcl.ora password=sys
3) 打开归档模式
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
SQL> ALTER DATABASE ARCHIVELOG;
SQL> ALTER DATABASE OPEN;
2. 备份primary database
1) 冷备份
SQL>shutdown immediate;
拷贝D:\oracle\product\10.2.0\oradata\orcl到D:\oracle\product\10.2.0\oradata\standby
2) RMAN备份(采用压缩方式)
RMAN> backup as compressed backupset database;
3) 确认备份完成后,创建standby controlfile
SQL> alter database create standby controlfile as ‘d:\standby.ctl’;
3. 拷贝相关primary database文件到standby system
1) 拷贝备份文件至相应位置
2) 拷贝口令文件到standby system相应位置
Windows:%ORACLE_HOME%\database\
Unix&linux:$ORACLE_HOME\dbs\
(测试时primary和standby在同一主机,口令文件不用复制)
3) 拷贝standby.ctl到D:\oracle\product\10.2.0\oradata\standby\
4. 设置physical standby的参数文件
1) Primary上创建pfile文件
SQL>create pfile=’d:\init.ora’ from spfile;
2) 编辑init.ora,增加如下项:
DB_NAME=orcl
DB_UNIQUE_NAME=standby
LOG_ARCHIVE_CONFIG=’DG_CONFIG=(orcl,standby)’
CONTROL_FILES=’D:\oracle\product\10.2.0\oradata\standby\standby.ctl’
LOG_ARCHIVE_DEST_1=’location= D:\oracle\product\10.2.0\oradata\standby\arch’
LOG_ARCHIVE_DEST_2=’service=standby optional’
DB_FILE_NAME_CONVERT=‘D:\oracle\product\10.2.0\oradata\orcl’,’D:\oracle\product\10.2.0\oradata\standby’
LOG_FILE_NAME_CONVERT=’D:\oracle\product\10.2.0\oradata\orcl’,’D:\oracle\product\10.2.0\oradata\standby’
STANDBY_FILE_MANAGEMEN=’auto’
AUDIT_FILE_DEST=’D:\oracle\product\10.2.0\admin\standby\adump’
BACKGROUND_DUMP_DEST=’D:\oracle\product\10.2.0\admin\standby\bdump’
CORE_DUMP_DEST=’D:\oracle\product\10.2.0\admin\standby\cdump’
USER_DUMP_DEST=’D:\oracle\product\10.2.0\admin\standby\udump’
5. 启动standby
1) Windows平台下,使用oradim创建standby
C:\>oradim –NEW –SID standby
2) 使用init.ora参数文件启动standby
C:\>set oracle_sid=standby
C:\>sqlplus / as sysdba
SQL>startup nomount pfile=d:\init.ora
SQL>alter database mount standby database;
启动过程如果报ORA-00205错,请检查controlfile的放置路径是否与init.ora中指定的一致。
6. 配置listener和tnsnames
1) 配置listener
primary和standby在同一主机,可使用同一个监听,增加黑体部分即可:
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = D:\oracle\product\10.2.0\db_1)
      (SID_NAME = orcl)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = standby)
      (ORACLE_HOME = D:\oracle\product\10.2.0\db_1)
      (SID_NAME = standby)
    ) 
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    )
  )
2) 配置tnsnames
增加standby黑体部分,ORCL为原有指向primary部分
standby =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = standby)
    )
  )
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )
7. 配置primary system的参数文件
1) 创建primary的pfile文件
 SQL>create pfile=’d:\initorcl.ora’ from spfile;
2) 编辑initorcl.ora文件,增加如下内容:
DB_NAME=orcl
DB_UNIQUE_NAME=orcl
LOG_ARCHIVE_CONFIG=’DG_CONFIG=(orcl,standby)’
LOG_ARCHIVE_DEST_1=’location= D:\oracle\product\10.2.0\oradata\orcl\arch’
LOG_ARCHIVE_DEST_2=’service=standby optional’
STANDBY_FILE_MANAGEMEN=’auto’
8. 传输归档日志文件
1) 启动primary至open状态
SQL>startup
SQL>alter system switch logfile;
查看log_archive_dest_1与log_archive_dest_2的状态
SQL>select dest_id,status,error from v$arhive_dest;
如status不正常,error会列出问题所在
查看归档日志是否传输到standby指定的LOG_ARCHIVE_DEST_1目录下,如没有,且在alert日志中出现“ORA-01031: 权限不足”,则说明口令文件存在问题,检查口令文件路径及命名是否正确。
口令文件默认路径及命名:
Windows:%ORACLE_HOME%\database\PWDsid.ora (PWDorcl.ora)
Unix&linux:$ORACLE_HOME\dbs\orapwSID (orapwORCL)
手动传输归档日志并应用:
例如传输primary的ARC00046_0683553865.001归档文件到standby的d:\下,
SQL> alter database register physical logfile 'd:\ ARC00046_0683553865.001';
SQL> select sequence#,applied from v$archived_log;
 SEQUENCE# APP
---------- ---
        46 NO
SQL> alter database recover managed standby database disconnect from session;
数据库已更改。
SQL> select sequence#,applied from v$archived_log;
 SEQUENCE# APP
---------- ---
        46 YES
至此,归档46已应用到了standby中。
2) 启动standby至mount状态
SQL>startup nomount pfile=d:\init.ora
SQL>alter database mount standby database;
3) 应用归档日志
如归档日志已传至standby相应目录下:
在后台应用归档日志
SQL>alter database recover managed standby database disconnect from session;
在前台应用归档日志
SQL>alter database recover managed standby database;
停止应用归档
SQL>alter database recover managed standby database cancel;
4) Read only open database
停止应用归档后:
SQL>alter database open read only;
此时即可检查primary与standby的数据一致性。

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

下一篇: DATAGUARD SWITCHOVER
请登录后发表评论 登录
全部评论

注册时间:2008-04-16

  • 博文量
    65
  • 访问量
    212893