实验环境:
1.虚拟机VMware Server 1.0.6
2.操作系统:
ora10g@linux5 /home/oracle$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5.1 (Tikanga)
3.数据库环境(OMF管理的数据库):
sys@ora10g> select * from v$version;

BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production

一.Primary 数据库配置及相关操作
1.确认primary库处于归档模式
sys@ora10g> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     33
Next log sequence to archive   35
Current log sequence           35

2.将primary库置为FORCE LOGGING 模式
sys@ora10g> alter database force logging;

Database altered.

3.在primary库创建standby数据库控制文件
sys@ora10g> alter database create standby controlfile as '/home/oracle/backup/ora10gdg.ctl';

Database altered.

4.创建primary库客户端初始化参数文件
1).创建主库中的pfile
sys@ora10g> create pfile from spfile;

File created.

2).备份到backup目录用于创建备库的pfile
sys@ora10g> ! cp /oracle/u01/app/oracle/product/10.2.0/db_1/dbs/initora10g.ora /home/oracle/backup/initora10gdg.ora

3).修改后主库pfile中内容如下:
ora10gdg@linux5 /oracle/u01/app/oracle/product/10.2.0/db_1/dbs$ cat initora10g.ora
ora10g.__db_cache_size=20971520
ora10g.__java_pool_size=4194304
ora10g.__large_pool_size=4194304
ora10g.__shared_pool_size=71303168
ora10g.__streams_pool_size=0
*.audit_file_dest='/oracle/u01/app/oracle/admin/ora10g/adump'
*.background_dump_dest='/oracle/u01/app/oracle/admin/ora10g/bdump'
*.compatible='10.2.0.3.0'
*.control_files='/oracle/u02/oradata/ORA10G/controlfile/o1_mf_4srph8fv_.ctl','/oracle/u01/app/oracle/flash_recovery_area/ORA10G/controlfile/o1_mf_4srph96b_.ctl'
*.core_dump_dest='/oracle/u01/app/oracle/admin/ora10g/cdump'
*.cursor_sharing='EXACT'
*.db_block_size=8192
*.db_create_file_dest='/oracle/u02/oradata'
*.db_create_online_log_dest_1='/oracle/u01'
*.db_create_online_log_dest_2='/oracle/u02'
*.db_create_online_log_dest_3='/oracle/u02'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='ora10g'
*.db_recovery_file_dest='/oracle/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4294967296
*.job_queue_processes=10
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_max_size=104857600
*.sga_target=104857600
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/oracle/u01/app/oracle/admin/ora10g/udump'

#################################################################
#Parameters for Primary Database.
#################################################################
*.DB_NAME='ora10g'
*.DB_UNIQUE_NAME=ora10g
*.LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(ora10g,ora10gdg)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/oracle/u02/oradata/ORA10G VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ora10g'
*.LOG_ARCHIVE_DEST_2='SERVICE=ora10gdg LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ora10gdg'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE

#################################################################
#Parameters which using for switch over from Primary to Standby.
#################################################################
*.FAL_SERVER=ora10gdg
*.FAL_CLIENT=ora10g
*.DB_FILE_NAME_CONVERT='/oracle/u02/oradata/ORA10GDG/datafile','/oracle/u02/oradata/ORA10G/datafile'
*.LOG_FILE_NAME_CONVERT='/oracle/u02/oradata/ORA10GDG/onlinelog','/oracle/u02/oradata/ORA10G/onlinelog'
*.STANDBY_FILE_MANAGEMENT=AUTO
*.STANDBY_ARCHIVE_DEST='/ora10g_arch'

4).通过pfile 重建spfile
sys@ora10g> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

NotConnected@> create spfile from pfile='initora10g.ora';

File created.

5.配置tnsnames.ora文件
ora10g@linux5 /oracle/u01/app/oracle/product/10.2.0/db_1/network/admin$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /oracle/u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORA10G =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = linux5)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ora10g)
    )
  )

ORA10GDG =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = linux5)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ora10gdg)
    )
  )

EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )

ora10g@linux5 /oracle/u02/oradata/ORA10GDG/controlfile$ tnsping ora10g

TNS Ping Utility for Linux: Version 10.2.0.4.0 - Production on 25-MAR-2009 03:03:10

Copyright (c) 1997,  2007, Oracle.  All rights reserved.

Used parameter files:
/oracle/u01/app/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = linux5)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ora10g)))
OK (50 msec)
ora10g@linux5 /oracle/u02/oradata/ORA10GDG/controlfile$ tnsping ora10gdg

TNS Ping Utility for Linux: Version 10.2.0.4.0 - Production on 25-MAR-2009 03:03:17

Copyright (c) 1997,  2007, Oracle.  All rights reserved.

Used parameter files:
/oracle/u01/app/oracle/product/10.2.0/db_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = linux5)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ora10gdg)))
OK (10 msec)

二.Standby数据库配置及相关操作
1.创建密码文件,注意保持sys 密码与primary 数据库一致
ora10g@linux5 /oracle/u01/app/oracle/product/10.2.0/db_1/dbs$ orapwd file=orapwora10gdg password=sys entries=30

2.创建所需目录(注意OMF管理的文件)
ora10g@linux5 /home/oracle$ cd $ORACLE_BASE/admin
ora10g@linux5 /oracle/u01/app/oracle/admin$ mkdir ora10gdg
ora10g@linux5 /oracle/u01/app/oracle/admin$ cd ora10gdg
ora10g@linux5 /oracle/u01/app/oracle/admin/ora10gdg$ mkdir dpdump
ora10g@linux5 /oracle/u01/app/oracle/admin/ora10gdg$ mkdir cdump
ora10g@linux5 /oracle/u01/app/oracle/admin/ora10gdg$ mkdir pfile
ora10g@linux5 /oracle/u01/app/oracle/admin/ora10gdg$ mkdir bdump
ora10g@linux5 /oracle/u01/app/oracle/admin/ora10gdg$ mkdir udump
ora10g@linux5 /oracle/u01/app/oracle/admin/ora10gdg$ mkdir adump

ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area$ mkdir ORA10GDG
ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area$ cd ORA10GDG
ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG$ mkdir controlfile
ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG$ mkdir onlinelog
ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG$ mkdir backupset
ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG$ mkdir autobackup
ora10g@linux5 /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG$ mkdir archivelog

3.复制数据文件到standby库对应的目录(datafile,log,controlfiles)
1).拷贝数据文件
$ cp -R /oracle/u02/oradata/ORA10G/datafile /oracle/u02/oradata/ORA10GDG
2).拷贝日志文件,注意是OMF管理的
$ cp -R /oracle/u02/oradata/ORA10G/onlinelog /oracle/u02/oradata/ORA10GDG
$ cp -R /oracle/u01/app/oracle/flash_recovery_area/ORA10G/onlinelog /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG
3).拷贝主库生成的控制文件,注意是OMF管理的
$ cp /home/oracle/backup/ora10gdg.ctl /oracle/u02/oradata/ORA10GDG/controlfile/o1_mf_4srph8fv_.ctl
$ cp /home/oracle/backup/ora10gdg.ctl /oracle/u01/app/oracle/flash_recovery_area/ORA10GDG/controlfile/o1_mf_4srph96b_.ctl

4.修改standby初始化参数文件
1).standby的初始化参数如下
ora10gdg@linux5 /oracle/u01/app/oracle/product/10.2.0/db_1/dbs$ cat initora10gdg.ora
ora10g.__db_cache_size=20971520
ora10g.__java_pool_size=4194304
ora10g.__large_pool_size=4194304
ora10g.__shared_pool_size=71303168
ora10g.__streams_pool_size=0
*.audit_file_dest='/oracle/u01/app/oracle/admin/ora10gdg/adump'
*.background_dump_dest='/oracle/u01/app/oracle/admin/ora10gdg/bdump'
*.compatible='10.2.0.3.0'
*.control_files='/oracle/u02/oradata/ORA10GDG/controlfile/o1_mf_4srph8fv_.ctl','/oracle/u01/app/oracle/flash_recovery_area/ORA10GDG/controlfile/o1_mf_4srph96b_.ctl'
*.core_dump_dest='/oracle/u01/app/oracle/admin/ora10gdg/cdump'
*.cursor_sharing='EXACT'
*.db_block_size=8192
*.db_create_file_dest='/oracle/u02/oradata'
*.db_create_online_log_dest_1='/oracle/u01'
*.db_create_online_log_dest_2='/oracle/u02'
*.db_create_online_log_dest_3='/oracle/u02'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='ora10g'
*.db_recovery_file_dest='/oracle/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4294967296
*.job_queue_processes=10
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_max_size=104857600
*.sga_target=104857600
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/oracle/u01/app/oracle/admin/ora10gdg/udump'

#################################################################
#Parameters for Standby Database.
#################################################################
*.DB_NAME='ora10g'
*.DB_UNIQUE_NAME=ora10gdg
*.LOG_ARCHIVE_FORMAT=log%t_%s_%r.arc
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(ora10g,ora10gdg)'
*.DB_FILE_NAME_CONVERT='/oracle/u02/oradata/ORA10G/datafile','/oracle/u02/oradata/ORA10GDG/datafile'
*.LOG_FILE_NAME_CONVERT='/oracle/u02/oradata/ORA10G/onlinelog','/oracle/u02/oradata/ORA10GDG/onlinelog'
*.STANDBY_ARCHIVE_DEST='/ora10gdg_arch'
*.FAL_SERVER=ora10g
*.FAL_CLIENT=ora10gdg
*.STANDBY_FILE_MANAGEMENT=AUTO

#################################################################
#Parameters which using for switch over from Standby to Primary.
#################################################################
*.LOG_ARCHIVE_DEST_1='LOCATION=/oracle/u02/oradata/ORA10GDG VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ora10gdg'
*.LOG_ARCHIVE_DEST_2='SERVICE=ora10g LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ora10g'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
*.REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE

2).通过该pfile 创建spfile
NotConnected@> create spfile from pfile= 'initora10gdg.ora';

File created.

5.启动standby 到mount
NotConnected@> startup mount;
ORACLE instance started.

Total System Global Area  104857600 bytes
Fixed Size                  1266056 bytes
Variable Size              79695480 bytes
Database Buffers           20971520 bytes
Redo Buffers                2924544 bytes
Database mounted.

6.启动redo 应用
NotConnected@> alter database recover managed standby database disconnect from session;

Database altered.

7.查看同步情况
首先连接到primary 数据库
sys@ora10g> select instance_name,host_name,version,status from v$instance;

INSTANCE_NAME    HOST_NAME            VERSION           STATUS
---------------- -------------------- ----------------- ------------
ora10g           linux5               10.2.0.4.0        OPEN

sys@ora10g> alter system switch logfile;

System altered.

sys@ora10g> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
--------------
            36

连接到standby 数据库
NotConnected@> select instance_name,host_name,version,status from v$instance;

INSTANCE_NAME    HOST_NAME            VERSION           STATUS
---------------- -------------------- ----------------- ------------
ora10gdg         linux5               10.2.0.4.0        MOUNTED

NotConnected@> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
--------------
            36

8.暂停redo 应用
NotConnected@>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

三.验证standby数据库正确性
1.primary在sec用户创建一个表
sec@ora10g> create table test_dg (a int);

Table created.

sec@ora10g> conn / as sysdba
Connected.
sys@ora10g> alter system switch logfile;

System altered.

sys@ora10g> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
--------------
            38

2.查看standby是否存在该表
NotConnected@> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)
--------------
            38

NotConnected@> alter database recover managed standby database cancel;

Database altered.

NotConnected@> alter database open read only;

Database altered.

sys@ora10gdg> conn sec/sec
Connected.

sec@ora10gdg> desc test_dg;
 Name       Null?    Type
 ---------- -------- ---------------
 A                   NUMBER(38)

OK,成功。

同一服务器配置DataGuard的更多相关文章

  1. Oracle Grid control 11g及Active DataGuard 11g安装部署

    Oracle Grid control 11g及Active DataGuard 11g安装部署(一) 原贴 http://blog.csdn.net/lichangzai/article/detai ...

  2. 使用Oracle 11g新特性 Active Database Duplication 搭建Dataguard环境

    Duplication Database 介绍 Duplicate database可以按照用途分为2种: duplicate database(复制出一个数据库) duplicate standby ...

  3. Oracle 11.2.0.4 DataGuard 环境打PSU,OJVM PSU补丁快速参考

    环境:RHEL6.5 + Oracle 11.2.0.4 DataGuard physical standby 主库和备库都是单节点. 需求:主备库同时应用160719的PSU和OJVM PSU补丁. ...

  4. Linux服务器配置之加载硬盘

    Linux服务器配置之加载硬盘 1.修改密码 passwd 2.测试密码是否成功 3.查看硬盘信息 fdisk –l 4.格式化分区 fdisk /dev/vdb 5.查看分区 6.快速格式化/dev ...

  5. Windows Server 2008 R2 WEB服务器配置系列文章索引

    最近这段时间趁天翼云1元主机活动,购买了一个1元主机,主要是为了写一些服务器配置的教程. 已经完成如下几篇文章,送给大家. 国内云主机比较 天翼云/阿里云/腾讯云 Windows Server 200 ...

  6. Window下python2.7+Apache+mod_wsgi+Django服务器配置

    前言:试着使用python搭建一个网页,分别在windows下和linux下,本篇文章主要讲解Window下python+Apache+mod_wsgi+Django服务器配置过程中遇见的问题和解决方 ...

  7. Samba服务器配置

    Samba服务器配置流程: (1)安装samba服务器先用#rpm -ivh samba-列出与samba有关的rpm包然后选择第一个包,用tab键补齐文件名 (2)创建新用户和其密码#useradd ...

  8. 给11gR2 Dataguard打psu补丁的步骤及注意事项

    参考文档278641.1 0.备份备主备库的spfile备份主库的数据 1.在主库上暂停向备库传日志alter system set log_archive_dest_state_X=defer sc ...

  9. dataguard不同步问题ora-16191解决

    公司的11g的dataguard主备不同步,检查步骤如下: Primary:查询主库的最大日志 SQL> select max(sequence#) from v$archived_log;SQ ...

随机推荐

  1. web图片轮播实现

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  2. django的信号

    Django中提供了“信号调度”,用于在框架执行操作时解耦.通俗来讲,就是一些动作发生的时候,信号允许特定的发送者去提醒一些接受者. 1.Django内置信号 Model signals pre_in ...

  3. 介绍 .Net工具Code Snippet 与 Sql Server2008工具SSMS Tools Pack

    不久前,某某在微软写了一个很酷的工具:Visual Stuido2008可视化代码片断工具,这个工具可以在http://www.codeplex.com/SnippetDesigner上免费下载,用它 ...

  4. join

    一句话 join(param) 是把  array 连城一个字符串,中间用 param隔开

  5. 【leetcode】Word Ladder II

      Word Ladder II Given two words (start and end), and a dictionary, find all shortest transformation ...

  6. [Linux]yum开启rpm包缓存

    在CentOS下用yum安装,回发现在/var/cache/yum/下的base.extrs和updates下的packages下都没有发现下载的RPM 原来在/etc/yum.conf下没有设置下载 ...

  7. ffmpeg-20160515-git-bin

    ESC 退出 0 进度条开关 1 屏幕原始大小 2 屏幕1/2大小 3 屏幕1/3大小 4 屏幕1/4大小 S 下一帧 [ -2秒 ] +2秒 ; -1秒 ' +1秒 下一个帧 -> -5秒 f ...

  8. codeforces 490B.Queue 解题报告

    题目链接:http://codeforces.com/problemset/problem/490/B 题目意思:给出每个人 i 站在他前面的人的编号 ai 和后面的人的编号 bi.注意,排在第一个位 ...

  9. 【数据结构】DFS求有向图的强连通分量

    用十字链表结构写的,根据数据结构书上的描述和自己的理解实现.但理解的不透彻,所以不知道有没有错误.但实验了几个都ok. #include <iostream> #include <v ...

  10. 无限轮播的N+2 策略

    N张照片把contentsSize设置为N+2个图片的宽度,例子如下,两端填充如图,当处于一端时,且即将进入循环状态的时候,如第二张图,从状态1滑动到状态2,在滑动结束的时候,将当前的位置直接转到状态 ...